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
- Open the terminal application.
- Type the pidof command as follows to find PID for firefox process:
- 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:
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
A note about top/htop command
- Show All Running Processes in Linux
- Linux / UNIX: Find out or determine if process pid is running
- Unix / Linux: Find Information About The Process Including All Command Line Parameters
- Linux: Find Out Which Process Is Listening Upon a Port
Getting more help
Read the man pages for the following command using man command:
$ man pgrep
$ man pidof
$ man ps
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|