How to Install and Use btop on Ubuntu 20.04
Introduction
This tutorial explains how to install btop on Ubuntu 20.04.
btop (also known as btop++) is a customizable command-line utility for resource monitoring, which is very customizable with different themes and options. It shows usage statistics for processors, memory, disks, network devices, and processes. btop is a continuation of bpytop and bashtop. The former is written in Python, and the latter is written in Bash. The latest version, btop, is written in C++.
Prerequisites
Before you begin, you should:
- Deploy an Ubuntu 20.04 server.
- Update the server.
- Create a non-root user with sudo privileges.
- Log in to your server as a non-root user.
Installation
Install
btop
usingsnap
.$ sudo snap install btop
Start btop by running
btop
.$ btop
You have now successfully installed btop and should see the resource graphs and process list populating.
If you don't see a particular resource or get an error, connect the following interfaces by running each command below.
$ sudo snap connect btop:system-observe $ sudo snap connect btop:physical-memory-observe $ sudo snap connect btop:mount-observe $ sudo snap connect btop:hardware-observe $ sudo snap connect btop:network-observe $ sudo snap connect btop:process-control
Usage
General
You can navigate btop using a mouse or keyboard. While using a keyboard, you can use the arrow keys and Enter to navigate and select menu items. Pressing the Esc or M key will show the main menu. You can use this menu to change options, view help or controls, and exit btop. Using the Ctrl + C interrupt command or pressing Q will exit btop.
You may notice that certain highlighted letters are in the titles of each panel. These letters correspond to the key you can press to control that option. For example, pressing the letter p in preset (the P key) will swap between the configured presets. You can also use the mouse to click on the highlighted letters. Swap back to the default preset once you have tried that out (preset 0).
CPU Panel
The small section of the right of the CPU panel shows the number of cores (C0, C1, C2, etc.), the frequency, the load average (LAV), and the processor name. If available, it will also show the current temperature for the CPU and each of its cores. The large section that slowly populates is the CPU usage graph. The graph shows usage over time, with bigger spikes representing more usage. The refresh rate is in the top right corner. It can be increased or decreased with Plus and Dash. It would be best to keep it at the default value for the best performance.
Other helpful information, such as the current time, is at the top of the CPU panel. The system's uptime is also at the bottom left of the panel. You can toggle the CPU panel by pressing 1 on the keyboard.
Memory Panel
The memory panel at the left of the screen below the CPU panel shows the memory currently used, available, cached, and free. The total amount of memory available is at the top right of the memory panel. It also shows colored graphs, which can help detect a spike in memory usage.
On the right of the memory panel is also a list of disks and hard drives. Depending on your configuration, it may show you the input/output speeds (I/O, or just IO), how full it is, and how much space is left for each disk. If I/O is supported, you can press I to toggle between showing it or not. Pressing the D key hides the disk list, allowing for more extensive memory graphs. You can toggle the entire memory panel by pressing 2 on the keyboard.
Network Panel
The network panel shows you the network interfaces and their current speed. There is also a duel graph for both download and upload speeds. The downloads represent the top half, and the uploads represent the bottom half. The data transfer per second, the top data speed, and the total data transferred for both download and upload are on the right side.
The IP shown is the server's private IP address. The grey text at the bottom left corner indicates the graph's scale of both download and uploads, measured in Kibibytes. Depending on your current network usage, the graph may auto-scale to show you more information. For example, if your upload usage is higher than your download usage, btop will zoom out the upload graph to show more. To synchronize the automatic scaling, you can press the Y key to sync the graph. Syncing the graph zooms it in more and scales both download and upload in the same way. The A key will turn off auto-scaling altogether.
Pressing Z to "zero" out the total network usage numbers will swap between the total data used and the data used in the current btop session. To switch between network devices and the local area network (lo for local), you can press B or N. You can toggle the network panel by pressing 3 on the keyboard.
Process Panel
You can use the process panel to view current processes, information about them, and send a signal to them. As mentioned before, you can use a mouse or the arrow keys to navigate and select menu items. Each process also lists the process ID (Pid), the program name, the execution command, how many threads it has, the user who created it, the memory usage, and the CPU usage.
Pressing F will allow you to filter through processes by entering any part of the process (such as the Pid, command, user etc.). You can clear it by using the Delete or Esc key. The C key will allow you to sort processes per-core, and the R key will reverse the current process list. You can toggle tree view mode by pressing E, which lets you see which process created each child process in a tree view. Using the Left and Right arrow keys allows you to sort by things like the memory usage, CPU usage, and the process name.
When selecting a process, you can press Enter or click it to view more information about it. It shows the CPU usage in a graph, the process' status, the I/O write and read speeds, the parent process, a memory graph, and all the other information covered before. When viewing more information about a process or just selecting it in the process list, you can press T to terminate the process, K to kill the process, or S to send a signal to the process. Please note that you may lose or corrupt some data when terminating, killing, or sending a specific signal to a process. You can hide the information panel for a particular process by pressing Enter again. The total number of processes are also shown at the bottom right. You can toggle the process panel by pressing 4 on the keyboard.
Menu
Options
You can access the options menu by pressing the Esc or M key, and pressing Enter to select the Options menu. You can change many options to customize your experience with btop.
In the general tab, you can set the color theme you would like to use by using the arrow keys. If you would like to create a theme, see the documentation on adding different btop themes. Other options in the general tab include:
- Toggling theme background
- TrueColor
- Vim keys
- Presets
- Shown panels
- Refresh rate (in milliseconds)
- Rounded corners
- Graph symbols to use for graphs
- Clock formatting
To navigate to other tabs, hit the Tab button, the corresponding number of the tab on your keyboard, or use the mouse. Each tab contains miscellaneous options for each resource panel. Some standard settings include:
- Panel location
- An override for graph symbols to use for graphs
Help
You can access the help menu in the main menu by pressing H or selecting Help with Enter. The help menu shows each key, what it does, and the current version of btop.
Additional Information
You now can successfully use btop to monitor resource usage for your system. For more information on btop, see the links below.