How to Use the Ps Command

The ps command is used to display information about active processes running on a system. It provides various options to customize the output and filter the information based on specific criteria. Here are some common examples of how to use the ps command:

  1. Display a list of all processes running in the current terminal session:
ps

This command will show a list of processes associated with the current terminal session.

  1. Display a list of all processes running on the system:
ps -e

The -e option is used to display information about all processes running on the system, regardless of the terminal session.

  1. Display detailed information about processes, including the process ID (PID), terminal, CPU usage, and more:
ps aux

The aux options are commonly used together to display detailed information about all processes running on the system.

  1. Display a process tree, showing the parent-child relationship between processes:
ps -ef --forest

The -f option displays a full-format listing, and --forest displays the process tree structure.

  1. Display processes owned by a specific user:
ps -u {{username}}

Replace {{username}} with the desired username. This command will show processes owned by the specified user.

  1. Display processes associated with a specific process ID (PID):
ps -p {{pid}}

Replace {{pid}} with the desired process ID. This command will show information about the process with the specified PID.

These are just a few examples of how you can use the ps command. There are many more options available to customize the output and filter the information based on your specific requirements. You can refer to the ps manual page by running man ps in the Terminal for more detailed information about the command and its options.

你可能感兴趣的:(linux)