Skip to main content

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

OptionDescription
-aShow command line arguments.
-cDisable compact display.
-h or --highlight-allHighlight the current process and all its ancestors.
-nSort the processes with the same parent by PID instead of by name.
-pShow PIDs; PIDs are shown as decimal numbers in parentheses after each process name.
-uShow the owner of each process.
-gShow process group IDs.
-lShow long lines.
-sShow 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

OptionDescription
-aDisplays active and inactive memory.
-fDisplays the number of forks since boot.
-mDisplays slabinfo.
-nCauses the headers not to be reprinted regularly.
-sDisplays a table of event counters and memory statistics.
-dReports disk statistics.
-pReports disk partition statistics.
-SSpecifies 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

OptionDescription
-scaleChanges the scale of the graph.
-updateSpecifies the interval between updates, in seconds.
-hlSpecifies the color for the graph.
-highlightSpecifies 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

OptionDescription
-dChanges the delay between graph updates.
-sChanges the scale of the graph.
-vPrints version information and exits.

Example Syntax:

tload [options] [terminal]
tload

Comparison Table

CommandDescriptionGraphical OutputHighlights
pstreeDisplays a tree of processesNoHierarchical view of processes and their relationships
vmstatReports information about processes, memory, paging, block I/O, traps, and cpu activityNoReal-time system summary, Performance and resource usage insights
xloadProvides a graphical representation of system load averageYesVisual representation of system load in a graphical environment
tloadVisual representation of system load average in the terminalYes (Text-based)Text-based graphical representation of system load for terminal environments

Differences and Usage

  • pstree is especially useful for visualizing the parent-child relationship between processes. It helps in quickly identifying which processes are spawned by others.

  • vmstat is versatile and provides a comprehensive view of system performance, including CPU, memory, and I/O, making it invaluable for system diagnosis and performance tuning.

  • xload and tload are more focused on representing the system load graphically, with xload being suitable for graphical desktop environments and tload for 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.

YouTube @cloudaffle