Linux: Jobs Command

Before this command do anything useful, we have to run something:

tail -f /dev/null

Once you hit enter on the command above, hit Ctrl-Z to stop and go back to command prompt.

Now you can run the jobs command to list currently stopped/running-in-the-background jobs/commands.

jobs
[1]+  Stopped                 tail -f /dev/null

When you want to go back to your last stopped program you can type one of these commands:

%
%%
fg
fg %
fg %%

When you want to go back to a specific jobs you can type one of these commands:

%<jobs-number>
"%<full-or-partial-command-name-start-from-the-beginning>"
fg %<jobs-number>
fg "%<full-or-partial-command-name-start-from-the-beginning>"

BONUS:

To list process in tree style fashion you can type ps f.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *