How to use PS command

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

Using a system without monitoring what’s happening in the background is not a good thing to do -especially in Linux- because as a result, you may be consuming resources in the wrong side of the city, or your system may be not properly utilized in the manner way.

There are some systems depend almost exclusively on the GUI screens to monitor the system, and some people may prefer this method, but we will talk about one of the traditional, essential and effective ways to monitor our Linux system which is the PS command

PS command

Process Status or PS as its name says displays the status and information of the variant processes.

It is designed mainly for non-interactive use (scripts, extracting info, shell pipelines etc…) unlike TOP command which is for interactive use, but may be we will talk about it later in a separate article.

Simple PS command

As you can see, nothing much to watch in the simple way, and that’s why this command only displays the processes running in the current shell.

But we go further with a lot of different options of the command (as much as possible), let’s define some terms related to this command:

PID: this is the unique ID of any process

TTY: type of terminal where user logged in

TIME: how long CPU is running in minutes and seconds

CMD: what command lunched the process

PPID: the parent ID of the processes

Now with some options

To view all processes use either -A or -e

View all running processes

To view the processes owned by the runner of the command

ps -x

To view by selection

PS is powerful tool in selection, you can filter the results based on variant attributes

1. by command name


here we can see the results of all processes with the selected command name (CMD)

2. by group id and group name

3. by process ID (PID)

you can have the same results by running –pid or p

you can select multiple PIDs

4. by parent ID (PPID)

5. by TTY

Format your output

You can choose how your results display on the screen which gives the command more flexibility

To view the full format

Full format with more information

Use -ef to see all process with full format

The last option as if you use the aux option, this gives you a full picture of your running processes

User defined format

You can even see the tree of your processes which displays which process launched which process

To do that use the PSTREE command

Now to see a specific process tree use the following command

ps –forest -C command_name 

Also we can use -ef option here to get a full view of all processes tree

Conclusion

Monitoring your system is one of the critical and essential things to do as an administrator to keep your system in a good shape by utilizing your resources and for tuning your system performance.

PS is a powerful tool to monitor your system and see information about the processes the are running whether you are aware of or lying there in the background.

There is no article would be able to cover all options of any command so for more information and more options please see the man page of the command.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook