PS utility in Linux to display processes on the screen

with pre-installed OS of the Linux family come without a graphical interface. For operation and configuration use the terminal. Let’s talk about one of the utilities that is responsible for viewing processes. Let’s take Server 18.04 as an example.

What is PS

The PS system utility is responsible for displaying processes on the user’s screen. Together with , the more, less and grep commands are used for filtering.

PS is available in any Linux server OS distribution. Launched via the PS command:

Screenshot #1. PS utility.

Where the first column is the process ID (PID), the second is its name. The third shows the CPU time spent by the service, and the fourth shows the application that started it.

PS Syntax

The command works with the following additional keys.

Key -e (-A). Displays a list of all processes that are running on the server.
ps –e

The -d option will show the system administrator all processes, except for the so-called “leaders”. Leadership is when one process starts others. When starting a process with this key, the user will not see the first service, but he will be shown dependent on it.
ps –d

The –N switch changes the option values ​​exactly the opposite. Let’s take the previous point as an example. If you need to see only the leaders, then after the D key, enter N.
ps –d –N 

To display services that are running in the current terminal session, use the letter T, and to view only those that are currently running, use r.

Sorting

Consider the possibilities of the PS utility as a filter. If you want to display information about a specific service, then specify its identifier (PID).
ps 1721

Important! If you want to show several processes, then specify the PID of each separated by a comma.

Administrators do not remember the IDs of each process, but they do remember the names. Accordingly, to search for a specific service, we specify the name through a special key.
ps –C

Another way to sort is to use the group name. To do this, use the -G or -Group key.
ps --Group users 

Alternative: Combine search by group ID. The -g or -group option is responsible for this.

Important! The -G and -g switches differ only in their spelling: uppercase and lowercase, but they perform different functions.

To view a list of processes that a particular user has started, use the -U function.
ps –U name_user

, where user_name is the username for which the selection is made.

Important! If you want to display the processes that the user launched, then we take his name in straight quotes.

Additional features

As shown above, PS displays summary information about processes by default. To get such a description, use the -eF switch.
ps –eF

Information will be added about the size that the service takes from RAM, the time interval of work, the ID of the account under which the process is running, and other data.

To finalize the information, the –sort key is used along with additional options that sort by values, , %mem, cp, comm, etc.
ps –eF --sort

, where option is one of the many keys.

Detailed information is available in the help desk of the PS team.

The keys less and more control the size of the page in the terminal, i.e. allows you to look under one page for each keystroke.

The grep command selects data that contains a specific word, for example:
Ps –eF | grep

After running the command, the terminal window will display information about all lines containing the word nginx.

 

Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!