Javatpoint Logo
Javatpoint Logo

ps Command in Linux/Unix with Examples

The ps command is used to view currently running processes on the system. It helps us to determine which process is doing what in our system, how much memory it is using, how much CPU space it occupies, user ID, command name, etc .

The ps command may display different results for different systems because it displays information about the currently running process of a system.

Syntax:

Ps1

Look at the above snapshot, 4 columns are displayed as the output.

  • PID is the process ID of running command
  • TTY is the type of terminal where current command is running
  • TIME tells how much time is used by CPU to run the process
  • CMD is current command

ps command supports 3 types of usage syntax style

  • Unix, may be grouped and preceded by hyphen
  • BSD, may be grouped but not preceded by hyphen
  • GNU, long options and preceded by double hyphens

Options

Option Function
ps -ef / -aux List currently running process in full format
ps -ax List currently running process
ps -u <username> List process for specific user
ps -C <command> List process for given command
ps -p <PID> List process with given PID
ps -ppid <PPID> List process with given ppid
pstree Show process in hierarchy
ps -L List all threads for a particular process
ps --sort pmem Find memory leak
ps -eo Show security information
ps -U root -u root u Show process running by root

Linux ps -ef and ps -aux

To display all currently running processes in full format on a system two types of commands are used.

Syntax:

Here,

e displays all the processes

f displays full format listing

Syntax:

fullformat1

Look at the above snapshot, it display all the running processes on our system.

Syntax:

fullformat2

Look at the above snapshot, this command filter the result by CPU or memory usage. It helps you in determining how much memory is used or how much CPU space is used by a process.

Linux ps -ax

This command display all the processes in a system. Here, a stands for all. It will display a long list of result.

Syntax:

psax1

Look at the above snapshot, it does not display information in full format but shows a list of all the processes running in the system.

Linux ps -u <username>

Option u displays the process for a specific user. You can also specify multiple usernames separated by a comma between them.

Syntax:

Example:

ps -f -u akki,sssit

psu1

Look at the above snapshot, it display the processes of akki and sssit with "ps -f -u akki,sssit" command.

Linux ps -C <command>

Option C display a list of processes with the mentioned command as argument.

Syntax:

Example:

pxC1

Look at the above snapshot, it displays all the processes which has firefox in its command execution.

Linux ps -f -p <PID>

Each process is assigned with a specific Process ID number.

A process may have many sub process listed under it. Each of these sub process will also have its own PID number. So, a process will have its own PID number and may have a parent PID number.

Option p display list of the processes having the mentioned PID number.

Syntax:

Syntax:

psp1

Look at the above snapshot, it displays the processes with the mentioned PID numbers.

Linux ps -f --ppid <PPID>

As mentioned earlier, some process may have PPID along with PID number. All the sub processes having same PPID number may be listed by mentioning PPID number.

Syntax:

Example:

ps -f --ppid 1517

Psppid1

Look at the above snapshot, all the sub processes of PPID 1517 are listed here.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA