Using the top command to display information
The top command and the program htop can help you view the currently running processes on your server. It’s useful for finding scripts or programs that might be running on your server and also useful if your server is experiencing issues like slow webpage loading or other resource issues. Top is installed by default but htop is a separate program which needs to be installed. We will detail how to install htop later on.
Top has a range of shortcuts that display the information in different orders. Consult the table below for the different shortcuts available.
The most common shortcut is top -c and nine times out of ten if you are having trouble with a server by using this shortcut you can determine what the problems is and then decide on the best way forward.
There is a lot of information listed on the top screen and we are going to point out the basics when using the top -c shortcut. Below is a screenshot from one of our KVM NVMe hosts. It’s powering a range of VPS servers for our customers from Windows servers and desktops to Ubuntu and CentOS servers.
From the information we can see;
- The Uptime of the host. This one has been online for 163 days.
- The server load in 1 minute, 5 minute and 15-minute intervals.
- This is how much of your CPU power is currently not being used.
- The wait time. This is how long a process has to wait before being finished.
- CPU Usage. The percentage of the total CPU you are using.
- Memory usage, how much physical memory, swap and cache you are using and have free. You can use free -m for memory usage.
Below this information, you can see the currently running processes and containers on the server. As this is KVM we do not see what individual processes are being run. We simply see the container mounted and resource usage. For a more detailed explanation on top and the full range of commands you can check the manual under man top.
Installing And Using Htop
Htop is much the same as top but the information is displayed in a more graphical way. if you want to use htop then first you will need to install htop;
Install htop on CentOS 7 or CentOS 8
CentOS 8 yum install epel-release dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm yum install htop CentOS 7 yum install epel-release yum install htop
To install htop on Ubuntu or debian
apt-get install htop
Once installed issue the htop command and you will be presented with the htop screen.
How was this article?
You might also like
More from All About Linux
How to install FTP and configure FTP on an Ubuntu 22 LTS instance
If you need to upload files to your NVMe VPS you have a couple of options. You can use a …
How to install a Cloudflare Origin SSL Certificate – NGINX
An SSL Certificate is vital to encrypt data between you and your clients. SSLs can be complicated things. If they …
How To Open Port FirewallD and Close Port FirewallD -CentOS 7
Open And Close Ports In FirewallD - Manage Zones In FirewallD Like IPtables, FirewallD is a Linux firewall that filters packets …
[…] a process in Linux suggests you likely already know what you want to terminate. You can use the top screen or ps -a to list all the processes running on the server. top -c is good if you don’t […]