Linux find all processes with name

How to check running process in Linux using command line

I am a new system administrator for the Linux operating system. How do I check running process in Linux using the command line option?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Est. reading time 4 mintues

One can use the Linux command line or terminal app to display a running process, change their priorities level, delete process and more. This page shows how to use various commands to list, kill and manage process on Linux.

Check running process in Linux

The procedure to monitor the running process in Linux using the command line is as follows:

  1. Open the terminal window on Linux
  2. For remote Linux server use the ssh command for log in purpose
  3. Type the ps aux command to see all running process in Linux
  4. Alternatively, you can issue the top command or htop command to view running process in Linux

Let us see some example and usage in details.

Please note that vivek@nixcraft:

$ is my shell prompt. You need to type commands after the $ prompt.

How to manage processes from the Linux terminal

The ps command is a traditional Linux command to lists running processes. The following command shows all processes running on your Linux based server or system:
vivek@nixcraft:

$ ps -aux
vivek@nixcraft:

  1. root – User name
  2. 1 – PID (Linux process ID)
  3. 19:10 – Process start time
  4. /sbin/init splash – Actual process or command

There may be too many processes. Hence, it uses the following less command/more command as pipe to display process one screen at a time:
vivek@nixcraft:

$ ps -aux | more
vivek@nixcraft:

$ sudo ps -aux | less
Press q to exit from above Linux pagers. You can search for a particular Linux process using grep command/egrep command:
vivek@nixcraft:

$ ps aux | grep firefox
vivek@nixcraft:

$ sudo ps aux | grep vim
vivek@nixcraft:

$ sudo ps -aux | egrep ‘sshd|openvpn|nginx’

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Linux pgrep command

Many variants of Linux comes with the pgrep command to search/find process. The syntax is:
vivek@nixcraft:

$ sudo pgrep sshd
vivek@nixcraft:

$ pgrep vim
vivek@nixcraft:

$ pgrep firefox
vivek@nixcraft:

Linux top command

The top command is another highly recommended method to see your Linux servers resource usage. One can see a list of top process that using the most memory or CPU or disk.
vivek@nixcraft:

$ sudo top
vivek@nixcraft:

Linux htop command to check running process in Linux

The htop command is an interactive process viewer and recommended method for Linux users. One can see a list of top process that using the most memory or CPU or disk and more:
vivek@nixcraft:

$ sudo htop
vivek@nixcraft:

Linux kill command

Want to kill a process? Try kill command. The syntax is:
vivek@nixcraft:

$ kill pid
vivek@nixcraft:

$ kill -signal pid
Find PID using ps, pgrep or top commands. Say you want to kill a PID # 16750, run:
vivek@nixcraft:

$ kill 16750
For some reason if the process can not be killed, try forceful killing:
vivek@nixcraft:

$ kill -9 16750
OR
vivek@nixcraft:

$ kill -KILL 16750

Linux pkill command

If you wish to kill a process by name, try pkill command. The syntax is:
vivek@nixcraft:

$ pkill processName
vivek@nixcraft:

$ pkill vim
vivek@nixcraft:

$ pkill firefox
vivek@nixcraft:

$ pkill -9 emacs
vivek@nixcraft:

$ sudo pkill -KILL php7-fpm

Linux killall command

The killall command kills processes by name, as opposed to the selection by PID as done by kill command:
vivek@nixcraft:

$ killall vim
vivek@nixcraft:

$ killall -9 emacs

Linux nice and renice command

The primary purpose of the nice command is to run a process/command at a lower or higher priority. Use the renice command to alter the nice value of one or more running Linux processes. The nice value can range from -20 to 19, with 19 being the lowest priority. Say, you want to compile software on a busy Linux server. You can set a very low priority, enter:
vivek@nixcraft:

$ nice -n 13 cc -c *.c &
Set a very high priority for a kernel update. Before rebooting Linux server, run:

Источник

Linux list processes by user names (EUID and RUID)

Linux list processes by user names

The procedure to view process created by the specific user in Linux is as follows:

  1. Open the terminal window or app
  2. To see only the processes owned by a specific user on Linux run: ps -u
  3. Search for a Linux process by name run: pgrep -u
  4. Another option to list processes by name is to run either top -U or htop -u commands

Let us see examples in details to show all processes for a specific user on Linux.

How to see process created by a specific user in Linux

See all process crated by user named tom:
ps -u tom
OR
ps -U tom
EUID is the Effective User ID. The effective user ID describes the user whose file access permissions are used by the process. RUID is the Real User ID. The real user ID identifies the user who created the process. So:

  • -u tom : Show all processes by RUID
  • -U tom : Display all processes by EUID

You can get a list of every process running as vivek (real [RUID] & effective ID [EUID]) in user format:
ps -U vivek -u vivek
ps -U vivek -u vivek u
## see all process run by, qemu and postfix users ##
ps -U qemu -u qemu
ps -U postfix -u postfix
ps -U postfix -u postfix u

How to show all processes for a specific user using top/htop

The syntax is pretty simple to see all processes created by a user named vivek:
top -U vivek

Linux list processes by user name using top command

Linux show all processes created and used by a user named ‘vivek’ using htop

How to display user ID associated with a process

Another option is to use the combination of ps command and grep command/egrep command:
sudo ps -ef | grep
sudo ps -efl | grep
sudo ps -efl | grep vivek
sudo ps -ef | grep nginx
sudo ps -efl | grep ‘www-data’

The www-data user ID associated with a Linux process named lighttpd, nginx, and php-fpm.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

  • -l : Long format
  • -a : Show command line args
  • -p : Display Linux PIDs
  • -s : See parents of the selected process

The pgrep command

The pgrep command can look up processes based on usernames. The syntax is:
### Only match processes whose Linux effective user ID (euid) is listed ###
pgrep -u euid
### Only match processes whose effective user ID (uid) is listed ##
pgrep -U uid
pgrep -l -u vivek
pgrep -l -U www-data

Conclusion

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Linux find process by name

Procedure to find process by name on Linux

  1. Open the terminal application.
  2. Type the pidof command as follows to find PID for firefox process:
    pidof firefox
  3. Or use the ps command along with grep command as follows:
    ps aux | grep -i firefox
  4. To look up or signal processes based on name use:

pgrep firefox

Linux find process by name using pgrep command

pgrep command looks through the currently running processes and lists the process IDs which match the selection criteria to screen. All the criteria have to match. For example, will only list the processes called sshd AND owned by root user:
$ pgrep -u root sshd
Just look up pid for firefox process:
$ pgrep firefox

How to use ‘ps aux | grep command’

ps command shows information about a selection of the active processes:
$ ps aux
$ ps aux | grep -i ‘search-term’
$ ps aux | grep ‘firefox’
$ ps aux | grep ‘sshd’
OR use the following syntax instead of using egrep command in pipes:
$ ps -fC firefox
$ ps -fC chrome
The -C option asks ps command to select PIDs by command name.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Using pidof command to grab PIDs for any named program on Linux

The pidof command finds the process id’s (pids) of the named programs such as sshd, firefox and more. For example:
$ pidof sshd
$ pidof firefox
Sample outputs:

A note about top/htop command

To display Linux processes use top command or htop command:
$ top
OR
$ htop

See also

Getting more help

Read the man pages for the following command using man command:
$ man pgrep
$ man pidof
$ man ps

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How to Find a Process Name Using PID Number in Linux

In this article, we will look at how to find a process name by 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 process holds execution details of the program in memory such as its input and output data, variables and so on.

Importantly, since Linux is a multitasking operating system, it executes several programs simultaneously, and this means each process process must be identified specifically.

The kernel identifies each process using a process ID (PID), a every instance of process must have a unique PID from other processes which is assigned when the process is invoked, to avoid any execution errors.

The /proc file system stores information about currently running processes on your system, it contains directories for each process.

Use the ls command to list its contents, however, the list may be long, so employ a pipeline and the less utility to view the /proc contents in a more convenient way as below:

From the screenshot above, the numbered directories store information files about the processes in execution, where each number corresponds to a PID.

Below is the list of files for systemd process with PID 1:

You can monitor processes and their PIDs using traditional Linux commands such as ps, top and relatively new glances command plus many more as in the examples below:

Monitor Linux processes using traditional top command.

Monitor Linux Processes with top Command

Monitor Linux processes using glances, a new real-time process monitoring tool for Linux.

Glances – Real Time Linux Processes Monitoring

Find Out Process PID Number

To find out the PID of a process, you can use pidof , a simple command to print out the PID of a process:

Find Linux Process PID

Coming back to our point of focus, assuming you already know the PID of a process, you can print its name using the command form below:

  1. -p specifies the PID
  2. -o format enables a user-defined format

Find Out Process Name Using PID Number

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 comm= which means command name, same as the process name.

Find Linux Process Name

For additional usage information and options, look through the ps man page.

If you want to kill a process using its PID number, I suggest you to read Find and Kill Linux Processes Using its PID.

Thats it for the moment, if you know any other better way to find out a process name using PID, do share with us via our comment section below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Читайте также:  Как узнать чем загружен диск windows 10
Оцените статью