How to Check Running Processes in Linux

Photo by Ilya Pavlov on Unsplash

Processes, commands, software – many of us are constantly running any number of applications and processes at the same time. Maybe you like to listen to music while you’re on your video call and you have 4 other systems going and processes on all of them.

We get it. Multi-tasking is simply the way of the future for many of us. But here’s the thing: sometimes we get processes going in multiple different places and we don’t want to babysit those processes.

Running processes in Linux is perhaps one of the best ways to manage and check your running processes. Of course, in order to do so, you need to be familiar with the process to use Linux and just how exactly it works.

How to See Running Processes in Linux

In Linux, every process will have a unique process identification number (PID). The processes begin when a command is executed within the system. These processes can be run in the background or possibly the foreground.

In most cases in Linux, programs start out as a foreground process. This is basically the default. However, a process can be moved to the background, even while it is running. When you move a process to the background, it allows you to do other things and execute other commands while the process is running.

With Linux, you can see the running processes. You can also manage those processes; if you need to stop one or maybe reallocate how they are working on the system, you can do all of that too. There are commands for these things.

For now, let’s start by talking about how you can see the list of running processes in Linux.

Use the “PS” Command

To see your list of processes in Linux, use a PS command. PS stands for process statuses.

When you use the PS command, you see a listing of all of the processes that are currently operating in Linux. Think of it almost like a Windows Task Manager. The biggest difference is that the command is a snapshot of a specific point in time when you hit the command. So, when the status of a process changes, the PS command doesn’t reflect that in your snapshot.

You can run the PS command repeatedly to see updated statuses or at least see the running processes, but those statuses will not update within your command snapshot.

Use “PS Aux” Command

If you want something more detailed than just the snapshot, the PS Aux command is more detailed than PS. Here’s a breakdown of the command functions.

  • PS still stands for process statuses
  • A refers to all users so you get all PS for all users
  • U tells you how much memory or usage is taking place from each process
  • X will tell you if any of the processes are automatic and not something initiated on an individual’s terminal

You can also get those same results but get the Linux list processes sorted in a hierarchical view. That command is ps -axjf. It gives you the same data, but if there is a parent process and a child process, it groups those things together for you.

Additional Commands for Linux List Processes

There are a couple of other commands that you can use as well. They all give you similar data, but you might be able to sort it out or view something specific. Check these out.

  • ps –T will tell you just the processes statuses that were initiated specifically on a terminal
  • ps –e will get running processes in Linux that are just a generic list in UNIX formatting
  • ps –u [username] allows you to see the processes tied to the username
  • ps –c process_name gives you specific processes based on the name of your command

Photo by Kevin Ku on Unsplash

How to List Running Processes in Linux

You can use the command above as a quick snapshot to see the running programs in Linux, but it simply doesn’t give you much detail when you do it that way. It’s limited, but it can be a good resource if you just want a quick check of running processes in Linux.

Of course, you can also resort to some more functional lists like these.

Using “pgrep” Command in Linux

The pgrep command comes from UNIX systems. It’s basically a command that is considered to be a command-line utility. You can find the IDs of any given process using a specific set of criteria.

This includes adding partial names of the process, adding a user running said process, or any other searchable criteria of the process.

When you enter the pgrep command with that criteria, Linux finds the associated processes that are running.

Using “top” Command in Linux

The top command is a very popular command to see the Linux list of processes. This command will let you know which processes are hoarding the resources.

You know what we mean: those processes that eat up resources and dramatically slow down or hinder other processes that are running. When you run the command, the list you get puts the processes using the most CPUs at the top.

It’s then sorted in that manner from the highest CPU usage to the lowest CPU usage. You can easily and quickly spot the commands that are hogging resources.

The unique difference in this command compared to the commands we mentioned above is that it does update within the returned results of your command. It updates in real time, so if a process finishes or stops using so many resources, it will update on your list.

This command list also allows you to interact. Here are the keys and interactions for the top command.

  • c – gives you the complete path of the process
  • d – will update how often the list will refresh
  • h – provides you with a help window
  • k – will kill a process right here (no kill command needed!)
  • M – sorts your list based on usage
  • N – sorts your list based on PID
  • r – updates your priority (no complicated renice commands needed!)
  • z – Highlights the running processes or changes their colors for you
  • Ctrl+C or q will stop the top command and close it out

These function keys are case-sensitive, so take note of that.

Using “htop” Command in Linux

The "htop" command is very similar to your top command. However, you will find that htop command is more user-friendly and actually allows you to do quite a bit more within the command results, as opposed to top command.

You can scroll through it in both directions and you can make changes or even kill Linux system processes within the htop command. You can also change priority and insert PIDs if you want to.

Here’s the thing: you won’t find this command readily available. In most cases, it has to be manually installed within Linux before it will be available to you to use. This can be a nuisance, but it’s worth the installation process.

How you install htop command will most likely depend on which system you are using. The nice thing is that once you have htop command capability, you can use the extra functions and you can still use the interactive functions just like with the top command.

These functions are through your function keys on the keyboard instead of a specific letter. Here is the breakdown for those.

  • F1 – provides you a help menu
  • F2 – opens the setup menu for htop command
  • F3 – allows you to search for a specific process
  • F4 – sorts your processes by their names
  • F5 – lines up processes in a tree view with parent and child grouped together
  • F6 – sorts the process by any column of your choice within the htop screen
  • F7 – changes the priority of processes by decreasing priority (no renice coding needed)
  • F8 – changes the priority of processes by increasing priority (no renice coding needed)
  • F9 – allows you to kill a process (no kill coding required)

If you use the htop command, make yourself a cheat sheet or commit these to memory. It will make your Linux list processes management so much easier!

Using “kill” Command in Linux

The kill command is almost self-explanatory. Use the kill command to force a process to shut down, or to kill the process. This command is a little bit more detailed, because you first need to get the PID from one of your other commands, unless you already know it.

Then, you can use this simple command with the word "kill" to shut it down.

So your command is kill [PID].

When you put this in, the system ties the PID of the process to your kill command and forces it closed. Again, you can compare this to a Windows Task Manager where you end a task, but it’s a different system for doing so.

Using “pkill” Command in Linux

If you don’t want to find the PID before you kill the process or perhaps you used a different Linux list processes command without the PID, you can kill a process with just the process name instead.

This command is similar to the pgrep that we discussed earlier, but it’s designed to kill a running process so it simply has a different use. This one is kind of nice because you only need the name of the process and not all of the other details.

The command for a pkill, which means process kill, is pkill [command]. In the event that you use this code, you will replace [command] with the word or the name of the process. You won’t need the parentheses either, so leave those off.

When you enter this command the running programs in Linux that match the command will kill or be shut down.

Using “killall” command in Linux

The killall command is very similar to the pkill command. In fact, it’s pretty much the exact same thing, but you use a different command code to kill the desired Linux system processes.

We will tell you that some processes can be finicky, so if the pkill command doesn’t work for one, just try a different tactic with this code, or vice versa.

The killall command doesn’t kill everything, just the process that you command and any children processes underneath it as well.

The command is killall [command]. In this command, you will again replace command and the parentheses with the name of the process you want to kill.

Using “nice” and renice” Command in Linux

The nice and renice commands are basically interchangeable. This command is designed to prioritize the running processes in Linux. It ultimately gives you full control if you want to reallocate resources or make one process a higher priority in the running processes.

Here, it will be helpful to know the running processes and first plan or know how you want to reorganize them.

The term nice refers to the value for the priority on the task. The values can be anywhere from -20 to 19. The lower the number the higher the priority, so if you want something to be the highest priority, you want it to be -20.

In order to reprioritize, you will renice the process. This means you’re going to change the nice value from whatever it is to whatever you want it to be within the allowable range of numbers.

Move your lower-priority processes to 19 and numbers near it and move higher-priority processes to -20 and numbers near to it.

You can set a code priority when you run a process, usually by establishing the nice number.

You can also change the priority when the process is running using the following steps and commands.

  • Determine whether your priority is negative or positive and code accordingly. Use renice [priority] [PID] for positive and renice [priority] –p [PID] for negative.
  • Then pgrep vim
  • Renice [priority] [PID]
  • Sudo renice [priority] [PID]

In each of these instances, you will replace the items in parentheses with the appropriate command. For example, priority is going to just be your number. Remember that the number needs to be between -20 and 19 here.

The PID is going to be your PID number for the process you are renicing through the commands. Chances are you will have multiple PID numbers or probably at least 2 that you are switching out and moving priority levels on, so be prepared with any PID numbers you might need.

Frequently Asked Questions

Photo by Jon Tyson on Unsplash

Here are a few additional questions that we see often. We hope they can be helpful to you!

Which Linux Command is Used to Manage Processes?

You can use several different commands, depending on how you would like to manage. We recommend using top or htop as the best management commands, as they give you the ability to reprioritize or kill the process from within your command screen.

You can also manage processes through any other commands we shared here.

How Do I Switch Processes in Linux?

You can easily switch between processes in Linux by using the Ctrl+Alt functionality and then using one of your function keys between F1 and F6. This allows you to move to a different process that is running in Linux in the background.

How Do You Check How Many Processes Are Running in Linux?

You can check the processes in Linux by using one of the list processes that we shared in this guide. Try using ps aux or even a top Linux command to see running processes. This is the easiest way to bring it up.

What is a Process and Its Types in Linux?

Linux will have different types of processes, such as daemon, kernel, and user processes. The majority of those are user processes that are initiated by a user on a terminal. Daemon processes are those that run automatically in the background as needed or when scheduled. A kernel process will automatically run when the system decides there are resources to handle it.

How Many Processes Run in Linux?

The number of processes running will depend on your utilization in Linux. Use a command like ps aux, top, or htop to see exactly what and how many processes are running at any given time.

Final Thoughts

Linux processes and managing and understanding them really is a straightforward subject when you know what to look for and which commands to use. Most of the commands for accessing data in Linux are simple and straightforward.

For example, killing a process is just kill and then the PID or process name. Renicing a process is probably one of the more complicated commands, but once you know how it works, it becomes easier.

With these tips for checking and managing your running processes, you shouldn’t have any troubles. We highly recommend using top and htop commands as much as possible to simplify the process.

Sign in to Client Area