How to: Find Out Whether a UNIX / Linux Process Is Running or Not

Q. I’d like to find out if httpd / mysqld or sshd process is running or not under CentOS Linux server. How do I determine whether a process is running or not?

ADVERTISEMENTS

A. You need to use following commands:

[a] ps – It report a snapshot of the current processes

[b] grep – Filter out process names

Find out if sshd is Process is Running or Not

Type the following command at shell prompt:
$ ps -ewwo pid,args | grep [s]sh
Output:

5341 /usr/sbin/sshd
 5864 /usr/bin/ssh-agent x-session-manager
 6289 ssh oldbox
 7126 ssh admin@core.r1.vsnl.router 

Where,

  • ps : Command name
  • -ewwo pid,args : -e option force to select all running processes. -o option is used to specify user-defined format. In our case we are forcing to display only program pid and its arguments. Finally -w option specifies wide output. Use this option twice for unlimited width.
  • grep [s]sh : We are just filtering out sshd string
🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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

ADVERTISEMENTS
3 comments… add one
  • Ganesh Oct 19, 2007 @ 5:51

    U can also do that without using user defined format….

    ps -eaf |grep [s]sh

    easy to remember than that…

  • Arupananda May 21, 2012 @ 10:45

    if you want to see whether a process is running on your environment or not just go to your terminal and type a command on CLI
    (root@local-host)# ps -ef | grep process_name
    Here ps -ef used for displaying of all running process
    grep is used for searching purpose here grep process_name search the process

    ps -ef will be input to grep process_name by using pipesymbol

  • Ramu Nov 30, 2013 @ 11:13

    Thanks for sharing this nice tut.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.