ps command switches, usages and examples in Unix/Linux

Commonly using “ps command” switches with example – Unix/Linux

This will be a very useful discussions if you are managing Linux servers with many processes. A lot of switches are available with the command “ps” to trace out processes with their metadata. We can list or find-out a lot of information regarding the processes running under our server by simply using the command ps and its proper switches.

The knowledge of using the command “ps” will helpful, if your server is facing a high load issue. That means, you can find-out the process information simply from “ps” without running “TOP” in high load situation.

We can simply sort out the process with its resource usages like memory, CPU etc with ps command along with different switches. The PS command under Unix/Linux displays the screen shots of current process. This is actually the static out put of the top command.

Some useful ps commands switch combinations and examples are explained below,

1. ps aux & ps ax

These commands will print all process running on the system(server). aux displays more details like user, cpu, memory etc. with respect to ax. The output difference are shown below,



2. Print processes like a tree format

# ps -ejH
# ps axjf
# pstree




3. Print security information

# ps -eo {euser, ruser, suser, fuser, comm, label}
# ps axZ
# ps -eM

This switch combination displays fue features like terminal, process ID, commands, time etc.. which are related to security.



4. Find out the top 10 memory consuming process on system(server)

 # ps -auxf | sort -nr -k 4 | head -10



5. Find out top 10 CPU consuming process

 # ps -auxf | sort -nr -k 3 | head -10



6. Find out every process running under a user.

# ps -U user-name -u user-name u



7. Display only the process ID of a particular process under the system(server)

# ps -C PROCESS -o pid= 
# pgrep PROCESS 
# pgrep -u user-name PROCESS (running under the user)
Here i am choosing one of the process Firefox that running under the system. So the syntax to find out the PID of that processes are,
# ps -C Firefox -o pid= OR pgrep Firefox OR pgrep -u arun Firefox


8. PS command to displays the process name having a particular PID

#  ps -p PID -o comm=



::Additional informations::

# ps -Al : Show Long Format Output.
# ps -AlF : To turn on extra full mode (it will show command line arguments passed to process).
# ps -AlFH : To See Threads ( LWP and NLWP).
# ps -AlLm : To See Threads After Processes.
# ps -e
# ps -ef
# ps -eF
# ps -ely
# -e Select all processes. Identical to -A.
# -f does full-format listing. This option can be combined with many other UNIX-style options to add additional columns. It also causes the command arguments to be printed. When used with -L, the NLWP (number of threads) and LWP (thread ID) columns will be added. See the c option, the format keyword args, and the format keyword comm.
# -F extra full format. See the -f option, which -F implies.
# -l long format. The -y option is often useful with this.
# -y Do not show flags; show rss in place of addr. This option can only be used with -l.

::Field description::

 UID the user who owns the process
 PID the process id, a unique identifier assigned to each process
 PPID the parent process id, the process that spawned the current process
 C this field is obsolete
 STIME the start time for the current process
 TTY the controlling terminal for the current process
 TIME the amount of CPU time accumulated by the current process
 CMD the command used to invoke the process
 PSR the processor
 PRI Priority of the process
 RSS Real memory usage
 S or STAT Process status code
 SZ Virtual memory usage
 NI nice value
 F Flags
 %CPU How much of the CPU the process is using
 %MEM How much memory the process is using
 WCHAN Memory address of the event the process is waiting for

Thank you for your time. Let me know your suggestions by commenting. 🙂

Related links:

How to show process usage for single user with TOP command
Top command usages and examples in Unix/Linux

groupdel, groupmems, groupmod, useradd , usermod , chgrp, chown, ls, head, tail, top, ps, find, crontab

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!