Linux find process by name

ADVERTISEMENTS



Procedure to find process by name on Linux

Open the terminal application. Type the pidof command as follows to find PID for firefox process:

pidof firefox Or use the ps command along with grep command as follows:

ps aux | grep -i firefox To look up or signal processes based on name use: pgrep firefox

Linux find process by name using pgrep command

I am a new Linux user. How can I find a computer program/process by name on Linux? Is it possible to find a process by name instead of PID on a Linux?A Linux computer program, or running a program concurrently with other applications known as a process. A child process in Linux is a process created by another process. The parent process is a process that has created one or more child processes on Linux operating system. The process identifier (process ID or PID) is a number used by Linux or Unix operating system kernels. It is used to uniquely identify an active process.

pgrep command looks through the currently running processes and lists the process IDs which match the selection criteria to screen. All the criteria have to match. For example, will only list the processes called sshd AND owned by root user:

$ pgrep -u root sshd

Just look up pid for firefox process:

$ pgrep firefox

How to use ‘ps aux | grep command’

ps command shows information about a selection of the active processes:

$ ps aux

$ ps aux | grep -i 'search-term'

$ ps aux | grep 'firefox'

$ ps aux | grep 'sshd'

OR use the following syntax instead of using egrep command in pipes:

$ ps -fC firefox

$ ps -fC chrome

The -C option asks ps command to select PIDs by command name.

Using pidof command to grab PIDs for any named program on Linux

The pidof command finds the process id’s (pids) of the named programs such as sshd, firefox and more. For example:

$ pidof sshd

$ pidof firefox

Sample outputs:



A note about top/htop command

To display Linux processes use top command or htop command:

$ top

OR

$ htop



See also

Getting more help

Read the man pages for the following command using man command:

$ man pgrep

$ man pidof

$ man ps