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:

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

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:

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:

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:

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:

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…

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

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:

Again, an example:

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.

View Some Logs In The Terminal

Today we’ll have a relatively simple set of commands that will show you how to view some system logs in the terminal. We’re only going to cover a few of them that are similar in operation. There are far more things that get logged.

You generate logs as you use your computer. These will vary and there are quite a few logs kept. Logs aren’t just kept by the system. Some third-party applications create logs. We’ll only be covering a few system logs. I just want to keep things simple.

The tool we’re using for this exercise is the cat command. The cat application is one tool that lets you read text files in the terminal. It’s a frequently used tool at my house. Hopefully, you too will get comfortable using this command at your house.

It seems like that should be enough of an intro. If you have any questions, you can always leave a comment. Those get seen and addressed more quickly than when you try to contact me elsewhere. (Comments almost instantly send a notification to whatever computer I’m using. They’ll even ping my phone if I turn the notification sound on.)

Anyhow… Ask away, should you have any questions…

View Some System Logs In The Terminal:

We’ll be viewing a few different types of logs. As mentioned above and in the heading, this is something we do in the terminal. You can usually open a terminal by pressing CTRL + ALT + T. If that doesn’t work, you’ll almost certainly find a terminal in your application menu.

First, we’ll view the kernel log.

The kernel is the actual “Linux” in your Linux. The kernel deals with task scheduling, and running processes as needed. It’s an abstraction between you and the hardware.

If you want to view the current kernel log, use this command:

If you want to view the previous session’s kernel logs, use this command:

Both of those commands will flood your terminal. That’s okay, you can use the pipe operator and the less command like so:

Next, we’ll view the boot log.

When you boot your computer, the computer keeps track of what happens during that process. This is known as the boot log. It can be exceptionally handy when you have a problem booting. 

If you want to check the current boot log, use this command:

If you want to check the previous boot log, check it with this command:

Again, you can use a pipe and the less command to manage the flow of data.

Next, we’ll view the system log.

The system logs all sorts of additional information. If you’re not finding the information you want in the previous two logs, checking the system log is prudent. The system logs all sorts of things that are useful for resolving problems.

If you want to check the current system log, use this command:

If you want to check the previous system log, run this command:

Don’t forget that you can use a pipe and less in this command. This will give you a slower output you can manage with your arrow keys.

And that will show you your system log.

That’s all it takes to view the major system logs. There are other logs and we’ll have to cover them at some point.

Closure:

Well, this didn’t take too many words or too much time… That’s nice. If you want to start troubleshooting your own problems, learn to read the system logs. If you don’t want to ask for help, learn to read the system logs. Well, that and learn to read the man pages, but that last bit is outside the scope of this article.

I do hope you enjoyed this article. They’re fun to write but it does sometimes feel like work. I never wanted this to feel like it was work, but here we are. It probably would have been wiser to not set such a schedule and to allow some vacation time in there. This whole project started when I had far more time due to the pandemic.

We do have a special day coming up… You’ll see!

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.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.