Safely Update Linux Package Managers
 Safely Update Linux Package Managers 
 A portable Bash script to update all major package managers on any Linux distribution while ensuring safety. It avoids disruptive upgrades by using commands like apt upgrade instead of dist-upgrade, performs post-update cleanup for certain package managers (e.g., APT, Homebrew, and DNF), and only updates package managers detected on the system to prevent unnecessary operations. It supports APT, DNF, YUM, Pacman, Zypper, APK, Emerge, Nix, Snap, Flatpak, and Homebrew.
Features
- โ Cross-distro support: Works with Debian, Ubuntu, Fedora, RHEL, CentOS, Arch, Manjaro, openSUSE, Alpine, Gentoo, and NixOS.
- ๐ฆ Supports 11 package managers: apt,dnf,yum,pacman,zypper,apk,emerge,nix-env,snap,flatpak, andbrew.
- ๐ Auto-detection: Automatically detects your Linux distribution and available package managers.
- ๐งน Cleanup included: Performs post-update cleanup for APT, Homebrew, and DNF.
- ๐ Safe operations: Uses apt upgradeinstead ofdist-upgradeto avoid disruptive upgrades.
- โ๏ธ Modular & extensible: Easy to add more logic for distro-specific updates.
Usage
Download the script update-everything.sh here and run:
1
2
chmod +x update-everything.sh
./update-everything.sh
Or run directly from Gist in one line:
1
bash <(curl -L https://go.khuong.dev/update-everything-script)
Note: Most package managers (APT, DNF, Snap, etc.) require
sudoaccess. Ensure you trust the script and its source before granting elevated privileges to avoid potential security risks.
References
 This post is licensed under  CC BY 4.0  by the author.
