- Upgrade to Microsoft Office Pro and Windows 11 Pro with this bundle for 87% off
- Get 3 months of Xbox Game Pass Ultimate for 28% off
- Buy a Microsoft Project Pro or Microsoft Visio Pro license for just $18 with this deal
- How I optimized the cheapest 98-inch TV available to look and sound incredible (and it's $1,000 off)
- The best blood pressure watches of 2024
Backgrounding and foregrounding processes in the Linux terminal
Running commands in the Linux terminal is likely something you do nearly every day, but moving a running process into the “background” and later moving it back into the “foreground” is something different altogether. When a process is running in the foreground (the usual state of running commands), it could be said to “own your terminal”. In other words, you will likely sit and wait for it to finish before you even try to run another command. If a process is likely to take a long time to complete, on the other hand, you do have an option other than waiting patiently for it to get done. You can move it into the background – freeing up your terminal window to run other commands.
Moving a process to the background
To move a process into the background, you would type ^z (hold the Ctrl key and press “z”) to suspend it, and then type bg to move it into the background. The process will keep running, but you’ll get your prompt back and be able to work on something else while it’s still running to completion in the background. Note that a backgrounded process will keep running until it’s done or until you log off. Here’s an example:
$ sleep 1000 ^Z [1]+ Stopped sleep 1000 $ bg [1]+ sleep 1000 &
Checking on backgrounded processes with the jobs command
To list backgrounded processes, use the jobs command like this: