Raspberry Pi

How to Find Process Name using PID in Raspberry Pi

PID (Process Identification) number is the process identity number in Linux-based systems such as Raspberry Pi OS. The Linux-based systems support multi-tasking due to which multiple processes can run at the same time. So, in order to differentiate between processes each process in Raspberry Pi is assigned a PID number which is always different from each other. So, if a user knows the PID number of a certain process they can easily track the process with it. If you want to know how you can find the process name using PID then follow this article.

How to Find Process Name Using PID Number in Raspberry Pi?

There are several ways to find the process name using PID number, which are mentioned below:

Command 1

The first command on the list is the ls /proc command. The /proc files system contains information of directories for all the running processes in the Raspberry Pi. So, by listing the contents of /proc we can display a list of running processes with their PID numbers. From this list, you can compare the PID number and find the process with the desired PID number

$ ls /proc

Command 2

The second command on the list is the ps aux command, which displays the list of processes with their PID number, %mem (memory) and %cpu (CPU) usage. So, you can know which PID or process is utilizing the most amount of RAM and CPU:

$ ps aux

By seeing the output of this command, you can also find the process name by looking for its PID number in the list: 

Command 3

Another handy command which can be used to find process name using PID number in Raspberry Pi is the top command:

$ top

The top command list all the processes with their PID number and sorted in such a way that the processes with maximum CPU usage are listed at the top:

Command 4

Last but the most useful command to find process name using the PID number in Raspberry Pi is mentioned below:

Syntax

$ ps -p <PID> -o comm=

By using this command, you can simply use the PID number in the command and as an output the name of the process will display on the terminal

Examples

$ ps -p 11875 -o comm=
$ ps -p 1455 -o comm=

Conclusion

There are so many commands in the Raspberry Pi system that can help users to find out the process name by using the PID number. Some of the most important and useful commands are discussed in the article such as the top command, ps aux, ls /proc and other such commands. The output displays the PID number list with the processes’ names from which the user can find their desired process.

About the author

Zahra Zamir

An Electronics graduate who loves to learn and share the knowledge, my passion for my field has helped me grasp complex electronics concepts and now I am here to share them with others.