Listing and Terminating Processes
You can start processes in the foreground and background, suspend them, and move them between the foreground and background, but how do you know which commands are running? There are two commands to help you find out—jobs and ps.
jobs
The jobs command shows you the processes that are suspended and the ones running in the background. Because jobs runs as a foreground process, it cannot show you active foreground processes. In the following example, you have three jobs—the first one (job 3) is running, the second (job 2) is suspended (a foreground process after Ctrl+Z was issued), and the third one (job 1) is stopped in the background waiting for keyboard input:
$ jobs [3] + Running first_one & [2] - Stopped (SIGTSTP) ...
Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.