Viewing Running Processes in Linux
In Linux, monitoring running processes is crucial for system administration and
troubleshooting. Besides the commonly used ps, top, and htop commands,
Linux offers several other utilities like pstree, vmstat, xload,
and tload for viewing running processes and system status. Each tool provides
different perspectives and information about the processes and system's state.
1. pstree
pstree displays the system’s running processes as a tree. It provides a clear
hierarchical view of processes and their child processes.
Options for pstree Command
| Option | Description |
|---|---|
-a | Show command line arguments. |
-c | Disable compact display. |
-h or --highlight-all | Highlight the current process and all its ancestors. |
-n | Sort the processes with the same parent by PID instead of by name. |
-p | Show PIDs; PIDs are shown as decimal numbers in parentheses after each process name. |
-u | Show the owner of each process. |
-g | Show process group IDs. |
-l | Show long lines. |
-s | Show parent processes of the specified process. |
Example Syntax:
pstree [options] [pid or username]
pstree
2. vmstat
vmstat reports information about processes, memory, paging, block I/O, traps,
and CPU activity. It presents a summary of the valuable information that allows
the user to understand the performance and resource usage of the system.
Options for vmstat Command
| Option | Description |
|---|---|
-a | Displays active and inactive memory. |
-f | Displays the number of forks since boot. |
-m | Displays slabinfo. |
-n | Causes the headers not to be reprinted regularly. |
-s | Displays a table of event counters and memory statistics. |
-d | Reports disk statistics. |
-p | Reports disk partition statistics. |
-S | Specifies the display unit (k:1000, K:1024, m:1000000, M:1048576). |
Example Syntax:
vmstat [options] [delay [count]]
vmstat 1 10 # It will display system information every 1 second, 10 times.
3. xload
xload provides a graphical representation of the system load average, allowing
users to visualize the load on the system graphically.
Options for xload Command
| Option | Description |
|---|---|
-scale | Changes the scale of the graph. |
-update | Specifies the interval between updates, in seconds. |
-hl | Specifies the color for the graph. |
-highlight | Specifies the color for the graph. |
Example Syntax:
xload [options]
xload -upadte 1 -scale 7
4. tload
tload presents a graphical representation of the system load average in the
terminal, providing a visual understanding of how busy the system is.
Options for tload Command
| Option | Description |
|---|---|
-d | Changes the delay between graph updates. |
-s | Changes the scale of the graph. |
-v | Prints version information and exits. |
Example Syntax:
tload [options] [terminal]
tload
Comparison Table
| Command | Description | Graphical Output | Highlights |
|---|---|---|---|
| pstree | Displays a tree of processes | No | Hierarchical view of processes and their relationships |
| vmstat | Reports information about processes, memory, paging, block I/O, traps, and cpu activity | No | Real-time system summary, Performance and resource usage insights |
| xload | Provides a graphical representation of system load average | Yes | Visual representation of system load in a graphical environment |
| tload | Visual representation of system load average in the terminal | Yes (Text-based) | Text-based graphical representation of system load for terminal environments |
Differences and Usage
pstreeis especially useful for visualizing the parent-child relationship between processes. It helps in quickly identifying which processes are spawned by others.vmstatis versatile and provides a comprehensive view of system performance, including CPU, memory, and I/O, making it invaluable for system diagnosis and performance tuning.xloadandtloadare more focused on representing the system load graphically, withxloadbeing suitable for graphical desktop environments andtloadfor terminal or command-line environments.
Conclusion
Understanding and using the appropriate commands to view and analyze running
processes and system load is crucial for effective system administration and
troubleshooting in Linux. pstree, vmstat, xload, and tload each offer
unique perspectives and are suitable for different scenarios and user
preferences. By utilizing these tools efficiently, one can ensure optimal system
performance and swiftly identify and resolve any issues that arise.
What Can You Do Next 🙏😊
If you liked the article, consider subscribing to Cloudaffle, my YouTube Channel, where I keep posting in-depth tutorials and all edutainment stuff for software developers.