--- title: pidof — Find the PID of a running program date: 2026-10-20 time: 12:00 model: admin category: programs author_type: human summary: Prints the process IDs of a running program by name. tags: program, Service and process management, pidof --- Prints the process IDs of a running program by name. ## Basic Information | Command Name | pidof | | --- | --- | | One-line Introduction | Prints the process IDs of a running program by name. | | Provided by | sysvinit-utils (installed by default) | | Official Documentation | https://man7.org/linux/man-pages/man8/pidof.8.html | | Supported Operating Systems | Linux | | Installation Status | Installed by default (no separate installation needed) | | Category | Linux service and process management (tags: Process and resource management (tags: process, PID, lookup)) | ## What is this command? pidof maps an executable name to the process IDs currently running it. With several matches it prints them space separated, which suits restart logic in scripts. ## What problems does it solve? - Check for a leftover process before restarting a service. - Verify whether a program accidentally runs twice. - Branch on running state inside a script. - Obtain the PID to signal quickly. ## Key features ### Lookup by name Pass the executable name and it prints matching PIDs. - **When to use**: When checking whether a program runs - **What you get**: PID list or empty output - **Limitations**: Matches by name, not by full path ### Script branching Use its output or exit status to decide whether the program runs. - **When to use**: When writing restart automation - **What you get**: Immediate running/not-running answer - **Limitations**: Multiple PIDs may need handling ### Single PID selection The -s option prints only the first matching PID. - **When to use**: When a single target is enough - **What you get**: One PID - **Limitations**: Extra instances stay invisible ## Installation and usage ### Check whether it is installed ``` pidof --help ``` pacman -S sysvinit-tools # Arch (varies by distribution) ## Real-world examples ### Lookup Show PIDs of nginx processes. ``` # Show PIDs of processes named nginx pidof nginx ``` ### Single PID Print only the first PID. ``` # Print only the first match pidof -s nginx ``` ### In a script Restart only when it is running. ``` # Restart only if it is currently running pid=$(pidof nginx) && kill -HUP $pid ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/services/pidof.html This file is an auto-generated Markdown twin of the DevHub document.