Linux / UNIX: Find out or determine if process pid is running

How do I find out my process is running on a Unix-like operating systems? How do I get the pid number for particular process on a Linux operating systems using bash shell?

A PID is an acronym for process identification number on a Linux or Unix-like operating system. A PID is automatically assigned to each process when it is created. A process is nothing but running instance of a program and each process has a unique PID on a Unix-like system.[donotprint]
Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time 2m

The easiest way to find out if process is running is run ps aux command and grep process name. If you got output along with process name/pid, your process is running.

Task: Find out process pid

Simply use ps command as follows:
ps aux | grep {process-name}

For example find out if mysqld process (mysqld pid) is running or not:
$ ps aux | grep mysqld
Sample outputs:

mysql    28290  1.1  2.7 340496 56812 ?        Sl   Jul31 348:27 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/ --skip-locking --socket=/var/lib/mysql/mysql.sock

Find the process ID of a running program using pidof

pidof command finds the process id’s (pids) of the named programs. It prints those id’s on screen. This program is on some systems used in run level change scripts, especially when the system has a System-V like rc structure. In that case these scripts are located in /etc/rc?.d, where ? is the runlevel. If the system has a start-stop-daemon (8) program that should be used instead.
# pidof mysqld
Sample outputs:


Find PID using pgrep command

The pgrep command searches the running system and shows the process IDs of all processes that match the given criteria. The syntax is:
pgrep {processNameHere}
pgrep firefox
pgrep httpd
pgrep nginx

Sample outputs:


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 19 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
19 comments… add one
  • surendra kumar Aug 27, 2007 @ 8:14

    hay man you can use pgrep also know?
    why ps -aux | grep process name?
    u can use pgrep like this
    pgrep process name
    pgrep httpd
    pgrep named
    pgrep firefox
    if any special about your command just give me info related to it

  • Adrian B. Feb 10, 2009 @ 9:27

    Thanks Surendra, damn good tips

  • Adrian B. Feb 10, 2009 @ 9:28

    you can also use this :
    $>pkill -f cruisecontrol
    in a cruisecontrol process which runs under java. -f does a substring search of the process string.

  • lala Sep 20, 2009 @ 19:33

    man, u guys rock, trust me it helps so much, when my maya hangs.
    special thanks: adrian B, pkill -f maya: wow, toogood

  • Rakesh Oct 2, 2009 @ 11:40

    Hi .

    I have a probleam . when i start mysql it is showing MySQL manager or server PID file could not be found! [FAILED] . Starting MySQL/etc/init.d/mysql: line 159: kill: (5984) – No such process .how to solve the probleam. if any one know plz help me

  • subramanya Apr 23, 2010 @ 8:38

    Thank you very much for the info.. it works for me..

  • Aaron Oct 20, 2010 @ 4:00

    i tried using kill(pid,0) to test whether the process is existent, need to include


  • mohsin Nov 29, 2010 @ 8:19

    when i reconfigure (squid -k reconfigure) squid i got error.
    like this
    squid: ERROR: Could not send signal 1 to process 6471: (3) No such process
    how i can remove this error please help me.

    Thanks in advance

  • Pinoy Jun 4, 2011 @ 17:12

    hanks ive been searching the net on how to find the pid of a process and this post solve my problem. thank you

  • Mikkel Sep 22, 2011 @ 21:02

    Bear in mind that the command itself can show up in the results. For instance:

    mikkel@www ~ $ ps aux | grep ntp
    root     20417  0.0  0.0   4408  1316 ?        Ss   17:30   0:00 /usr/sbin/ntpd -p /var/run/
    mikkel   20429  0.0  0.0   2064   572 pts/0    S+   17:30   0:00 grep --colour=auto ntp

    If you only see the grep command listed, that means the named command is not running.

  • Amensan Nov 6, 2011 @ 17:27


    I still can’t see my pid number for my postfix services. can’t find that. Help me. Thanks.

    Using: Linux server 11.04

  • SALIM Nov 15, 2011 @ 9:13

    why ? mark indicating ?? while each ps -ef |grep some process

  • kamal Mar 14, 2012 @ 6:53

    im facing one problem with pgrep command
    I want to display the PID of process with greping on process using this command for that:
    pgrep -lfu $UID | grep -i AddUser | grep -v grep | grep bash | tr -s ” ” | cut -d ” ” -f1
    but since the path of process AddUser is too long..the output of pgrep does not shows the fullname of process instead it crops the process name and displays only first 3 chars…Any idea to avoid cropping of process name

  • hari Apr 3, 2012 @ 9:45

    thanku fr d infr…

  • mullai Jun 1, 2012 @ 8:02

    hello.i want the command for taking login name as a command line argument in linux for shell program

  • Himal Feb 6, 2013 @ 17:02

    hello, What does ps – HI do? What is the meaning of this command?

  • oluc May 2, 2013 @ 8:20

    The process could be running (it has a pid) but stopped (kill -STOP $pid) (it is not actually running).

  • devender shekhawat Sep 27, 2014 @ 19:01

    I have a process PID i want to check this PID is for which process & the process is running or not.please explain with example

  • Rabindra kumar Feb 9, 2015 @ 4:28

    Hi All I want to know how many jobs are running on a particular server. So can anyone help me providing the command so that I could able to check how many jobs are running in the server and log status as well

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum