How to use the linux top command

The Linux top command is the quickest way to see what your server is doing right now. It shows live RAM and CPU usage, load, and the processes running on your machine, which makes it ideal for monitoring a VPS or dedicated server. In this article, we will show you how to use the Linux top command and its most useful options.

Run the top command

First, connect over SSH and simply type:

top

The output updates in real time and shows a summary of RAM, CPU, and load at the top, followed by a live list of processes sorted by CPU usage. The three load numbers represent the average over the last one, five, and fifteen minutes, which helps you tell a brief spike from a sustained problem. Press q at any time to quit and return to the prompt.

View a specific user’s processes

Next, to focus on a single account, add the -u flag with a username:

top -u root

Handy keys inside top

While top is running, a few single-key shortcuts make it far more useful:

  • c – show the full command path of each process.
  • d – change the refresh delay (in seconds).
  • M – sort processes by memory usage.
  • P – sort processes by CPU usage (the default).
  • k – kill a process by entering its PID.

A friendlier alternative: htop

Finally, if it is available on your server, htop offers the same information with colors, scrolling, and mouse support. It is a great companion to the Linux top command when you want an easier overview.

Because top only reads information, it is safe to run any time – just be careful with the k key, since killing the wrong process can stop a service.

Need more help?

Explore more Linux commands with examples, or get the resources and root access to monitor everything yourself with a JetHost VPS.