pidof Command in Linux | Explained

In Linux, each process is assigned a unique identification number called the “Process ID”. This process id can easily get into the command line prompt by utilizing the “pidof” Linux command. This command shows the currently running process id. Moreover, the user can check more than one process ID simultaneously.

Keeping this in view, this article will describe the objective, working, and functionalities of the “pidof” command in Linux.

The outcomes of this article are defined below:

Let’s start with the basics of the pid command in Linux.

What is the pidof Command in Linux?

In Linux, the “pidof” command displays the process id list of the running programs or processes. It searches all the process that matches the mentioned program and displays the output.

The “pidof” doesn’t display the stuck program process id. 


The very basic syntax of the “pidof” command is defined below:

$ pidof [options] program1 program2 ... programN

The syntax of the “pidof” command holds the below-mentioned components:

  • Pidof: It is the main keyword in the syntax.
  • options: the square brackets represents the supported arguments of the “pidof” command.
  • program1…..programN: Specified program/processes whose process IDs need to be found via the “pidof” command.

The most commonly used arguments of the “pidof” command are listed using the command.

$ man pidof

How to Use pidof Command in Linux?

This section illustrates these options with the help of various practical examples.

Example 1: Display the particular Program ID

The “pidof” command, without any argument, provides the mentioned process or the program ID. To check the ID of the “systemd” program, type the command on the output and see the results:

$ pidof systemd

Example 2: Show Only One ID of Specific Program

By default, the “pidof” command displays all the IDs of the running process matching with the specified program or command.

To get only one ID of the particular program, enter the “pidof” command with the “-s” option. The “-s” option prints only one ID of the particular process:

$ pidof -s bash

The above output displays the “PID” of the “bash” process.

Example 3: List Script’s Process ID

The “-x” option of the “pidof” command helps get the process ID of scripts. Because generally, the “pidof” command does not display the process IDs of scripts “shell/perl/python”. Type the “pidof” command with the combination of “-x” and the “bash” as shown below:

$ pidof -x

The output shows the “bash” script process id.

Example 4: Modifying the Default Separator

The process ids are separated by default by the “tab” character. It can be changed by using the “-d” option of the “pidof” command. The new separator may be the “,(Comma)”, “;(Colon)”, “;(Semi-Colon)” and any other character.

In this example, the “|(Pipe)” symbol is used with the “-d” option for separating the process IDs of the “firefox” program:

$ pidof -d “|” firefox

The output shows that the process id’s of firefox are separated by a “|”.

Example 5: Get the Process ID of Running Process In PWD

The “-c” flag of the “pidof” command displays the process IDs currently running in the same root directory. Run the command as the root user or use the “sudo” with the “pidof” command:

$ sudo pidof -c bash

Example 6: Exclude Specific PID

The output of the “pidof” command list down all the process id related to the mentioned program or process.

To remove the particular id from the output, enter the “-o” option with a specific process id and program name in the terminal:

$ pidof -o PID thunderbrid

At this moment, there are a total “of 3” id’s associated with the “thunderbird” process, which is shown below.

We used the command to remove the process linked with the “id=8066”.

$ pidof -o 8066 thunderbird

The command will only omit the  “id=8066” process id from the output session. It has no impact on the running process.

That’s how the pidof command in Linux work.


The “pidof” command is useful to get the list of running process IDs. “tab” characters separate all the process IDs by default. The working of the “pidof” command relies on its generalized syntax. Furthermore, it is also useful for separating the displayed IDs by any other character, showing the stuck program’s process ID, and much more. This guide explains the purpose, usage, and working of the “pidof” command.