in

UbuntuUbuntu

How to use PS Command in Linux Ubuntu 19.10/18.04 LTS?

A Linux command to view the Process Status!!

PS Command

PS Command in Linux: In Linux, a program that is currently running is called process. You may need to find out what processes are ongoing while working on a Linux system. Here is the PS Command to find information about the running processes. The ps command, a short form of “Process Status”, used to view the information related to the currently running processes. It displays the list of processes with their PIDs along with details depends on diverse options. This command provides several options for manipulating the output as per our needs. This article describes how to make use of the PS Command Linux and its options with relevant examples.

Index:

General Syntax of “ps” command:

The formal syntax for ps command is as follows:

$
ps [OPTIONS]

How to use PS Command?

Execute the below command in order to view list of processes for the current shell.

$
ps
PS Command
PS Command

The output contains four columns of information labeled PID, TTY, TIME and CMD.

PS Command Output Columns
PS Command Output Columns
  • PID: It is the process id that is considered to be important for a user. It allows you to kill any crash process.
  • TTY: It is the terminal type that the user logged into.
  • TIME: CPU utilization time in minutes and seconds for the running process. Sometimes TIME shows 00:00:00 and it indicates no CPU time has been given by the kernel.
  • CMD: The name of the command that was used to begin the process.
Check this too  How to use Halt Command in Linux Ubuntu 19.10/18.04 LTS?

Examples to use “ps” command:

Let’s look out some examples of using the ps command with the available options.

To view all processes:

You have to use either of the following options in order to view all processes running on your system.

$
ps -A

or

$
ps -e
PS Command - View all processes
PS Command – View all processes

To view running processes:

$
ps r
PS Command - Running processes
PS Command – Running processes

To Show true command name:

$
ps c
PS Command - Show true command name
PS Command – Show true command name

PS Command – Options:

  1. UNIX options – which may be organized and must be prefaced by a dash(“-“).
  2. BSD options – Must not be used with a dash.
  3. GNU options – Preceded by two dashes(“–“).
Basic options:
 -A, -e               all processes
 -a                   all with tty, except session leaders
  a                   all with tty, including other users
 -d                   all except session leaders
 -N, --deselect       negate selection
  r                   only running processes
  T                   all processes on this terminal
  x                   processes without controlling ttys
Selection by list:
 -C <command>         command name
 -G, --Group <GID>    real group id or name
 -g, --group <group>  session or effective group name
 -p, p, --pid <PID>   process id
        --ppid <PID>  parent process id
 -q, q, --quick-pid <PID>
                      process id (quick mode)
 -s, --sid <session>  session id
 -t, t, --tty <tty>   terminal
 -u, U, --user <UID>  effective user id or name
 -U, --User <UID>     real user id or name

  The selection options take as their argument either:
    a comma-separated list e.g. '-u root,nobody' or
    a blank-separated list e.g. '-p 123 4567'
Output formats:
 -F                   extra full
 -f                   full-format, including command lines
  f, --forest         ascii art process tree
 -H                   show process hierarchy
 -j                   jobs format
  j                   BSD job control format
 -l                   long format
  l                   BSD long format
 -M, Z                add security data (for SELinux)
 -O <format>          preloaded with default columns
  O <format>          as -O, with BSD personality
 -o, o, --format <format>
                      user-defined format
  s                   signal format
  u                   user-oriented format
  v                   virtual memory format
  X                   register format
 -y                   do not show flags, show rss vs. addr (used with -l)
     --context        display security context (for SELinux)
     --headers        repeat header lines, one per page
     --no-headers     do not print header at all
     --cols, --columns, --width <num>
                      set screen width
     --rows, --lines <num>
                      set screen height
Show threads:
  H                   as if they were processes
 -L                   possibly with LWP and NLWP columns
 -m, m                after processes
 -T                   possibly with SPID column
Miscellaneous options:
 -c                   show scheduling class with -l option
  c                   show true command name
  e                   show the environment after command
  k,    --sort        specify sort order as: [+|-]key[,[+|-]key[,...]]
  L                   show format specifiers
  n                   display numeric uid and wchan
  S,    --cumulative  include some dead child process data
 -y                   do not show flags, show rss (only with -l)
 -V, V, --version     display version information and exit
 -w, w                unlimited output width

        --help <simple|list|output|threads|misc|all>
                      display help and exit

Get help from ps command:

In order to get help from the ps command, you have to execute any one of the following commands on the Ubuntu Terminal.

$
ps --help <simple|list|output|threads|misc|all>

or

$
ps --help <s|l|o|t|m|a>

Check ps command version:

In order to check the ps command version, use any one of the below commands.

$
ps --version

or

$
ps -V

or

$
ps V

A Short Summary:

We hope that this article about the usage of PS Command Linux Ubuntu 19.10 Eoan Ermine/ 18.04 LTS Bionic Beaver helped you clearly. Besides, we have listed all available options associated with the command so it will assist you with no doubts. We will be happy and motivated if you share your valuable feedback about this article.

Check this too  DF Command in Linux: DF Command to Check Disk Space in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

Lisa

Written by Lisa

Lisa is a technical writer who assists readers with quality content as part of a Tec Robust team. Her writing helps people from diverse professional backgrounds. Her article makes you gain clarity on technical topics as she knows what is right for you.

VirtualBox Fedora

How to Install VirtualBox on Fedora 31?

Focal Fossa Desktop Preview

“Focal Fossa Wallpaper Shoots Laser From it’s Eyes” Said by Martin Wimpress