Home Command line utilities How To Upgrade Everything Using Topgrade CLI Utility In Linux
Upgrade Everything Using Topgrade In Linux

How To Upgrade Everything Using Topgrade CLI Utility In Linux

By sk
253 Views

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
  • Redhat based: Run yum upgrade (or dnf if present)
  • Debian based: Run apt update && apt dist-upgrade
  • Gentoo: Run layman -s ALL && emerge --sync -q && eix-update && emerge -uDNa world
  • openSUSE: Run zypper refresh && zypper dist-upgrade
  • Void: Run xbps-install -Su

2. Run etc-update.

3. Run unofficial and third-party package managers:

  • Update Flatpak packages
  • Update snap packages
  • Run fwupdmgr to show firmware upgrade. (View only. No upgrades will actually be performed)
  • Run rpi-update to update Raspberry Pi Firmware
  • Run pihole updater
  • Update Rustup by running rustup update. This will also attempt to run rustup self update when Rustup is installed inside the home directory.
  • Run Cargo install-update
  • Upgrade Emacs packages
  • Upgrade OCaml packages
  • Upgrade vcpkg globally installed packages
  • Upgrade myrepos managed sourcecode repositories
  • Upgrade Python packages installed using pipx
  • Upgrade R globally installed packages
  • Upgrade Vim/Neovim 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.
  • Upgrade Atom packages
  • Run gem upgrade --user-install if ~/.gem exists

On Unix:

  • Run brew update && brew upgrade. This should handle both Homebrew and Linuxbrew.
  • Run nix upgrade-nix && nix --upgrade.
  • Run Pearl pearl update.
  • Run zplug 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:

Upgrade Everything Using Topgrade In Linux

Upgrade everything using Topgrade in Linux and Unix

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
Run Topgrade inside Tmux

Run Topgrade inside Tmux session

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:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

3 comments

MarkDubya June 26, 2018 - 1:47 am

On Arch based systems, the only package manager that should be used is pacman (optionally with an AUR helper). If packages are updated via other means, there will be conflicts. If a package is not in the repos or the AUR, then makepkg should be used to create one.

Reply
Ricardo June 15, 2019 - 11:38 pm

Correct, and it’s true in every other Linux distribution may I add.

You simply should not nistall software via language/application specific package managers (pip, gem, etc) system wide.

Not sure if topgrade distinguishes beetwen/checks for packages installed system wide and locally to the user (but I guess it can, as it checks emacs, vim and others which usually install their packages locally to the user).

Reply
Ricardo June 15, 2019 - 11:40 pm

BTW, topgrade doesn’t seem to support Slackware packages.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More