Viewing running processes is a fundamental Linux task essential for monitoring system resource usage, diagnosing performance issues, and managing active applications.
Linux provides several commands and tools that allow users and administrators to inspect all processes currently executing on the system, including detailed information on CPU and memory usage, process IDs, parent-child relationships, and command invocation.
Using the ps Command to List Processes
The ps (process status) command displays snapshots of currently running processes. It provides detailed information such as process IDs (PID), associated users, start times, memory and CPU utilization, and the command invoked.
Common usage:
ps auxa: Shows processes for all users.
u: Displays user-oriented format including user and memory usage.
x: Lists processes not attached to a terminal.
Example output snippet:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 168656 4780 ? Ss Oct11 0:21 /sbin/init
user 2345 2.1 1.0 230000 21000 pts/0 R+ 10:00 0:05 topUsing top for Real-Time Process Monitoring
Linux provides top as an interactive utility for monitoring system activity. Following are the key aspects of using top effectively.
1. top provides a dynamically updating list of running processes ordered by CPU usage by default.
2. Displays system-wide resource consumption: CPU, memory, swap, load averages.
3. Users can interact with top to sort by memory, kill processes, or renice them.
4. Start it by typing:
top5. Press q to quit top.
Enhanced Process Viewer with htop
Linux users rely on htop for detailed and color-coded process information. Following are the core capabilities of the htop tool.
1. htop is an improved, interactive text-mode process viewer with color-coded output.
2. Features scrollable process list, tree view, detailed CPU/memory graphs.
3. Allows killing and renicing processes via function keys.
4. Install with:
sudo apt install htop # Debian/Ubuntu
sudo dnf install htop # Fedora5. Run with:
htopOther Useful Commands to View Processes
pgrep firefox
pidof sshdps -ejH
ps axjf
pstreeps -u username