• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

pidof: command not found

by Deepika

“pidof” is a Unix/Linux command that is used to find the process ID (PID) of a running process based on its name. This can be useful in several scenarios such as:

  • Checking if a process is running: You can use the “pidof” command to check if a process is running. For example, if you want to check if the Apache web server is running, you can use the following command: pidof apache2. If the Apache web server is running, the command will output its PID.
  • Killing a process: Once you have the PID of a process, you can use the “kill” command to stop the process. For example, if you want to stop the Apache web server, you can use the following command: kill $(pidof apache2).
  • Monitoring a process: The “pidof” command can be used in combination with other tools to monitor a process. For example, you can use the “top” command to monitor the CPU and memory usage of a process by using its PID.

It’s important to note that the “pidof” command only returns the PID of the first instance of the process it finds. If there are multiple instances of the same process running, you need to use other tools to find all of their PIDs.

If you encounter the below error while running the command pidof:

pidof: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install sysvinit-utils
Ubuntu apt-get install sysvinit-utils
Arch Linux pacman -S procps-ng
Kali Linux apt-get install sysvinit-utils
CentOS yum install sysvinit-tools
Fedora dnf install procps-ng
OS X brew install pidof
Raspbian apt-get install sysvinit-utils

pidof Command Examples

1. List all process IDs with given name:

# pidof bash

2. List a single process ID with given name:

# pidof -s bash

3. List process IDs including scripts with given name:

# pidof -x script.py

4. Kill all processes with given name:

# kill $(pidof name)

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to recover from deleted root entry in /etc/shadow and/or /etc/passwd files in CentOS / RHEL 6
  2. lpq: command not found
  3. iptables Command Examples in Linux
  4. crontab error : “You (user) are not allowed to access to (crontab) because of pam configuration.”
  5. Rpm: Error While Loading Shared Libraries: Libz.so.1: Cannot Open Shared Object File: No Such File
  6. CentOS / RHEL 5 : How to use the faillog command to track failed login attempts
  7. How to Extend allowed number of loopback devices
  8. avahi-browse Command Examples in Linux
  9. pkill Command Examples in Linux
  10. How to load SELinux Module For Oracleasm

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright