Every program you open creates a task. Your computer handles many tasks at once. Knowing how to check and monitor these tasks helps you troubleshoot performance issues. This guide shows you simple methods to see what runs on your system. You’ll learn commands like ps, top, and htop. These tools reveal active programs and their resource consumption. Managing tasks effectively prevents slowdowns and identifies problematic applications. Understanding task management empowers you to maintain system health and optimize performance.
What Is a Process in Linux
A task starts when you launch any program or run a command. Each task gets a unique identifier called PID (Process ID). Multiple programs run simultaneously on modern systems thanks to multitasking support.
The task ends when you close the program or it completes execution. Some tasks run in the foreground, requiring your direct interaction. Others run in the background, operating silently without user input.
Child tasks get created by parent tasks. The operating system tracks these relationships. When you need to kill a PID, understanding parent-child relationships prevents accidental termination of critical system components.
How to List Processes Using ps Command
The ps command displays currently running tasks. It creates a snapshot of active programs at the moment you run it. The output appears as a static list, not a live feed.
Basic ps Command
Open your terminal and type:
ps
This shows tasks for your current terminal session. You get four columns:
| Column | Description |
|---|---|
| PID | Unique task identifier |
| TTY | Terminal type connected |
| TIME | Total CPU usage duration |
| CMD | Program name that started the task |
Display All System Processes
To see every task across your entire machine, use:
ps -A
or
ps -e
Both commands produce identical results, showing all tasks regardless of terminal ownership.
Detailed Process Information
For comprehensive details including usernames and background tasks, run:
ps aux
This reveals eleven columns of data about every running program. Key columns include USER (account running the task), %CPU (processor usage percentage), %MEM (memory consumption percentage), and STAT (current state symbol).
The ps command documentation explains every available option in detail.
Filter by Program Name
Find tasks by program name using:
ps -C program_name
Example:
ps -C firefox
View Tasks by Username
Display tasks owned by a particular user:
ps -u username
How to List Processes Using top Command
The top utility provides live updates. It refreshes automatically every few seconds. Type this in your terminal:
top
You see a dynamic display showing CPU and memory consumption. The list automatically sorts by CPU usage, placing resource-heavy programs at the top. Press q to exit.
This real-time monitoring helps identify programs consuming excessive resources. The top command reference contains shortcuts for customizing the display.
Key top Command Columns
The output contains several important columns:
| Column | Meaning |
|---|---|
| PID | Process identification number |
| USER | Account running the task |
| PR | Scheduling priority |
| NI | Nice value (lower means higher priority) |
| VIRT | Virtual memory used |
| RES | Physical memory used |
| S | Process state (R=running, S=sleeping) |
| %CPU | Processor usage percentage |
| %MEM | Memory usage percentage |
| COMMAND | Program name |
How to List Processes Using htop Command
The htop utility offers a colorful, scrollable interface. It provides visual bars showing resource usage. Most distributions don’t include htop by default, so you need to install it first.
Install htop
Debian/Ubuntu:
sudo apt install htop
Red Hat/CentOS:
sudo dnf install htop
Launch htop
Type in your terminal:
htop
This tool makes monitoring easier with mouse support and interactive features. You can scroll vertically and horizontally to view all tasks. The htop documentation lists all keyboard shortcuts.
htop Features
Unlike top, htop lets you select and terminate tasks without typing PIDs manually. Press F9 to kill a selected task. Press F3 to search for specific programs. Press F6 to sort by different columns.
Finding Process IDs with pgrep
The pgrep utility searches for PIDs by name. It returns only the identifier number:
pgrep browser_name
This proves useful when you need the PID for termination commands. Combine it with other commands for powerful filtering.
Using pidof
Another option for finding PIDs by program name:
pidof program_name
Example:
pidof firefox
Terminating Running Processes
Stop any task using these methods. Always try graceful termination first to prevent data loss.
Terminate by PID
Use the kill command:
kill PID_number
For forceful termination when programs refuse to close:
kill -9 PID_number
Terminate by Program Name
Use pkill to stop tasks by name:
pkill program_name
For forceful termination:
pkill -9 program_name
When dealing with port conflicts, you might need to kill a process on a specific port.
Managing Long Output Lists
Task lists can be lengthy. Pipe through less for pagination:
ps aux | less
Filter specific programs using grep:
ps aux | grep chrome
Quick Reference Table
| Command | Purpose |
|---|---|
| ps | Show current terminal tasks |
| ps aux | Display all tasks with details |
| ps -C name | Filter by program name |
| ps -u user | Show tasks by username |
| top | Live monitoring view |
| htop | Interactive colorful monitor |
| pgrep | Find PID by name |
| pidof | Get PID for program |
| kill | Terminate by PID |
| pkill | Terminate by name |
FAQs
How do I see all running tasks on my Linux system?
Run ps aux in your terminal. This displays every task with detailed information including CPU usage, memory consumption, and program names. For live monitoring, use top or htop commands instead.
What is the difference between ps and top commands?
The ps command creates a static snapshot of tasks at one moment. The top command provides continuous real-time updates that refresh automatically every few seconds, showing current resource usage.
How can I stop a frozen program on Linux?
First find the program’s PID using ps aux or pgrep. Then run kill PID_number for graceful termination. If the program still refuses to close, use kill -9 PID_number for forceful termination.
Why should I use htop instead of top?
The htop command offers mouse support, colorful visual bars, and horizontal scrolling. You can select and terminate tasks without typing PIDs manually. It provides a more user-friendly interface than top.
How do I find tasks consuming the most CPU resources?
Run top or htop. Both commands automatically sort tasks by CPU usage, placing the most resource-intensive programs at the top of the list. Press Shift+M in top to sort by memory usage instead.