How to Keep Your Linux System Up to Date With Topgrade
Updating a Linux machine is a tedious task. One that requires running a series of commands to run everything from system items to third-party packages and tools on the latest version.
But luckily, like most things on Linux, there is a tool that makes this process easier too. It’s called Topgrade and it lets you upgrade your entire system with a single command.
Follow us as we take a detailed look at Topgrade and show you how you can use it to keep your Linux system up to date.
what is top
Topgrade is a CLI utility that allows you to upgrade your Linux system without actually going through the upgrade process, which usually involves running a series of commands. Here’s how it works: when you go to Topgrade in the terminal, it will identify all the tools installed on your system and run the appropriate commands on your behalf to update them.
What can Topgrade update?
Topgrade works on most Linux distributions: Debian, Red Hat, Arch Linux, openSUSE, Gentoo, Clear Linux and Void Linux. In addition, it also supports third-party package managers like Snap and Flatpak.
So if you’re running one of these distributions on your system, or have one of the supported third-party package managers installed, Topgrade will handle their updates for you. Similarly, if you run Topgrade, it can identify and update tmux, Flutter SDK, pip, Vim/Neovim, Node, and Pi-hole, among several other package managers.
How to install Topgrade on Linux
You can install Topgrade using Rust’s Cargo package manager. But first you need to install Cargo (and some of its dependencies) on your system. If you already have it installed, you can skip this step and continue installing Topgrade.
To install Cargo on Linux, open the terminal and run the following command:
sudo apt install cargo libssl-dev pkg-config
Next, after installing Cargo, you can install Topgrade with this command:
cargo install topgrade
Once the installation is complete, you will see an on-screen warning prompting you to add the path for Topgrade to your $PATH variable so you can use it from anywhere on the system.
Check out our guide to setting the $PATH variable on Linux to find out how to do it correctly. Alternatively, if you only want to use topgrade once, you can add it to the $PATH variable like this:
export PATH=$PATH:/home/username/.cargo/bin
How to use Topgrade to update anything on Linux
As mentioned, Topgrade works pretty much on its own. As soon as you invoke it, it automatically identifies and updates packages that are installed on your computer.
Therefore, using Topgrade is incredibly easy. All you have to do is run a simple command and respond to the confirmation prompts when they appear in the terminal. Additionally, some packages and utilities also require you to enter your system password to authenticate the operation.
To update your system with Topgrade, open the terminal and run this command:
topgrade
When prompted to confirm an update, press Y for yes and N for no. Topgrade will now run a series of commands. Sit back and let the packages finish updating.
If you want to stop, press Ctrl + C and enter q.
Exclude packages from update
Because the topgrade command essentially upgrades the entire system, it takes a while to complete the process. To get around this, you can use Topgrade to exclude certain packages from updating, so you can prevent Topgrade from updating them with the rest of the packages.
Suppose you don’t want Topgrade to update the vim package on your system. To do this, you can simply use the –deactivate flag and run the command as follows:
topgrade
View which packages are updated on your system
Before entering Topgrade, you can view a summary of all packages on your computer that will be upgraded during the process.
To do this, open the terminal and run:
topgrade
Clean up temporary or old files
Besides updating your Linux system, one of the things you can do with Topgrade is to clean up the temporary or old files that you have on your computer. Not only does this free up disk space, but it also reduces the risk of your system or its programs encountering errors or bugs.
To use Topgrade to clean temporary or old files, run:
topgrade
If asked for a password, enter your admin password and press Enter. You may also be asked to confirm certain file deletions. Press Y and hit Enter Continue.
Get detailed information about an operation
Like many CLI-based programs, Topgrade gives you the – detailed Option to view detailed information about the running process. If you want to see how Topgrade updates the packages, you can do so by running this command:
topgrade
Update a specific package
Occasionally you may only want to update certain packages. In such situations, you can use the –only Option to update a specific package. The command looks like this:
topgrade --only package
For example:
topgrade
Edit the topgrade configuration file
Similar to other Linux programs, Topgrade also has a configuration file that tells the program how to work, what operations to perform, and so on.
While Topgrade offers certain options that allow you to do this explicitly from the terminal, you can also modify the configuration file to make these changes permanent. That way you don’t have to do it yourself every time you run the command.
To edit the topgrade configuration file, run this in a terminal window:
topgrade
If this opens the configuration file, you can change (change, add, remove) values associated with various actions. To enable an action, comment out the line by removing the lb Sign (#).
Similarly, the file also contains custom commands and precommands. If you want Topgrade to run a custom command when you run it, you can add that command to the Custom Commands Section.
On the other hand, if there’s a command you want the program to run before anything else, type it in Commands to be executed before anything Section. When you are finished making changes to the configuration file, save and close it.
Simplify the boring Linux system update process
Topgrade is one of those tools that you wish you knew about sooner. It’s easy to use and offers the easiest way to automate Linux system updates to save the time and effort of doing the process manually.
One of the best times to use Topgrade is when you’re not actively using your computer, as you can run the program and exit while it updates the system.
However, Topgrade has some limitations that limit its use with scripts or even some advanced operations with custom commands. However, for most users, Topgrade can be extremely useful.
If certain packages are causing problems on your system and updating them still doesn’t fix the problem, they are probably broken and you may need to intervene and fix them manually.