- slide 1 of 7
Listing Stopped Jobs
Type the “jobs" command at a terminal prompt and press “Enter" to view information about stopped, running and terminated jobs for your current user session. The jobs command displays information about the jobs in three columns. The first column contains the job’s number, the second column contains the job’s status and the last column contains the command the job is running.
You can use the number displayed in the first column to perform actions on a specific job, such as starting it in the background, starting it in the foreground or terminating it.
- slide 2 of 7
You can type “fg" into the Ubuntu terminal and press “Enter" to start the most recently stopped job in the foreground. A job started in the foreground displays its output in the terminal window. You can also type “bg" instead to start the most recently stopped job in the background. A job running in the background doesn’t display any output in the terminal, leaving your terminal session free to perform other commands.
You can also use the “fg" or “bg" commands to start specific jobs in the foreground or background. Type “fg %1" or “bg %1" into the terminal to start a stopped job in the foreground or background, replacing “1" with the number of the stopped job from the jobs command, and press “Enter."
- slide 3 of 7
Once the job is started in the foreground, you can stop it again by pressing the “Ctrl" and “Z" keys on your keyboard at the same time, or terminate it entirely by pressing the “Ctrl" and “C" keys on your keyboard at the same time.
If a job is running in the background, you can use the “fg %1" command to bring it to the foreground, replacing “1" with the number of the job from the jobs command.
You can terminate a job with the kill command. Type “kill -9 %1" into the terminal, replacing “1" with the job’s number from the jobs command, and press “Enter" to kill the job. You’ll lose any open data the job hasn’t saved yet because the “kill -9" command forcibly terminates processes without allowing them to save any open data.
- slide 4 of 7
If you type the “logout" or “exit" commands into a terminal and receive the “There are stopped jobs" message, you don’t have to stop the jobs before logging out. This is a confirmation method to remind you that there are stopped jobs you will lose if you log out. You can continue with the log-out process and forcibly terminate the stopped jobs by typing the “logout" command into the terminal again and pressing “Enter" without typing the “jobs" command in between to list the stopped jobs. If you type the “jobs" command in between, you’ll have to type the “logout" command twice.
- slide 5 of 7
Ubuntu also includes the Upstart daemon, which replaces the traditional init daemon and manages the services running in the background on your Ubuntu system. Upstart also refers to the services installed on the system as jobs. You can use the “start" and “stop" commands to start stopped services and stop running services.
Type “sudo start service" into the terminal window, replacing “service" with the name of the stopped Upstart job you want to start, and press “Enter" to start a stopped upstart Job. You can also use the “sudo stop service" command to stop a running service.
The sudo command will prompt you for your password. Type it at the password prompt and press “Enter" to authenticate.
If you don’t know the exact name of the Upstart job you want to start, you can type “ls /etc/init.d" into the terminal and press “Enter" to see a list of Upstart jobs stored in the init.d directory.
- slide 6 of 7
Starting Jobs in the Background
By default, any command you type in the terminal runs as a foreground job. You can directly run a command as a background job by appending it with a space and an ampersand, such as “firefox &" to run Firefox as a background job. The Firefox browser window will open on your desktop, but your terminal won’t show Firefox’s status messages.