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.

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= 
Or 
# pgrep PROCESS 
Or
# pgrep -u user-name PROCESS (running under the user)


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

#  ps -p PID -o comm=


Was this answer helpful? 2 Users Found This Useful (72 Votes)