As we all know already, keeping our Linux system up-to-date involves invoking more than one package manager. Say for instance, in Ubuntu you can't upgrade everything using "sudo apt update && sudo apt upgrade" command. This command will only upgrade the packages which are installed using APT package manager. There are chances that you might have installed some other applications using cargo, pip, npm, snap, flatpak or Linuxbrew package managers. You need to use the respective package manager in order to keep them all updated. Not anymore! Say hello to "topgrade", an utility to upgrade everything using a single command in one go.

You need not to run every package manager separately to update the packages. The topgrade tool resolves this problem by detecting the installed packages, tools, plugins and run their appropriate package manager to update everything in your Linux box with a single command. It is free, open source and written using Rust programming language. It supports GNU/Linux, Mac OS X, FreeBSD and Microsoft Windows.

Installing Topgrade

The topgrade is available in AUR. So, you can install it using Yay helper program in any Arch-based systems.

$ yay -S topgrade

On other Linux distributions, topgrade can be installed Cargo package manager. To install cargo package manager, refer the following link.

And, then run the following command to install topgrade:

$ cargo install topgrade

If cargo method doesn't work for any reason, download the latest topgrade binary from releases page. As of writing this guide, the latest version was 2.2.0.

$ wget https://github.com/r-darwish/topgrade/releases/download/v2.2.0/topgrade-v2.2.0-x86_64-unknown-linux-gnu.tar.gz

Extract the tar file:

$ tar xvf topgrade-v2.2.0-x86_64-unknown-linux-gnu.tar.gz

Copy or move the topgrade binary file to your path, for example /usr/local/bin/.

$ sudo mv topgrade /usr/local/bin/

Check if it is correctly installed as shown below.

$ which topgrade /usr/local/bin/topgrade

Check installed version:

$ topgrade -V Topgrade 2.2.0

Upgrade Everything Using Topgrade In Linux And Unix

Once installed, run topgrade utility to upgrade all the things in your Linux system.

$ topgrade

Once topgrade is invoked, it will perform the following tasks one by one depending upon the OS you use. You will be asked to enter root/sudo user password wherever necessary.

On Linux:

1. Run your Linux system's package manager and do the following operations:

Arch based : Run yay or fall back to pacman

: Run or fall back to Redhat based : Run yum upgrade (or dnf if present)

: Run (or if present) Debian based : Run apt update && apt dist-upgrade

: Run Gentoo : Run layman -s ALL && emerge --sync -q && eix-update && emerge -uDNa world

: Run openSUSE : Run zypper refresh && zypper dist-upgrade

: Run Void: Run xbps-install -Su

2. Run etc-update.

3. Run unofficial and third-party package managers:

Update Flatpak packages

packages Update snap packages

packages Run fwupdmgr to show firmware upgrade. (View only. No upgrades will actually be performed)

to show firmware upgrade. (View only. No upgrades will actually be performed) Run rpi-update to update Raspberry Pi Firmware

to update Raspberry Pi Firmware Run pihole updater

updater Update Rustup by running rustup update . This will also attempt to run rustup self update when Rustup is installed inside the home directory.

. This will also attempt to run when Rustup is installed inside the home directory. Run Cargo install-update

Upgrade Emacs packages

packages Upgrade OCaml packages

packages Upgrade vcpkg globally installed packages

globally installed packages Upgrade myrepos managed sourcecode repositories

managed sourcecode repositories Upgrade Python packages installed using pipx

Upgrade R globally installed packages

globally installed packages Upgrade Vim/Neovim packages. Works with the following plugin frameworks: NeoBundle Vundle Plug Dein

packages. Works with the following plugin frameworks: Node Run yarn global update if yarn is installed. Run npm update -g if NPM is installed and npm root -g is a path inside your home directory.

Run composer global update if Composer's home directory is inside the home directory of the user. Run valet install after.

if Composer's home directory is inside the home directory of the user. Run after. Upgrade Atom packages

packages Run gem upgrade --user-install if ~/.gem exists

On Unix:

Run brew update && brew upgrade . This should handle both Homebrew and Linuxbrew .

. This should handle both and . Run nix upgrade-nix && nix --upgrade .

. Run Pearl pearl update .

. Run zplug update

update Upgrade tmux plugins with TPM

On FreeBSD:

Upgrade and audit packages.

Miscellaneous (These steps will be performed on all OS)

It will check if the following paths are tracked by Git. If so, pull them:

~/.emacs.d

~/.zshrc

~/.oh-my-zsh

~/.tmux

~/.config/fish

~/.config/nvim

~/.vim

~/.config/openbox

~/.config/bspwm

~/.config/i3

Powershell Profile

Custom defined paths

Final steps

Once all packages are upgraded, Topgrade will do one more final step.

On Linux:

Topgrade utility will run needrestart to restart all services.

On FreeBSD:

Topgrade will run freebsd-upgrade

In Mac OS X, it will upgrade App Store applications.

Sample output from my Ubuntu 18.04 LTS test box:

The good thing is if one task is failed, it will automatically run the next task and complete all other subsequent tasks. Finally, it will display the summary with details such as how many tasks did it run, how many succeeded and how many failed etc.

Suggested read:

Topgrade options

Tograde comes with a few options to perform various additional tasks.

Run Topgrade inside Tmux sessions

This is handy when you use Topgrade on the remote systems.

To start Topgrade inside a Tmux session, use -t flag.

$ topgrade -t

Remove old and unnecessary files

To instruct package managers to clean up old and unused files, use -c flag with topgrade:

$ topgrade -c

Disable specific upgrade steps

Sometimes, you don't want to upgrade a specific package. If so, you can use --disable option.

For instance, skip system upgrade using command:

$ topgrade --disable system

This command will only skip the system upgrade phase and upgrade everything else as usual.

―― 11:39:48 - Self update ―――――――――――――――――――――――――――――――――――――――――――――――――――――― Topgrade is up-to-date ―― 11:39:50 - rustup ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― info: checking for self-updates info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: checking for self-updates stable-x86_64-unknown-linux-gnu unchanged - rustc 1.35.0 (3c235d560 2019-05-20) ―― 11:39:52 - Node Package Manager ――――――――――――――――――――――――――――――――――――――――――――― ―― 11:40:08 - Summary ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― Git repositories: OK rustup: OK NPM: OK

Skip Emacs upgrade:

$ topgrade --disable emacs

This command will skip upgrading Emacs packages and its configuration files.

Skip Vim upgrade:

$ topgrade --disable vim

Skip gem upgrade:

$ topgrade --disable gem

For more details, check the help section by running the following command:

$ topgrade --help Topgrade 2.2.0 Roey Darwish Dror <[email protected]> Command line arguments USAGE: topgrade [FLAGS] [OPTIONS] FLAGS: -c, --cleanup Cleanup temporary or old files -n, --dry-run Print what would be done -h, --help Prints help information --no-retry Do not ask to retry failed steps -t, --tmux Run inside tmux -V, --version Prints version information -v, --verbose Output logs OPTIONS: --disable <disable>... Do not perform upgrades for the given steps [possible values: gem, git-repos, vim, emacs, system]

Personally, I liked the idea of creating an utility like topgrade and upgrade everything installed with various package managers with a single command. I hope you find it useful too.

Resource: