Linux: How to Find Process by Name

This post will guide you how to find a process by name on Linux. How do I find a process by name under Linux operating system.

Find Process by Name


You can use PS command to find running process in your Linux. and if you want to use ps command to find process by its name, you still need to combine with grep command. Like as followss:

# ps aux | grep -i sshd

Outputs:

devops@devops-osetc:~$ ps aux | grep -i sshd
root 1092 0.0 0.2 65512 2256 ? Ss Dec18 0:00 /usr/sbin/sshd -D
root 18170 0.0 0.6 94904 6796 ? Ss 10:50 0:00 sshd: devops [priv]
devops 18218 0.0 0.4 94904 4320 ? S 10:50 0:00 sshd: devops@pts/1
devops 18252 0.0 0.0 14224 936 pts/1 S+ 10:53 0:00 grep --color=auto -i sshd

Find Process using pidof Command


You can also use pidof command to achieve the same result of finding process by its name in Linux, just use the following command:

# pidof sshd

Outputs:

devops@devops-osetc:~$ pidof sshd
18218 18170 1092

From the above outputs, you should see that this command will find the process ID of a running program.

Find Process Using pgrep Command


You can also use pgrep command to look up or signal processes based on name and other attributes. just use the following command:

# pgrep sshd

Outputs:

devops@devops-osetc:~$ pgrep sshd
1092
18170
18218

Show all Running Process


If you want to show all running process in your Linux system, you need to use ps command with aux options. type:

# ps axu | less

Or

# ps aux | more

Outputs:

devops@devops-osetc:~$ ps aux | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.4 185248 4444 ? Ss Dec18 0:05 /sbin/init splash
root 2 0.0 0.0 0 0 ? S Dec18 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Dec18 0:06 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< Dec18 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S Dec18 1:31 [rcu_sched]
root 8 0.0 0.0 0 0 ? S Dec18 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S Dec18 0:00 [migration/0]
root 10 0.0 0.0 0 0 ? S< Dec18 0:00 [lru-add-drain]
root 11 0.0 0.0 0 0 ? S Dec18 0:00 [watchdog/0]
root 12 0.0 0.0 0 0 ? S Dec18 0:00 [cpuhp/0]
root 13 0.0 0.0 0 0 ? S Dec18 0:00 [kdevtmpfs]
root 14 0.0 0.0 0 0 ? S< Dec18 0:00 [netns]
root 15 0.0 0.0 0 0 ? S Dec18 0:00 [khungtaskd]
root 16 0.0 0.0 0 0 ? S Dec18 0:00 [oom_reaper]
root 17 0.0 0.0 0 0 ? S< Dec18 0:00 [writeback]
root 18 0.0 0.0 0 0 ? S Dec18 0:00 [kcompactd0]
root 19 0.0 0.0 0 0 ? SN Dec18 0:00 [ksmd]
root 20 0.0 0.0 0 0 ? SN Dec18 0:01 [khugepaged]
root 21 0.0 0.0 0 0 ? S< Dec18 0:00 [crypto]
.......

See Also:

You might also like:

Sidebar



back to top