
While listing the active processes in the background, it may not show the name of the process and will only show you the PID of the process.
And if you are curious to know the name of the process, then you can use the ps command in the following manner:
ps -p <Enter_PID> -o comm=
In the above command, make sure to replace <Enter_PID>
with the PID of your process.
Want more details? Here you have it.
How to get the process name from PID
In this section, I will walk you through a detailed explanation of how I used the ps command to get the process name.
Also, I will show you how you can find a process name directly using the pidof
command later in this tutorial.
So let's start with the breakdown of the ps command.
First, let's have a look at the output you get when you use the ps command in the following manner:
ps -p <Enter_PID> -o comm=
For example, here, I used the PID 4416
, so here's the end command I have to use:
ps -p 4416 -o comm=

As you can see, the PID indicated that the process name was firefox-bin
.
Now, let's break it down for better understanding:
ps
: The ps command which is used to get information about running processes.-p <Enter_PID
: The-p
flag is used to specify the PID of the process and you append the PID with it.-o comm=
: This part is used to format the output with the ps command. Specifically, when you pair the-o
flag with thecomm==
(an abbreviation for command), it shows the name of the executable associated with the process.
Pretty cool. Right?
But how would you know the actively running processes? Use the ps command with the -ef
flag as shown:
ps -ef

Pretty cool. Right?
But what if you want to know the PID using the process name only? Well, in that case, you can use the pidof
command in the following manner:
pidof exact_process_name
For example, if I want to know the PID of firefox, then I will use the following:
pidof firefox

That was easy.
Here's how to master the Linux command line
Beginner to the terminal? Let me share some tips to embrace the terminal.
First, start with the basic Linux commands to get the hang of how you perform basic tasks in the terminal:

Once done, you can refer to our tutorial series "Terminal Basics" where we have covered how you perform basic tasks like copying files, changing directories, etc:

I hope you will find this guide helpful.
It's FOSS turns 13! 13 years of helping people use Linux β€οΈ
And we need your help to go on for 13 more years. Support us with a Plus membership and enjoy an ad-free reading experience and get a Linux eBook for free.
To celebrate 13 years of It's FOSS, we have a lifetime membership option with reduced pricing of just $76. This is valid until 25th June only.
If you ever wanted to appreciate our work with Plus membership but didn't like the recurring subscription, this is your chance π