PIDOF(8)
๐ PIDOF(8) ๐
Okay bestie, this page is from the Linux System Administrator's Manual and it's all about pidof ๐
โจ NAME โจ
pidof - find the process ID of a running program ๐
๐ SYNOPSIS โจ
pidof [-s] [-c] [-n] [-x] [-z] [-o omitpid[,omitpid...]] [-o
omitpid[,omitpid...]...] [-d sep] program [program...]
๐ DESCRIPTION โจ
So pidof finds the process IDs (PIDs) of the programs you name and prints those IDs to standard output ๐จ๏ธโจ It's giving "find me the PID, no cap."
Lowkey, on some systems this gets used in run-level change scripts, especially when the system has a System-V-style rc structure. In that case the scripts live in /etc/rc?.d, where ? is the runlevel ๐ง If your system has a start-stop-daemon(8) program, that's the one you should be using instead, periodt ๐
๐ OPTIONS โจ
-sโ Single shot! ๐ฏ This tells the program to only return one PID, bestie.-cโ Only return PIDs of processes running with the same root directory ๐ธ This one gets ignored for non-root users, because they can't check the current root directory of processes they don't own ๐-nโ Skip thestat(2)system call on all binaries sitting on network-based file systems like NFS ๐ Instead of using this flag, you can set and export the variablePIDOF_NETFS๐ฆ-qโ Quiet mode ๐คซ Don't show matched PIDs on standard out. The program just exits with a status of true or false to tell you whether a matching PID was found. Main character energy โจ-xโ Scripts too! ๐ This makes the program also return the process IDs of shells that are running the named scripts ๐-zโ Tries to detect processes stuck in zombie (Z) status ๐ง Normally these get skipped, because messing with them can makepidofor related tools hang ๐ Quick tea: back in the daypidofwould skip processes in the uninterruptible state (D) unless you passed-z. That's no longer the case! Nowpidoffinds and reportsDstate processes whether or not you use-z๐ซถ-d sepโ Tellspidofto usesepas the output separator when more than one PID is shown ๐ The default separator is a space.-o omitpidโ Tellspidofto leave out processes with that process ID ๐ โโ๏ธ The special PID%PPIDcan be used to name the parent process of thepidofprogram, aka the calling shell or shell script ๐
๐ EXIT STATUS โจ
0โ Yay! At least one program with the requested name was found ๐1โ Oof, no program with the requested name was found ๐ญ
๐ NOTES โจ
Okay so pidof is actually the same program as killall5(8). It just behaves based on the name it was called under ๐ง
When you invoke pidof with the full pathname to the program you want, it's reasonably safe ๐ Otherwise it's possible it returns PIDs of running programs that just happen to share the same name but are actually different programs. Iykyk ๐ Also, the executable name of running processes is calculated with readlink(2), so symbolic links to executables will match too ๐ฆ
Heads up, bestie! Zombie processes and processes in disk sleep (statesZandD, respectively) are ignored by default, because trying to access their stats can sometimes fail ๐ The-zflag tellspidofto try detecting these sleeping and zombie processes, but it comes with the risk of failing or hanging. Proceed with caution ๐ซฃ
๐ SEE ALSO โจ
shutdown(8), init(8), halt(8), reboot(8), killall5(8) ๐
๐ AUTHOR โจ
Miquel van Smoorenburg ๐ง
Okay that's the whole page, bestie ๐ It's from sysvinit, last updated 01 Sep 1998. Love you, mwah ๐๐ฆ๐
๐ฆ where this page comes from
- debian trixie: sysvinit-utils 3.14-4 ยท GPL-2.0-or-later
- ubuntu questing: sysvinit-utils 3.14-4ubuntu1 ยท GPL-2.0-or-later
- ubuntu resolute: sysvinit-utils 3.15-5ubuntu1 ยท GPL-2.0-or-later
- ubuntu stonking: sysvinit-utils 3.18-1ubuntu1 ยท GPL-2.0-or-later
- Copyright (C) 1998 Miquel van Smoorenburg
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms