{"id":12445,"date":"2019-03-27T01:23:53","date_gmt":"2019-03-27T01:23:53","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12445"},"modified":"2019-03-27T01:23:53","modified_gmt":"2019-03-27T01:23:53","slug":"how-to-find-a-process-name-using-pid-number-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/27\/how-to-find-a-process-name-using-pid-number-in-linux\/","title":{"rendered":"How to Find a Process Name Using PID Number in Linux"},"content":{"rendered":"<p>In this article, we will look at\u00a0<a href=\"https:\/\/www.tecmint.com\/find-linux-processes-memory-ram-cpu-usage\/\" target=\"_blank\" rel=\"noopener\">how to find a process name<\/a>\u00a0by its process identification number (PID). Before we dive into the actual solution, let us briefly talk about how processes are created and identified by Linux.<\/p>\n<p>Every time a user or the system (Linux) launches a program, the kernel will create a process. A process holds execution details of the program in memory such as its input and output data, variables and so on.<\/p>\n<p>Importantly, since Linux is a multitasking operating system, it executes several programs simultaneously, and this means each process process must be identified specifically.<\/p>\n<p>The kernel identifies each process using a process\u00a0<strong>ID<\/strong>\u00a0(<strong>PID<\/strong>), a every instance of process must have a unique\u00a0<strong>PID<\/strong>from other processes which is assigned when the process is invoked, to avoid any execution errors.<\/p>\n<p><center>The\u00a0<a href=\"https:\/\/www.tecmint.com\/exploring-proc-file-system-in-linux\/\" target=\"_blank\" rel=\"noopener\">\/proc file system<\/a>\u00a0stores information about\u00a0<a href=\"https:\/\/www.tecmint.com\/monitor-linux-processes-and-set-process-limits-per-user\/\" target=\"_blank\" rel=\"noopener\">currently running processes on your system<\/a>, it contains directories for each process.<\/center>Use the\u00a0<a href=\"https:\/\/www.tecmint.com\/tag\/linux-ls-command\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>\u00a0to list its contents, however, the list may be long, so employ a pipeline and the\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-more-command-and-less-command-examples\/\" target=\"_blank\" rel=\"noopener\">less utility to view the \/proc contents<\/a>\u00a0in a more convenient way as below:<\/p>\n<pre>$ ls \/proc \r\nOR\r\n$ ls \/proc | less \r\n<\/pre>\n<div class=\"code-label\">List \/proc File System<\/div>\n<pre>1     168   2230  25    329   584   7386  83         driver        schedstat\r\n10    169   2234  2503  33    603   74    830        execdomains   scsi\r\n1070  17    2247  2507  34    610   7411  833        fb            self\r\n1081  1702  2256  2523  349   611   7423  836        filesystems   slabinfo\r\n109   1714  2258  253   35    612   745   839        fs            softirqs\r\n11    173   2266  2551  36    613   746   84         interrupts    stat\r\n110   1760  2273  26    362   62    75    844        iomem         swaps\r\n1188  1763  2278  2688  3642  63    7533  85         ioports       sys\r\n12    1769  2282  2694  3643  64    7589  86         irq           sysrq-trigger\r\n1204  177   2283  2695  37    6436  76    860        kallsyms      sysvipc\r\n1209  1773  2285  2698  38    65    7619  87         kcore         thread-self\r\n1254  18    2287  2699  39    66    7689  9          keys          timer_list\r\n13    1847  2295  27    3974  67    7690  94         key-users     timer_stats\r\n15    1914  23    2702  3976  68    77    977        kmsg          tty\r\n152   1917  2308  28    4273  6897  7725  981        kpagecgroup   uptime\r\n153   1918  2309  280   4374  69    7729  987        kpagecount    version\r\n154   1938  2310  2815  4392  6969  7733  997        kpageflags    version_signature\r\n155   1956  2311  2817  44    6980  78    acpi       loadavg       vmallocinfo\r\n156   1981  2315  282   45    7     79    asound     locks         vmstat\r\n1565  1986  2316  283   4543  70    790   buddyinfo  mdstat        zoneinfo\r\n1567  1988  2317  29    46    71    8     bus        meminfo\r\n157   2     2324  2935  461   7102  80    cgroups    misc\r\n1579  20    2347  2944  4686  72    808   cmdline    modules\r\n158   2010  2354  3     47    73    81    consoles   mounts\r\n1584  2043  2436  30    4700  7304  810   cpuinfo    mtrr\r\n159   2044  2437  3016  5     7311  815   crypto     net\r\n1590  21    2442  31    515   7322  82    devices    pagetypeinfo\r\n16    2167  2443  318   5273  7347  820   diskstats  partitions\r\n160   22    2492  32    5274  7367  823   dma        sched_debug\r\n<\/pre>\n<p>From the screenshot above, the numbered directories store information files about the processes in execution, where each number corresponds to a\u00a0<strong>PID<\/strong>.<\/p>\n<p>Below is the list of files for\u00a0<strong>systemd<\/strong>\u00a0process with\u00a0<strong>PID 1<\/strong>:<\/p>\n<pre>$ ls \/proc\/1\r\n<\/pre>\n<div class=\"code-label\">Show SystemD Process PID<\/div>\n<pre>ls: cannot read symbolic link '\/proc\/1\/cwd': Permission denied\r\nls: cannot read symbolic link '\/proc\/1\/root': Permission denied\r\nls: cannot read symbolic link '\/proc\/1\/exe': Permission denied\r\nattr        coredump_filter  gid_map    mountinfo   oom_score      schedstat  status\r\nautogroup   cpuset           io         mounts      oom_score_adj  sessionid  syscall\r\nauxv        cwd              limits     mountstats  pagemap        setgroups  task\r\ncgroup      environ          loginuid   net         personality    smaps      timers\r\nclear_refs  exe              map_files  ns          projid_map     stack      uid_map\r\ncmdline     fd               maps       numa_maps   root           stat       wchan\r\ncomm        fdinfo           mem        oom_adj     sched          statm\r\n<\/pre>\n<p>You can\u00a0<a href=\"https:\/\/www.tecmint.com\/bcc-best-linux-performance-monitoring-tools\/\" target=\"_blank\" rel=\"noopener\">monitor processes and their PIDs<\/a>\u00a0using traditional Linux commands such as\u00a0<a href=\"https:\/\/www.tecmint.com\/mkdir-tar-and-kill-commands-in-linux\/\" target=\"_blank\" rel=\"noopener\">ps<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">top<\/a>\u00a0and relatively new\u00a0<a href=\"https:\/\/www.tecmint.com\/glances-an-advanced-real-time-system-monitoring-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">glances<\/a>\u00a0command plus many more as in the examples below:<\/p>\n<pre>$ ps aux\r\n<\/pre>\n<div class=\"code-label\">Show Running Processes with PID<\/div>\n<pre>USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\r\nroot         1  0.0  0.0 185728  6268 ?        Ss   10:15   0:01 \/sbin\/init splash\r\nroot         2  0.0  0.0      0     0 ?        S    10:15   0:00 [kthreadd]\r\nroot         3  0.0  0.0      0     0 ?        S    10:15   0:00 [ksoftirqd\/0]\r\nroot         5  0.0  0.0      0     0 ?        S&lt;   10:15   0:00 [kworker\/0:0H]\r\nroot         7  0.0  0.0      0     0 ?        S    10:15   0:09 [rcu_sched]\r\nroot         8  0.0  0.0      0     0 ?        S    10:15   0:00 [rcu_bh]\r\nroot         9  0.0  0.0      0     0 ?        S    10:15   0:00 [migration\/0]\r\nroot        10  0.0  0.0      0     0 ?        S    10:15   0:00 [watchdog\/0]\r\nroot        11  0.0  0.0      0     0 ?        S    10:15   0:00 [watchdog\/1]\r\nroot        12  0.0  0.0      0     0 ?        S    10:15   0:00 [migration\/1]\r\nroot        13  0.0  0.0      0     0 ?        S    10:15   0:00 [ksoftirqd\/1]\r\nroot        15  0.0  0.0      0     0 ?        S&lt;   10:15   0:00 [kworker\/1:0H]\r\nroot        16  0.0  0.0      0     0 ?        S    10:15   0:00 [watchdog\/2]\r\nroot        17  0.0  0.0      0     0 ?        S    10:15   0:00 [migration\/2]\r\nroot        18  0.0  0.0      0     0 ?        S    10:15   0:00 [ksoftirqd\/2]\r\nroot        20  0.0  0.0      0     0 ?        S&lt;   10:15   0:00 [kworker\/2:0H]\r\nroot        21  0.0  0.0      0     0 ?        S    10:15   0:00 [watchdog\/3]\r\nroot        22  0.0  0.0      0     0 ?        S    10:15   0:00 [migration\/3]\r\nroot        23  0.0  0.0      0     0 ?        S    10:15   0:00 [ksoftirqd\/3]\r\nroot        25  0.0  0.0      0     0 ?        S&lt;   10:15   0:00 [kworker\/3:0H]\r\nroot        26  0.0  0.0      0     0 ?        S    10:15   0:00 [kdevtmpfs]\r\nroot        27  0.0  0.0      0     0 ?        S&lt;   10:15   0:00 [netns]\r\nroot        28  0.0  0.0      0     0 ?        S&lt;   10:15   0:00 [perf]\r\n....\r\n<\/pre>\n<p>Monitor Linux processes using traditional\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">top command<\/a>.<\/p>\n<pre>$ top\r\n<\/pre>\n<div id=\"attachment_23263\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Monitor-Linux-Processes-with-top-Command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-23263\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Monitor-Linux-Processes-with-top-Command.png\" sizes=\"auto, (max-width: 914px) 100vw, 914px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Monitor-Linux-Processes-with-top-Command.png 914w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Monitor-Linux-Processes-with-top-Command-768x513.png 768w\" alt=\"Monitor Linux Processes with top Command\" width=\"914\" height=\"610\" aria-describedby=\"caption-attachment-23263\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-23263\" class=\"wp-caption-text\">Monitor Linux Processes with top Command<\/p>\n<\/div>\n<p>Monitor Linux processes using\u00a0<strong>glances<\/strong>, a new real-time process monitoring tool for Linux.<\/p>\n<pre>$ glances\r\n<\/pre>\n<div id=\"attachment_23264\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Glances-Real-Time-Linux-Processes-Monitoring.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-23264\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Glances-Real-Time-Linux-Processes-Monitoring.png\" sizes=\"auto, (max-width: 914px) 100vw, 914px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Glances-Real-Time-Linux-Processes-Monitoring.png 914w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Glances-Real-Time-Linux-Processes-Monitoring-768x513.png 768w\" alt=\"Glances - Real Time Linux Processes Monitoring\" width=\"914\" height=\"610\" aria-describedby=\"caption-attachment-23264\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-23264\" class=\"wp-caption-text\">Glances \u2013 Real Time Linux Processes Monitoring<\/p>\n<\/div>\n<p>Learn more about\u00a0<a href=\"https:\/\/www.tecmint.com\/glances-an-advanced-real-time-system-monitoring-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">how to install Glances in Linux systems<\/a>.<\/p>\n<h3>Find Out Process PID Number<\/h3>\n<p>To find out the\u00a0<strong>PID<\/strong>\u00a0of a process, you can use\u00a0<code>pidof<\/code>, a simple command to print out the\u00a0<strong>PID<\/strong>\u00a0of a process:<\/p>\n<pre>$ pidof firefox\r\n$ pidof python\r\n$ pidof cinnamon\r\n<\/pre>\n<div id=\"attachment_23265\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Find-Linux-Process-PID.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-23265\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Find-Linux-Process-PID.png\" alt=\"Find Linux Process PID\" width=\"464\" height=\"178\" aria-describedby=\"caption-attachment-23265\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-23265\" class=\"wp-caption-text\">Find Linux Process PID<\/p>\n<\/div>\n<p>Coming back to our point of focus, assuming you already know the\u00a0<strong>PID<\/strong>\u00a0of a process, you can print its name using the command form below:<\/p>\n<pre>$ ps -p PID -o format \r\n<\/pre>\n<p>Where:<\/p>\n<ol>\n<li><code>-p<\/code>\u00a0specifies the PID<\/li>\n<li><code>-o<\/code>\u00a0format enables a user-defined format<\/li>\n<\/ol>\n<h3>Find Out Process Name Using PID Number<\/h3>\n<p>In this section, we will see how to find out a process name using its PID number with the help of user defined format i.e\u00a0<code>comm=<\/code>\u00a0which means command name, same as the process name.<\/p>\n<pre>$ ps -p 2523 -o comm=\r\n$ ps -p 2295 -o comm=\r\n<\/pre>\n<div id=\"attachment_23267\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Find-Linux-Process-Name.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-23267\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Find-Linux-Process-Name.png\" alt=\"Find Linux Process Name\" width=\"464\" height=\"178\" aria-describedby=\"caption-attachment-23267\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-23267\" class=\"wp-caption-text\">Find Linux Process Name<\/p>\n<\/div>\n<p>For additional usage information and options, look through the\u00a0<strong>ps man<\/strong>\u00a0page.<\/p>\n<pre>$ man ps\r\n<\/pre>\n<p>If you want to kill a process using its PID number, I suggest you to read\u00a0<a href=\"https:\/\/www.tecmint.com\/find-and-kill-running-processes-pid-in-linux\/\" target=\"_blank\" rel=\"noopener\">Find and Kill Linux Processes Using its PID<\/a>.<\/p>\n<p>Thats it for the moment, if you know any other better way to find out a process name using\u00a0<strong>PID<\/strong>, do share with us via our comment section below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/find-process-name-pid-number-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will look at\u00a0how to find a process name\u00a0by its process identification number (PID). Before we dive into the actual solution, let us briefly talk about how processes are created and identified by Linux. Every time a user or the system (Linux) launches a program, the kernel will create a process. A &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/27\/how-to-find-a-process-name-using-pid-number-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Find a Process Name Using PID Number in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12445","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12445"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12445\/revisions"}],"predecessor-version":[{"id":12446,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12445\/revisions\/12446"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}