Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Ps Command in Linux (List Processes) - DesignLinux

Jun 22 2020
designlinux 0 Comments
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.

Related

Tags: ps, terminal

Parsing JSON Data in Python

Prev Post

How to Install Mono on Debian 10 Buster

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 65
  • 605,815

DesignLinux.com © All rights reserved

Go to mobile version