In this guide, we're going to explore an interesting tool that aims at making updates of everything installed on your system as easy as just running one command. This software is topgrade, it detects the tools you use on your system and run appropriate package manager to update packages.
On RHEL family Linux distributions like CentOS, topgrade will execute the yum upgrade
command, this is dnf upgrade
for Fedora. On Debian family, the equivalent command executed by topgrade to ensure everything is up to date is apt update && apt dist-upgrade
. On Arch Linux, it will use run yay or fall back to pacman
if yay is not installed.
If you don't have yay AUR helper installed on Arch Linux, install it by cloning the PKGBUILD and building with makepkg.
git clone https://aur.archlinux.org/yay.git cd yay makepkg -si
By just running a single topgrade command, it will also do an update of the following:
- Upgrade Atom packages
- Update Flatpak packages on Linux
- Update snap packages on Linux
- Run fwupdmgr to show firmware upgrade.
- Upgrade Emacs packages
- Run Cargo install-update
- Run.
brew update && brew upgrade
. This should handle both Homebrew and Linuxbrew on Unix. - Run zplug update on Unix
- Unix: Run fisherman update
- Upgrade tmux plugins with TPM
- Upgrade Vim/Neovim packages.
Installing topgrade on Linux
Installation of topgrade on Linux can be done by pulling a pre-compiled binary file or using cargo install. If you are running Arch Linux as your primary operating system, you can install topgrade from AUR:
$ yaourt -S topgrade
For all other Operating systems, navigate to topgrade releases page and download the latest release. As of this writing, the latest release is v0.9.0
$ export ver="v0.9.0" $ wget https://github.com/r-darwish/topgrade/releases/download/${ver}/topgrade-${ver}-x86_64-unknown-linux-gnu.tar.gz
For macOS users, download the package with the name apple-darwin.tar.gz
Uncompress the package to get the binary file:
$ tar xvf topgrade-${ver}x86_64-unknown-linux-gnu.tar.gz
Move extracted binary to /usr/local/bin
$ sudo mv topgrade /usr/local/bin/
Confirm topgrade binary location:
$ which topgrade /usr/local/bin/topgrade
Using topgrade to update system packages
Once the package has been installed, you can easily use it by invoking the name on the terminal:
$ topgrade --help Topgrade 0.9.0 Upgrade all the things USAGE: topgrade [FLAGS] FLAGS: -h, --help Prints help information -t, --tmux Invoke inside tmux -V, --version Prints version information
Simply type topgrade on your terminal and it will start updating and upgrading installed packages.
$ topgrade
If sudo privileges are required, you will be prompted for sudo password. Since I have oh-my-zsh
it was also updated.
Running topgrade in a tmux session
It is recommended to leave topgrade running in tmux
session to avoid accidental human interruption or network timeouts, especially when working on a remote system. For this use:
$ topgrade -t
If you don't have tmux installed, you can get it using your OS package manager:
On Ubuntu:
$ sudo apt-get install tmux
On CentOS / Fedora:
$ sudo yum install tmux $ sudo dnf install tmux
On Arch Linux, use:
$ sudo pacman -S tmux
Customizing topgrade
You can place a configuration file at ~/.config/topgrade.toml
. Here's an example:
git_repos = [ "~/dev/topgrade", ] [pre_commands] "Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak" [commands] "Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter"
In this example:
- git_repos - A list of custom Git repositories to pull
- pre_commands - Commands to execute before starting any action
- commands - Custom upgrade steps.
Read also
- How to Exclude Specific Packages from Yum Update
- How to Upgrade Individual Packages in Ubuntu/CentOS
- How to Install Packages on Arch Linux
Topgrade seems to be a must-have Sysadmin tool for managing updates across a cluster of servers you administer daily. The fact that you can have it run in a tmux session by just using -t flag, keeps updates safer by ensuring they finish gracefully. Give it a try and let us know how you liking it through our comment section.