I want to read how much does my program uses resources in unix but cant [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have program that I need to run and then see how much resources it uses in unix by using top command. But I don't know how to do it because if i run it from command line I cant use top command till program is finished and vice versa. How can I do it. I tried doing:
sleep 10s
top
./myProgram
But its not working

Open two terminals; run your program in one terminal and top in another.
If you're in a graphical environment, you can just start the terminal a second time.
If you're on the text-only console, you can switch between terminals using Ctrl-Alt-F1..F6 (possibly more) or Alt-Left/Right.
If you connect via SSH, just open multiple terminal sessions in your SSH client.
(Also, I'd hint to use htop instead of top, but you may need to install it first.)
In case your program is too short-lived to show up on top/htop, you might need to run it using Valgrind.

Open two terminals one for running top, and run your program in the other.

Related

How to send data to a Linux terminal [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I need to send data to a Linux terminal, in this manner that terminal could receive the data with scanf? there is any way to do that?
I tried to write my desired data to /proc/pid/fd/1 with below command, however, I can see the written data in the terminal but scanf couldn't catch that data and still wait for the user to enter data.
printf "85\n" > /proc/24737/fd/1
This is a very interesting question, and there is no easy way (that I know of) to write to a another terminal using the file descriptors.
see https://unix.stackexchange.com/questions/385771/writing-to-stdin-of-a-process
However, Unix and Linux, have many great ways for IPC (inter process communication). You might want to looking into pipes, named pipes, or Sockets.
Depending on what you are doing you might think about popen, or screen.
You probably don't want to write to the terminal, but the task that is running on the terminal? Can you change how the task is invoked (called)? Do you need to use standard in for other things?
If you explain your use case, we will try to direct you better.

Alt-Tab for Linux command line? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am wondering if such a thing exists to where I could run a Java program remotely through SSH on my VPS and then Alt + Tab so that I can run other things in the command line without having to reconnect in a separate tab. I've tried looking through the Java options in the manual, but I couldn't find anything insightful.
In Linux/Unix kind system there is a utility called nohup. You can invoke any command or process using nohup; it will make your terminal free after execution. Linux/Unix systems also support background jobs by appending the character & at end of your command.
So if your Java process is as follows,
java <your program>
you can run it as follows:
nohup java <your program> &
This modified command frees your terminal and you can run another command as per your need.

startx /bin/bash in fullscreen without desktop [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Ok so I know it's a weird case but hang in here with me.
So the thing is I've got an very old laptop running ubuntu 14.04 server without any desktop aka shell only. BUT the laptop also has a touch screen so we want to be able to use the "mouse"/touchscreen/touchpad to select text inside the terminal and/or click/copy/paste/cut/etc. It's part of art project with some students and also one of the tasks is to run as less as possible. So running a desktop in the background is not really an option. My question is:
Is there a way to start the Ubuntu terminal as UI application in fullscreen without the actual desktop in the background but giving the functionality of an mouse cursor.
(If someone knows a even better solution for adding a mouse without starting the desktop its appreciated)
Try this: create a ~/.xinitrc with content : exec gnome-terminal, then run startx
Or another solution is to stay in tty and install gpm for mouse control

Run multiple commands in serial and make sure all commands run [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I want to run a series of unix commands, one after another. If any of these commands dies for whatever reason, subsequent commands should continue to run.
For instance, I have 3 commands called "setup", "long-running-job" and "teardown". If "long-running-job" finishes with whatever exit code, or dies unexpectedly, I want to make sure "teardown" gets run in any case.
Simply concatenating all commands with semicolons doesn't seem to work. I tried running touch test.txt; ping localhost; rm test.txt in macOS Terminal, closed the terminal tab while it's running, and found that the "test.text" didn't get removed.
If you want to make sure that even if your interactive window closes that your commands keep going and that all your command happen sequentially in the order you specify then use the method in this answer: https://unix.stackexchange.com/a/47231
Basically for the command line in your question
nohup sh -c 'touch test.txt; ping localhost; rm test.txt'
That means the hang up signal sent by closing the terminal is ignored.
Have you tried GNU parallel? Seems like the ideal tool for your needs.
$> parallel ::: setup long-running-job teardown
Parallel comes with tons of options to control halts, failures, jumps, retries, etc. See the manual and the tutorial for examples.

How to open applications after booting a purely Command line interface of Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
After booting linux in purly command line mode how can I open an application eg web browser or Libra Office?
For example if I use the command "play" with any audio file it starts to play it. I want to know commands for other applications
You have to start an X Window session before you can open those applications because they depend on it to render the GUI. To do this you can use the startx command.
There is a good description here on how to use startx.
However, doing it this way can be a lot of manual and tedious work. That's why most linux distros have packaged full window managers like Gnome, Xcfe, etc for you to install with a single command. If what you really want is a minimal one you might look at Fluxbox or Openbox. You can learn a lot about the guts of X by installing and configuring them on your own.
I suspect what you may really need is just to edit text files and get resources from the internet while logged into a Linux box that is command line only. If so, you can check out these command line only tools.
Lynx command line browser
WGet internet file retriever
EMacs text editor
Vim text editor

Resources