This post is concerned with running jobs (one or more programs) in foreground and background using just a terminal. Here, I use
firefox as an example to demonstrate the same. <username> on screenshots shown below is scrambled for privacy concerns.
Running programs from terminal
You can always run a job in foreground by typing a command on to the terminal as
But once the program starts we lose the bash prompt. Another way to start firefox is to run the program in background. This will return bash prompt as shown below.
Pause and resume jobs from terminal
Sometimes you need to pause a job that’s running and return to bash prompt and execute some commands and afterwards resume the original job. Press
CTRL+Z to pause the original job and return to command prompt as shown below. This will immediately pause
firefox and you will note able to use it for browsing the web.
firefox in background run
This will resume firefox but in background and returns bash prompt as shown above.
firefox in foreground run
This will resume firefox but in foreground, but will not return bash prompt as shown above.
Listing jobs in background and killing them
To list all the jobs running in background run
To kill a job running in background, find job ID (21689) from earlier listing