• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

Ps Command in Linux (List Processes)

Written by Admin, Updated On June 22, 2020
ps, terminal
Ps Command in Linux (List Processes)

A process is an executing instance of a program. Process is one of the important concept of the Linux OS. Linux provides ps utiliy to view information about running processes. In this article, we will show you how to use the ps command to list the currently running processes and their PIDs along with other information.

How to Use ps Command#

The basic syntax for the ps command is as follows:

ps [OPTIONS]

ps provides numerous options for manipulating the output according to our need.

  • UNIX style options, preceded by a single dash.
  • BSD style options, used without a dash.
  • GNU long options, preceded by two dashes.

You can use different options types simultaneously, but in some specific situation conflicts can appear.

If using ps command without any options it will show four columns by default. It will show minimum two processes running in the current shell.

ps
 PID TTY          TIME CMD
4402 pts/0    00:00:00 bash
4412 pts/0    00:00:00 ps

The above output shows information about shell (bash) and and the processes that run in the shell (ps).

You can see there are four columns PID, TTY, TIME and CMD.

  • PID – Its ID of the process. Generally, user use ps command to know the PID, by knowing the PID you can kill a malfunctioning process.
  • TTY – The name of the controlling terminal for the process.
  • TIME – It will show the cumulative CPU time of the process, shown in minutes and seconds.
  • CMD – Name of the command that was used to start the process.

The ps command accepts many more options that can be used to display a specific group of processes and different information about the process. ps is most frequently used with the following combination of options:

BSD form:#

ps aux

Here, combination of three options:

  • The a option is used to display the processes of all users. It will also ignores the processes which are associated with a terminal.
  • u stands for a user-oriented format that provides detailed information about the processes.
  • Option x tells ps to list the processes without a controlling terminal. Those are mainly processes that are started on boot time and running in the background.

The above command will show the output in eleven columns as given below:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.4 159668  8932 ?        Ss   Jun19   0:03 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Jun19   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        I    Jun19   0:00 [kworker/0:0]
...

Below is an explanation of labels, we already shown PID, TTY, TIME and CMD labels before:

  • USER – Name of the user who runs the process.
  • %CPU – The cpu utilization of the process.
  • %MEM – The percentage of the process’s resident set size to the physical memory on the machine.
  • VSZ – Virtual memory size of the process in KiB.
  • RSS – Size of the physical memory that the process is using.
  • STAT – It’s showing process state code, such as Z (zombie), S (sleeping), and R (running).
  • START – Showing the time when the command started.

You can use the -f option to show a tree view of parent to child processes:

ps auxf

UNIX form:#

ps -ef
  • Option -e tells ps to display all processes.
  • The -f stands full-format listing, which provides detailed information about the processes.

The command will show output in eight columns named UID, PID, PPID, C, STIME, TIME, and CMD:

UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Jun19 ?        00:00:03 /sbin/init
root         2     0  0 Jun19 ?        00:00:00 [kthreadd]

Following is the explanation of remaining labels:

  • UID – It is same as USER, the user who runs the process.
  • PPID – The ID of the parent process.
  • C – Same as %CPU, the process CPU utilization.
  • STIME – Same as START, the time when the command started.

To show the processes running of a specific user, you would type:

ps -f -U tecnstuff -u tecnstuff

Here, tecnstuff is the user name.

Specific Format#

You can use o option with ps command to show columns which you want to display.

For example, to display only PID, PPID and COMMAND, you should run one of below command:

ps -efo pid,ppid,comm
ps auxo pid,ppid,comm

Conclusion#

The ps command is one of the most frequently used commands when fixing issues on Linux machines. There many options you can use with ps command.

To know more about ps, type man ps in your terminal.

If you have any questions or suggestion, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article Find Large Files in Linux
Next Article   How to Install Mono on Debian 10 Buster

Related Posts

  • How to Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on Debian 10
    How to Install Python 3.9 on Debian 10 December 25, 2020
  • How to Install Python 3.9 on Ubuntu 20.04
    How to Install Python 3.9 on Ubuntu 20.04 December 21, 2020
  • How to Install GIMP on Ubuntu 20.04
    How to Install GIMP 2.10 on Ubuntu 20.04 December 22, 2020
  • How to Install Notepad++ on Debian 10
    How to Install Notepad++ on Debian 10 December 23, 2020
  • How to Install Php 8 on Debian 10
    How to Install PHP 8 on Debian 10 January 2, 2021
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook