Skip to content

Using the ps Command in the ChromeOS Linux Environment

The ps command in Linux is used to display information about currently running processes. It provides details such as process IDs (PIDs), CPU and memory usage, and command execution details. This guide covers how to effectively use ps in the ChromeOS Linux (Crostini) environment.

Basic Usage

Listing Processes for the Current User

To display processes for the current user:

ps

This shows a simple list of running processes started by the user in the current shell.

Displaying All Running Processes

To see all processes running on the system:

ps aux

Explanation of columns: - USER – User who owns the process - PID – Process ID - %CPU – CPU usage percentage - %MEM – Memory usage percentage - VSZ – Virtual memory size - RSS – Resident memory size - TTY – Terminal associated with the process - STAT – Process state - START – Time when the process started - TIME – Total CPU time used - COMMAND – Command that launched the process

Filtering Processes by Name

To find a specific process by name:

ps aux | grep process_name

For example, to find all running Chrome processes:

ps aux | grep chrome

Displaying a Process Tree

To view running processes in a tree format:

ps axjf

Displaying Processes for a Specific User

To list all processes owned by a specific user:

ps -u username

Displaying Process IDs Only

To get a list of PIDs for a specific process:

ps -C process_name -o pid=

For example, to get the PID of bash:

ps -C bash -o pid=

Practical Use Cases

  • Checking system resource usage:
    ps aux --sort=-%cpu | head
    
  • Finding and terminating a process:
    kill $(ps -C process_name -o pid=)
    
  • Monitoring processes in real time:
    watch "ps aux --sort=-%mem | head"
    

Conclusion

The ps command is an essential tool for monitoring system processes in the ChromeOS Linux environment. Whether checking running processes, filtering specific ones, or managing system resources, ps provides valuable insights into system activity.