Count The Number Of Running Processes Per User

This won’t be as complicated as it seems because we’re just going to cover how to count the number of running processes per user. This is a fairly basic task that requires fairly basic tools. If you want to count the number of running processes per user, read on! It’s quite simple…

Your Linux system requires many running processes. A running process is an application, though some applications can have multiple running processes. The Linux kernel manages processes and a full desktop system will require hundreds of processes to be complete.

Processes are on a per-user basis. As explained before, Linux is a true multi-user operating system. Each user will have their processes and all processes will be owned by a user. It’s a pretty basic concept once you get your head around it.

You won’t need to install anything for this article. We will use some basic tools to show you how to count the number of running processes per user. This isn’t an advanced operation and you’ll almost certainly have the correct tools installed.

What tools will you need for this article?

ps:

The first tool you’re going to use is the ‘ps’ application. Don’t worry, the application is installed by default. You can confirm this with this command:

which ps

Additionally, you can check the man page with this command:

man ps

If you do that, you’ll see that this is the correct tool for listing the running processes in your Linux system. It’s described like so:

ps – report a snapshot of the current processes.

See? That’d be the correct tool for listing the currently running processes.

We’ll also use…

wc:

This too will not require any additional software. It’s a near-certainty that the wc command is included in your Linux operating system by default. You can confirm that wc exists with this command:

which wc

When it comes to counting things, the wc command is the go-to command. You can tell this by checking the man page with this command:

man wc

As you’ll see, the wc command is described like so:

wc – print newline, word, and byte counts for each file

So, wc is the correct tool. We’ll use the -l flag (count lines) to go along with the wc command, meaning this should be something you can figure out already without me needing to write the rest of the article! Linux isn’t all that difficult to work with and the terminal doesn’t have to be a complicated affair.

Count The Number Of Running Processes Per User:

Both the ps and wc commands are terminal-based commands. That means you’ll need an open terminal to count the number of running processes per user. You can usually open a terminal by pressing CTRL + ALT + T. If that doesn’t work, open one from the application menu.

With your terminal open, you can show the number of running processes with the following command:

ps -e

That’s the first part of this exercise. 

Next, we’ll use a pipe. We’ll pipe the output from that command to the wc command and tell the wc command to count the lines. That’s done like this:

ps -e | wc -l

That will give you a count of all the running processes which is nice but not the goal of this article. This article is meant to show you how to count the number of running processes per user.

So then, let’s show you how to show the processes owned by a user…

ps -U <user_name>

For example, I’d find processes owned by me with this command:

ps -U kgiii

Now, to count the number of running processes per user you just go ahead and pipe it to the wc command used above, like so:

ps -U <user_name> | wc -l

Again, an example:

ps -U root | wc -l

That command should show you all the running processes that are owned by root. It’s a pretty easy set of commands to figure out and I’m sure you can figure it out from here…

Closure:

Well, we set out to learn how to count the number of running processes per user. I’d like to think we accomplished that goal. You never know when you’ll want to see the processes owned by a user, but it could be useful when debugging things – like finding out what’s eating up your resources.

This is one of those commands that are pretty obvious once you know about it. They’re two simple commands that combine to create a pretty good result. Linux is like that. You don’t always need to know some esoteric commands. You can often combine some basic commands to get the output you’re after. You can achieve much with just a few basic commands and it’s good to get more comfortable doing so.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

5 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

5 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

6 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

6 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

6 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

6 months ago