In this article, we will see Linux ps command with examples.
Linux ps command is used to get list of processes currently running on Linux/Unix operating system. The ps command ıs commonly used by admınıstrators to ınvestıgate snapshots of a specıfıc process. ps ıs commonly used wıth grep to fılter out a
specıfıc process to analyze.
Linux ps command syntax and options:
ps [options]
Linux ps command examples
1. Find the list of processes running in current shell:
ps
Where:
PID: Process ID
TTY: Terminal type that user is logging into Linux
TIME: Amount of CPU units and seconds that process has been running.
CMD: Name of the command that launched process.
2. List all process running in Linux/Unix:
We can also get all processes running on our Linux/Unix system using ps command with the option -e or -A
ps -e
ps -A
3. To full listing of all processes in Linux:
In the following commnad -f means full listing.
ps -f
4. Find the processes associate with current terminal:
ps -T
5. View Processes not associated with a terminal : View all processes except both session leaders and processes not associated with a terminal.
ps -a
6. Find processes running for particular user in Linux/Unix:
We use -u option with ps command. Following command lists processes running for the user david.
ps -s david
7. View all processes owned by ourselves.
ps -x
8. Find list of processes running.
ps -r
9. How to check particular process is running or not by using process name and pid.
Check pid 225 is running or not.
ps -ef | grep 2295
Check processes related to postgres or not.
10. View highest memory using processes.
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | more
11. Find top 10 most memory consuming processes.
ps aux --sort=pmem | head -10
Linux ps options:
Basic options:
-A, -e all processes -a all with tty, except session leaders a all with tty, including other users -d all except session leaders -N, --deselect negate selection r only running processes T all processes on this terminal x processes without controlling ttys
So in this article, we have seen Linux ps command syntax examples and option.