How do I count how many processes are running in Linux?

How do I see how many processes are running in Linux? How can count all running processes in Linux?

A Linux process is nothing but running instance of a program or command. This page explains various commands to count the number of processes running in Linux.

Viewing running processes in Linux

The ps command used to list the currently running processes and their PIDs in Linux and Unix-like systems. At a bare minimum, two processes displayed on the screen. For example, bash and ps might default on Linux when you just type ps command ps
Sample outputs:

  PID TTY          TIME CMD
31043 pts/3    00:00:00 bash
32324 pts/3    00:00:00 ps

Counts for each file in Linux

The wc is an acronym for word count. By default, wc command counts the number of lines, words, and characters in the text. For examples, show the newline counts
echo "line 1" | wc -l
To print the byte counts
echo "Hello" | wc -c
One can print the word counts as follows:
echo "Hello world" | wc -w
Command to count the number of processes running in Linux

Find how many processes are running in Linux

One can use the ps command along with with the wc command to count the number of processes running on your Linux based system by any user. It is best to run the following commands as root user using the sudo command.

Command to count the number of processes running in Linux

The Linux syntax is as follows:
# ps -e | wc -l
To see and count every process on the system using BSD syntax:
# ps axu | wc -l
Want to see and count every process running as vivek (real and effective ID) in user format, run:
$ ps -U vivek -u vivek u | wc -l
Another example for www-data user:
$ ps -U www-data -u www-data u | wc -l
In short to see and count only processes by a certain user naned root, you can use the following command:
sudo ps -U root | wc -l
sudo ps -U root -u root u | wc -l

Next we are going count process IDs of nginx using the following syntax:
ps -C nginx | wc -l
ps -C nginx -o pid= | wc -l

See how many processes are running in Linux
Pass the --no-headers or --no-heading to print no header line at all to get processes count correctly on Linux:
# ps -e --no-headers | wc -l
# ps -e | wc -l

When count real number of nginx it is a good idea to remove grep command while grepping using ps command:
ps -e --no-headers | grep [n]ginx
ps -e --no-headers | grep [n]ginx | wc -l

Understanding the wc command options

wc option description
-c Print the byte counts
-m Print the character counts
-l Print the newline counts
-w print the word counts
--help Display the wc command help and exit

Understanding the ps command options

ps option description
-e Select all processes (GNU/Linux syntax)
aux Select all processes using BSD syntax
-U user Select by real user ID (RUID) or name
-u user Select by effective user ID (EUID) or name
-C cmdlist Select by command name. This selects the processes whose executable name is given in cmdlist
--no-headers Print no header line at all. --no-heading is an alias for this option


You learned how to list the number of processes running on the Linux or Unix like system using various command-line options. See the gnu ps help page here.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum