Terminating Processes

Managing tasks from the command line

Every so often, a program misbehaves. Sometimes, it’s due to something we configured incorrectly. Other times, it’s because the program has a bug. We’ve probably experienced a stuck program before and figured out how to kill the task using a graphical task manager. We can manage tasks from the command-line interface as well. All we need is the process ID.

Let’s start a long-running task in the background. In our terminal, we execute the following command:

sleep 9999999 &

This process is now running. We use the jobs -l command to list the running background jobs and show the process ID in addition to the job ID:

jobs -l

Get hands-on with 1200+ tech skills courses.