Get Process Name From PID in Linux

Learn to get the process name from the PID of a process in this quick Linux tip.

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=
Use the ps command to know the process name from PID

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 the comm== (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
Use of ps command to list actively running processes

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
Find the PID using process name in Linux

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:

25 Must-Know Ubuntu Commands
New to Ubuntu? Here are the must know Ubuntu commands that will help you get control on the system more effectively 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:

Linux Command Tutorials for Absolute Beginners
Never used Linux commands before? No worries. This tutorial series is for absolute beginners to the Linux terminal.

I hope you will find this guide helpful.

About the author
Sagar Sharma

Sagar Sharma

A software engineer who loves to write about his experience with Linux. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world


Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.