PS command not found in Linux or Docker container: Install and how to use

PS is a popular command tool, stands for “process status” comes pre-installed in the Linux systems to provide a snapshot of the running processes. However, if the user wants a real-time or constant update of the process list is desired, then the top tool should be used. Also, with pgrep , processes can be specifically searched for by name or a regular expression and with pstree you can display all running processes in tree form.

This process viewing command tool “ps” also offers various options in Linux to get the desired information of running processes. However, sometimes, in minimal Linux systems such as CentOS, Alamlinux, Ubuntu, or Docker running Linux containers you would not find the PS command by default. So, if you required, it can be installed using the based repository of your system, here we let you know how? Also, we will discuss some common PS command options that to get key information on what is going on inside the system.

Install ps command tool on Docker container, CentOS, or other Linux

If you are using the Debian or Ubuntu-based systems, then run the given commands to get the “ps” command-line tool.

sudo apt-get update
sudo  apt-get install procps

 

Whereas, RHEL (Redhat) based systems such as CentOS, AlmaLinux, Rocky Linux, Oracle Linux, and others can use these:

sudo yum update
sudo yum install procps

 

Command ps command options to use

1. Start with –help

Well, if you are already an experienced user of Linux, then you just need a glimpse of options to use with “ps” using --help option.

ps --help

To dig further use the given options with –help to know more.

get help with ps linux command

 

2. To List all current shell Linux processes

Those who just want to see the current shell process on Linux can simply use the ps without any additional option.

List current shell process linux

 

3. List all your Linux process using the “ps” command

When it comes to getting a list of all the running processes of your Linux system then ps command alone will not work. We have to declare an additional parameter with it and that is -A

ps -A

Alternatively, you can use -e flag as well.

ps -e

Other ways to get the Complete process list


The same using BSD syntax:

ps ax

If you want to receive more information, you can do that with

ps -eF

or.

ps aux

command to list all Linux process

 

4. Display all Linux process with TTY, except session leaders

Option -a selects all processes except the session leaders and processes that are not connected to a terminal. Whereas, if you use it without hyphen (-) then it displays all the processes with TTY, including other users.

Display all Linux process with tty

 

5.  PS command to show all processes in the current terminal

We can use the ‘T‘ option to select all processes connected to the current terminal with the help of the PS command. It is identical to the t option without any argument.

Show all processes connected to the current terminal

 

6. Restricts the selection to running processes

To list the running process use -r

ps -r

 

7.  Filter process list

Often, we are required to filter out processes we don’t need to find what actually useful. For example, if you want to list all processes related to the “terminal” then use the given syntax.

ps aux | grep process-name

For example:

ps aux | grep terminal

List Filter process command PS

 

8. Get-Process list in tree format

To display a process tree for understanding each one in a better way, we can use the following options with ps command.

ps -ejH

(or with BSD syntax):

ps axjf

The output is graphically nicer if pstree is used.

9. Show process related to a USER

To list the process associated with a particular user on your system, use:

ps -u username

Example:

ps -u h2s

Show process related to a USER

 

10. List all Processes for a Group

We already learned how to show all processes associated with some particular user. Now, let’s see how to see all the processes assigned under some system or user Group.

ps -fG group-name

Let’s you want o display process running for root group

ps -fG root

These are some arguments to use with PS command, to get more information see its man page.

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.