Everything that is running on a Linux system – a service, script, or anything else – is considered a “process.” One of the core activities of a system administrator is that of monitoring and interacting with the processes running on a machine.
There are numerous command line methods that can be used in order to make it easier to check for certain processes. One such method is to check for processes that are running under a particular user.
As sever optimal use/maximization continues to grow, it becomes more and more important to manage processes well. In this tutorial, you will see a few different commands that can be used to check for running processes under a particular user in Linux.
In this tutorial you will learn:
- How to use
pscommand to list processes by user
- How to interpret
psoutput, and more command switches
- How to use
htopcommands to list processes by user
- How to install
htopon major Linux distros
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux system|
|Software||ps, top, htop|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Check running process in Linux for a user
As usual with all things on a Linux system, there is more than one way to accomplish the task we need to do. Check out some of the various commands below to see how to check for the processes running under a user.
ps command – list processes by user
ps command is a default command line utility that can give us insight into the processes that are currently running on a Linux system. It can give us a lot of helpful information about these processes, including their PID (process ID), TTY, the user running a command or application, and more.
Normally, we would use the
ps command with the following syntax:
$ ps aux
As you can see, there are quite a few columns in our output, and some of them may be cryptic to beginners. Let’s go over what each one means:
USER– The user who the process is running under.
PID– The process ID (every process is assigned a number as an ID).
%CPU– How much CPU percentage the process is utilizing.
%MEM– How much RAM percentage the process is utilizing.
VSZ– Virtual memory size of the process.
RSS– The physical memory size that the process is using.
TTY– Which TTY (terminal screen) the process is tied to, or
STAT– The state code of the process; there are many but some common ones are
START– The time when the process started.
TIME– The accumulated CPU time the process has used.
COMMAND– The full command that was used to spawn the running process.
However, we want to isolate only the processes owned by a certain user. In this case, we will append the
-U option and the name of the user whose processes we want to monitor. In this example, we will check for all the processes running under the
$ ps -U root
This is good, but if we want to see more information about the processes running, we can append another
u option. Furthermore, using
-u will allow us to specify the user’s real and effective user ID. The syntax for our
ps command now looks like this
$ ps -U root -u root u
As you can see from the screenshot, we get more detailed information about all the processes running under the root user.
top and htop commands – list processes by user
htopcommands can also be used to view all of the processes on our Linux system, as well as to see which user owns a process.
In the screenshot below, we can quickly see which processes are running under root and how many system resources they are consuming.
htop command (a more human readable form of the aforementioned command) is even more helpful because we can simply click on the
USER column to organize all the processes by each user.
In case you do not already have access to the
htop command on your system, uou can use the appropriate command below to install htop with your system’s package manager.
To install htop on Ubuntu, Debian, and Linux Mint:
$ sudo apt install htop
To install htop on Fedora, CentOS, AlmaLinux, and Red Hat:
$ sudo dnf install htop
To install htop on Arch Linux and Manjaro:
$ sudo pacman -S htop
More help and examples
We have more guides dedicated to managing running processes, in case you are interested. We recommend the following:
- How to use ps command in Linux: Beginners guide
- Learning Linux Commands: top
- Fundamentals of processes management on Linux
- How to Kill a Running Process on Linux
In this tutorial, we saw how to list the running processes on a Linux system by user. As usual with all things on a Linux system, there is more than one way to accomplish this task, such as with the
htopcommands seen in this tutorial.