Linux find process by name

last updated in Categories , , , ,

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.


Procedure to find process by name on Linux

  1. Open the terminal application.
  2. Type the pidof command as follows to find PID for firefox process:
    pidof firefox
  3. Or use the ps command along with grep command as follows:
    ps aux | grep -i firefox
  4. To look up or signal processes based on name use:
  5. pgrep firefox

Linux find process by name using pgrep command

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:
Linux Find Process by name using pgrep pidof commands

A note about top/htop command

To display Linux processes use top command or htop command:
$ top
$ htop
htop Linux process viewer

See also

Getting more help

Read the man pages for the following command using man command:
$ man pgrep
$ man pidof
$ man ps


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.