# Linux Process Management: ps, htop, kill, and nice

> Linux has a sophisticated toolset to deal with processes in various circumstances from scripting, to monitoring, to control.

- Author: [Bhagwad Park](https://www.namehero.com/blog/author/bhagwad-park/)
- Published: 2026-01-07
- Updated: 2026-01-07
- Category: [Linux Command Line](https://www.namehero.com/blog/category/linux-command-line/), [Uncategorized](https://www.namehero.com/blog/category/uncategorized/), [VPS Hosting](https://www.namehero.com/blog/category/vps-hosting/)
- Web page: https://www.namehero.com/blog/linux-process-management-ps-htop-kill-and-nice/

As a Linux administrator, you will have your hands full keeping track of what’s happening with the server. You’ll have some long-running processes whose resource usage you’ll want to track, as well as shorter ones that can easily suck up all bandwidth if you let them. And of course, there’s the ever-present danger of malicious scripts, of which you need to be aware. So a lot is going on with processes, and not all tools have the same use-case scenario. We use some tools in a quick and dirty manner, others for scripting, others for real-time monitoring, and yet others for controlling processes. We also have tools that can assign priorities to processes, so let’s see what the various Linux tools are used for.

## Basic Process Viewing and Scripting – ps

The tool most associated with viewing Linux processes is “ps”. The “ps” tool is easy to use and generates a static text output of the currently running processes. One of the most common commands is:

```
ps aux
```

This generates the following output:
 [![ps aux](https://blogcdn.namehero.com/blog/wp-content/uploads/2026/01/05123732/image.png)](https://blogcdn.namehero.com/blog/wp-content/uploads/2026/01/05123732/image.png)ps aux

Here’s an explanation of the flags:

“a” is used to show the processes for all users. Without this, “ps” will only show the processes for the current session.

“u” will display the owner of the process

“x” shows us processes that are not attached to the terminal. For example, background processes and daemons fall into this category.

Note particularly that once the command completes, it returns to the shell prompt. This means that the output of “ps” is static, and doesn’t keep updating based on what’s happening. While this might seem like a disadvantage compared to other, more sophisticated tools like “htop”, it actually makes it extremely useful for scripting.

### Using “ps” for Scripting

Because the output of “ps” is plain text, it’s perfect for use in scripts, where you want to quickly know the status of a particular process. You can use [piped tools like “grep”](https://www.namehero.com/blog/how-to-use-the-pipe-command-in-linux/) to extract the information that you want, and also use options to only include the relevant fields. For example, look at this code:

pids=$(ps -u www-data -o pid=)

Included in a script, this will store a list of process ids belonging to the “www-data” user in the variable. This user is commonly used for web servers like Apache or NGINX. The “-o” flag tells the tool to only output the “pid” column with the process number, and the equal sign (=) indicates that you don’t want to output the name of the column. This makes it easy to parse the process IDs one by one. For example, something like this could work:

```
pids=$(ps -u www-data -o pid=)

for pid in $pids; do
    kill -9 $pid
done
```

This code will go through the list of pids returned by “ps” and kill each of them one by one. It’s a simple way to kill all the processes belonging to a certain user. You could also combine the entire operation into a single command like this:

```
ps -u www-data -o pid= | xargs kill -9
```

We’ve discussed before [how to use xargs](https://www.namehero.com/blog/how-to-use-the-xargs-command-in-linux/) to convert the output of a command into arguments, so this is a perfect example of how the command works.

This kind of manipulation is only possible because “ps” returns directly to the command line after completion, and its output is text-only.

But while other commands can’t be used in scripts like this, they can be very useful for monitoring, as we shall see.

## Using “top” and “htop”

Every Unix system includes the “top” tool, and it’s the classic command we use to monitor processes in real time in the system. Unlike “ps”, it doesn’t exit back to the command line immediately, but continues to update as things change.

Here’s a sample output from “top”:
 [![](https://blogcdn.namehero.com/blog/wp-content/uploads/2026/01/07123242/image-1.png)](https://blogcdn.namehero.com/blog/wp-content/uploads/2026/01/07123242/image-1.png)top Output

You can see that, unlike “ps”, the “top” command doesn’t return you to the command line. It’s a real-time monitoring tool that updates its status whenever something changes. So if a new process begins, it will be added to the list in front of your eyes. Similarly, the resource usage numbers will also keep updating.

The command “top” stands for “Table of Processes” , and it delivers. It’s ubiquitous, so you don’t need to install any new packages on your Linux server.

### Understanding the Load Average

On the top-right of the top command output, you’ll see a set of three numbers labeled “load average”. This is a complicated metric, measuring the number of runnable processes, and it’s meant to be compared with the number of cores on your system. The three numbers are the load for the past 1 minute, 5 minutes, and 15 minutes, reading from left to right.

If the load average number is greater than the number of cores on your system, the server is overloaded. Looking at the load average gives you an idea of how congested your system is. If you’re looking for a quick overview of how the system is doing, “top” is an excellent starting point. Most of the time, you won’t need to go beyond it.

### Even More Functionality with htop

While top is extremely useful, you can get even more value out of “htop”. This is a souped-up version of top, with a bunch of useful features such as the ability to scroll horizontally, use the mouse to make selections, and extensive filtering abilities, including being able to see a “tree-view” of processes.

Unfortunately, htop isn’t always available by default on Linux systems, so you’ll often have to install it manually using this if you’re on CentOS:

```
sudo dnf install htop
```

or if you’re on Ubuntu,

```
sudo apt-get install htop
```

Here’s a sample output of the htop command:
 [![](https://blogcdn.namehero.com/blog/wp-content/uploads/2026/01/07123243/image-2.png)](https://blogcdn.namehero.com/blog/wp-content/uploads/2026/01/07123243/image-2.png)htop on Linux

As you can see, it’s a lot more visually striking, and you perform intuitive actions like just clicking the column name to sort, etc.

## The “kill” Command

The above two tools – ps and top – are used to monitor system resources, but the kill command is used to control them. I won’t go into too many details, because we have a [comprehensive tutorial on the kill command](https://www.namehero.com/blog/the-scroll-of-processes-deciphering-linuxs-kill-command/) on the NameHero website. But note that with the “htop” command, you can also end processes by scrolling down or selecting the one you want, and hitting “F9”. Hitting “k” will also allow you to select the exact signal you want, so you can choose to outright kill a process, instead of asking it politely.

So really, “htop” is an “all-in-one” command that incorporates the best parts of both “ps”, “top”, and “kill”. But kill still has a few tricks up its sleeve, including bulk terminations of all processes involving a user. So don’t ignore your “kill” skills just yet!

## Conclusion

Linux has a whole range of process management tools, falling into two categories. The first category is tools like “ps” and “top”, which give you the status of the process. They don’t actually change anything. The second type of tool is like “kill”, which allows you to control which processes run. You can even change the priority of certain processes using tools like “nice” and “renice”, and I’ll cover that in another tutorial. But if you can just get used to using “top” and “kill”, you’ll already have a great handle on managing Linux processes.

## Related posts

- [The Scroll of Processes: Deciphering Linux’s Kill Command](https://www.namehero.com/blog/the-scroll-of-processes-deciphering-linuxs-kill-command/)
- [Listing Users And Basic User Management In Linux](https://www.namehero.com/blog/listing-users-and-basic-user-management-in-linux/)
- [Curl Headers, Cookies, and Authentication](https://www.namehero.com/blog/curl-headers-cookies-and-authentication/)
