Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux ps Command: Display Running Processes

The ps (process status) command is a fundamental tool for managing and monitoring processes in Linux systems. This tutorial will introduce you to the ps command, its usage, and some practical examples.

  • Basic Usage

The basic syntax for the ps command is as follows:

ps [options]

Some common options for the ps command include:

  • a: List processes from all users
  • u: Display processes in a user-oriented format
  • x: Include processes without a controlling terminal
  • e: List all processes on the system

For example, to list all processes in a user-friendly format, use:

ps aux
  • Filtering Process List

You can filter the process list using various options with the ps command. Some common options are:

  • -C: Filter processes by command name
  • -U: Filter processes by user
  • -p: Filter processes by process ID (PID)
  • -t: Filter processes by terminal (TTY)

For example, to display all processes owned by the user john, use:

ps -U john -u john u
  • Displaying Custom Process Information

The ps command allows you to customize the displayed process information using the -o option, followed by a comma-separated list of field names.

For example, to display the PID, command name, and CPU usage of all processes, use:

ps -eo pid,comm,pcpu
  • Examples

Here are some practical examples of using the ps command:

  • List all processes in a user-oriented format:
ps aux
  • List all processes owned by the user john:
ps -U john -u john u
  • List all instances of a process named example_process:
ps -C example_process
  • Display the PID, command name, and CPU usage of all processes:
ps -eo pid,comm,pcpu
  • Piping Output to Other Commands

You can pipe the output of the ps command to other commands like grep to search for specific processes or process attributes.

For example, to find all processes with the word "python" in their command name, use:

ps aux | grep python

In conclusion, the ps command is a versatile tool for managing and monitoring processes in Linux systems. By understanding its various options and output formats, you can effectively monitor and troubleshoot processes on your system.

  1. How to use ps to display running processes: The ps command is used to display information about active processes. To view a list of running processes:

    ps
    
  2. Viewing active processes in Linux with ps: Use ps to view active processes. For example, to display detailed information about all processes:

    ps aux
    
  3. Listing processes in Unix-like systems using ps: List processes using ps. For example, to show process information for a specific user:

    ps -u username
    
  4. Advanced options for the ps command in Linux: ps has various options for displaying detailed process information. For instance, to show process tree and parent-child relationships:

    ps -e --forest
    
  5. Filtering and sorting processes with ps in Linux: Filter and sort processes using ps. For example, to show the top CPU-consuming processes:

    ps aux --sort=-%cpu | head
    
  6. ps vs top: comparing process monitoring tools in Linux: ps and top are both process monitoring tools. While ps provides a snapshot, top offers real-time updates. For example, to use top:

    top
    
  7. Customizing output format with ps in Linux: Customize ps output format using the o option. For instance, to display only the process ID and command name:

    ps -eo pid,cmd