Skip to main content
2 ● Beginner 15m

Process Management

Learn to view, manage, and control processes running on a Linux system.

Learning Objectives

  • View running processes with ps and top
  • Understand process states and priorities
  • Send signals to processes
  • Run processes in the background
  • Use job control commands

Introduction

In Linux, a process is a running instance of a program. Understanding how to view and manage processes is essential for system administration and troubleshooting.

Viewing Processes

ps - Process Status

$ ps                 # Show processes in current terminal
$ ps aux             # Show all processes (BSD style)
$ ps -ef             # Show all processes (System V style)
$ ps aux | grep nginx  # Filter for specific process

Common columns:

  • PID - Process ID (unique identifier)
  • USER - Process owner
  • %CPU - CPU usage percentage
  • %MEM - Memory usage percentage
  • STAT - Process state
  • COMMAND - Command that started the process

top / htop - Interactive Process Viewer

$ top                # Real-time process viewer
$ htop               # Enhanced version (if installed)

Press q to exit, k to kill a process, h for help.

pgrep - Find Process by Name

$ pgrep nginx        # Get PID of nginx process
$ pgrep -l nginx     # Include process name

Process States

StateCodeDescription
RunningRCurrently executing or ready to run
SleepingSWaiting for an event
StoppedTStopped (e.g., Ctrl+Z)
ZombieZTerminated but not cleaned up

Signals

Signals are used to communicate with processes:

$ kill PID           # Send SIGTERM (graceful shutdown)
$ kill -9 PID        # Send SIGKILL (force kill)
$ kill -STOP PID     # Pause process
$ kill -CONT PID     # Resume process
$ killall nginx      # Kill all processes by name

Background & Foreground

Running in Background

$ sleep 100 &        # Start in background
$ jobs               # List background jobs
$ fg %1              # Bring job 1 to foreground
$ bg %1              # Resume job 1 in background

Ctrl+Z and Ctrl+C

  • Ctrl+C - Terminate foreground process (SIGINT)
  • Ctrl+Z - Suspend foreground process (SIGTSTP)

Your Task

  1. Start a long-running process in the background
  2. Verify it’s running with ps
  3. Check its job number with jobs

Run this command to start the background process:

sleep 300 &

Then verify it’s running.

Launch Your Sandbox

Copy the command below to start this exercise:

Launch Your Sandbox

Copy the command below to start this exercise in your terminal:

$infra-learn launch linux-02

Verification Criteria

The verification script will check the following when you run infra-learn verify:

  • 1 Background process running with name "sleep"
  • 2 Process has been started by the learner user
  • 3 Process is running in the background (not foreground)
Need a hint? (3 available)
Hint 1

Use & at the end of a command to run it in the background

Hint 2

Use jobs to see background jobs

Hint 3

Use ps aux to see all processes