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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

pidof Command Examples in Linux

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.

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. blkid Command Examples in Linux
  2. pvck Command Examples in Linux
  3. authconfig Command Examples in Linux
  4. script: command not found
  5. Linux Interview Questions – Linux Printing (CUPS)
  6. git changelog: Generate a changelog report from repository commits and tags
  7. How to recover deleted Logical volume (LV) in LVM using vgcfgrestore
  8. comm: Select or reject lines common to two files. Both files must be sorted
  9. CentOS / RHEL : DNS servers in /etc/resolv.conf change after a reboot/network service restart. How to make them permanent
  10. vgs Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright