Linux Commands - ps command (process PID)
by
Jeremy Canfield |
Updated: September 28 2021
| Linux Commands articles
The ps command can be used to view a static snapshot of active processes. The top command can be used to view processes in real time. The ps command without any options will display only the processes being used by the current user in the current shell.
[john.doe@server1 ]# ps
PID TTY TIME CMD
4012 pts/2 00:00:00 bash
4657 pts/2 00:00:00 ps
- The -A or -e options can be used to display all processes running on the system
- The -p option can be used to display a process associated with a certain process ID number (PID)
- The -U option can be used to display processes invoked by a certain user
- The -C option can be used to display processes invoked by a system service
- The -f or -F options can be used to add additional columns to the output
- The -o etime option can be used to determine how long a processes has been running for
grep
Often, the grep is used with the ps command.
[john.doe@server1 ]# ps | grep foo
This will always show that the grep command itself has a PID.
john.doe 29124 23915 0 03:02 pts/0 00:00:00 grep --color=auto foo
If you want to remove grep from the output, do this.
[john.doe@server1 ]# ps | grep foo | grep -v grep
Did you find this article helpful?
If so, consider buying me a coffee over at