From the course: Complete Guide to Navigating Linux: Working with Users, Files, and Networks

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Background and foreground jobs

Background and foreground jobs

- While working with processes, it's also good if you know how to work with background and foreground jobs. First, what is a job? Well, a job is a process that is started interactively by a user from a shell. So, any comment that you are running is a job, and by default, jobs are started in the foreground. And if you want to start a job in the background, simply put an ampersand behind the command name. Alternatively, on our running job, you can use Control-Z to stop the current job, and bg to continue running this job in the background. The job's commands will list currently running jobs, and fg is used to move a job from the background to the foreground. Let's do a quick demo. So, when I use sleep 3600 to do nothing for an hour, then, well, it will do nothing for an hour. And if I would like, I can watch the blinking cursor, and if I don't, then I'm using Control-Z to temporarily stop it, and then I can use bg to continue running it in the background. I can also do that immediately…

Contents