ps command Linux

Reading Time: 3 minutes

The ps command in Linux is used to display about running processes on the system. You can get information like process ID (PID) for the processes you or any other user is running on the same Linux system.

The x option (Note: no hyphen) will display all the processes even if they are not associated with current tty (terminal type) or if they don’t have a controlling terminal (like daemons).

ps x | head
  • PID is the unique process ID of the process
  • TTY is the type of terminal user is logged in to. pts means pseudo terminal
  • The STAT in the above output means Process State Codes. You can find a detailed table in the man page of the ps command.
  • TIME gives you for how long the process has been running
  • COMMAND is the command that you run to launch the process

With option u, you’ll have detailed information about each process:

ps ux | head

When you already have the PID but you don’t know which process it belongs to. You can use the ps command to find the process information from its PID in this way:

ps -pN

You can use more than one PIDs by separating them with comma:

ps -pN1,N2,N3

One of the essential use of the ps command is to get the process ID (PID) of a running program. Normally when you are looking to kill a misbehaving program, you search for all the occurrences of the program, get their PIDs and use the kill command to end the process.

ps -C program__name

You can also use grep command to get a similar result.

ps aux | grep program_name

You can display all processes running on the system using the -e operator. it is typically combined with f or F operator. -f option provides full-format listing. F option provides extra full format listing

$ ps -ef

PPID refers to parent process ID

You can later use this PID to kill this process using the kill command.

kill <process id>

To display all the processes by a user on the system, use the operator.

ps -u <UID>

Here is a listing of all options

Leave a comment