Excalibur's Sheath

Package and Software Managment

Apr 9, 2025 • By Jordan McGilvraylinux,server,bash,cli

Ensuring every component of your system is up-to date, secure and free of incompatible dependancies is the first step towards resiliant infrastructure. This guide will provide the needed commands to keep you environment up-to date secure, and free of incompatibilities.

apt, apt-get, and dpkg

apt and apt-get were developed by Debian, and are used by the Debian GNU Linux Distribution, and Linux distributions derived from it, like Ubuntu and Linux MInt. Since these commands affect the system as a whole, root access is needed for package management tasks. You can either log-in as root, use sudo su, or use sudo to run the commands. Especially on Ubuntu and its derivities sudo and the command is the easiest way to do this. On Debian you may have to grant your user permission to run sudo.

apt Basic Commands

Update Repositories:

sudo apt update

Upgrade all Packages:

sudo apt upgrade

Install Software:

sudo apt install PACKAGE_NAME

Remove Software:

sudo apt remove PACKAGE_NAME

Remove Packages No Longer Needed:

sudo apt autoremove

apt-get Basic Commands

apt-get is more stable in scripting situations. It works just like apt.

Update Repositories:

sudo apt-get update

Upgrade all Packages:

sudo apt-get upgrade

Install Software:

sudo apt-get install PACKAGE_NAME

Remove Software:

sudo apt-get remove PACKAGE_NAME

Remove Packages No Longer Needed:

sudo apt-get autoremove

Repair Broken Dependencies:

sudo apt-get install -f

dpkg Baic Commands

apt and apt-get help install dependancies needed for the package we want to install. Each package is contained in a .deb package, so apt and apt-get call dpkg to install the package we ask for and its dependencies. Sometimes we need to install, remove, or manage a .deb package directly.

Install a .deb Package:

sudo dpkg -i PACKAGE.deb

List Installed Packages:

sudo dpkg -l

Remove a .deb Package:

sudo dpkg -r PACKAGE.deb

yum, dnf, and rpm

Redhat developed rpm, and dnf. yum was first developed by Yellow Dog Linux, It is an acronymn standing for Yellow-Dog Updater Modified. Distributions which are derived from Redhat, like Fedora use them too. yum is a bit older, and is being replaced by dnf, while both yum and dnf use rpm to install packages, which usually end in .rpm. As with the Debian commands these commands need root access to function, so we will run them with sudo.

Yum Basic Commands

Upgrade all Packages

sudo yum update

Install a Package

sudo yum install PACGAGE_NAME

Remove a Package

sudo yum remove PACKAGE_NAME

DNF Basic Commands

Upgrade all Packages

sudo dnf update

Install a Package

sudo dnf install PACGAGE_NAME

Remove a Package

sudo dnf remove PACKAGE_NAME

RPM Basic Commands

yum and dnf run rpm in the back ground to install, update and remove packages. rpm can be used to direcly install and remove packages.

Install a Package

sudo rpm -i PACKAGE_NAME.rpm

Upgrade Package

sudo rpm -U PACKAGE_NAME

List all Installed Packages

sudo rpm -qa

Remove a Package

sudo rpm -e PACKAGE_NAME.rpm

pacman

packman is the package manager for [Arch](https://aechlinux.org} Linux and distributions derived from it.

Upgrade all Packages

sudo pacman -Syu

Install a Package

sudo pacman -S PACKAGE_NAME

Remove a Package

sudo pacman -R PACKAGE_NAME

Remove a Package and Dependencies not used by Other Packages

sudo pacman -Rs PACKAGE_NAME

Search Packages

sudo pacman -Ss STRING

emerge and portage

emerge and portage are used by Gentoo Linux.

Update Repositories

emerge --sync

Upgrade System

emerge -avuDU --with-bdeps=y @world

Install a Package

emerge -av package-name

Remove a Package

emerge -C package-name

List All Installed Packages

qlist -I

Displays all Installed Packages

emerge -av app-portage/portage-utils

Specialty Tools

These are designed to be univeral packages that work across multiple disributions.

Snap

Developed by: Canonical (makers of Ubuntu)

How it works:

  • Packages include the app and most of its dependencies.
  • Snaps run in a sandboxed environment for security.
  • Installed using the snap command.

Features:

  • Automatic updates.
  • Snapd daemon runs in the background to manage snaps.

Snap is great for containerized apps and IoT devices.

Example Package Install

sudo sap install PACKAGE_NAME

Flatpack

Developed by: Red Hat (originally called xdg-app)

How it works:

  • Uses runtimes (shared libraries) to reduce duplication.
  • Apps are sandboxed using Bubblewrap.
  • Installed using the flatpak command.

Features:

  • App permissions can be managed (e.g., file access).
  • GNOME Software and KDE Discover support it.

Flatpak is great for desktop apps with graphical interfaces.

Example Package Install

flatpak install flathub app-id

AppImage

Developed by: Open source community

How it works:

  • A single portable file — just download, make executable, and run.
  • No installation or root access needed.

Features:

  • Truly portable (can run from USB).
  • No sandboxing by default.

AppImage is super easy to distribute and run without system changes.

Example Package Install

All apps are portable Download Package

chmod +x PACKAGE

Run Package

Rare Package Manager Tools

zypper

Update Repositories

zypper refresh

Upgrade System

zypper update

Full Distribution Upgrade

zypper dup

Install a Package

zypper install PACKAGE_NAME

Remove a Package

zypper remove package-name

List All Installed Packages

zypper se --installed-only

guix

Update System Package Definitions

guix pull

Reconfigure System (Upgrade System Profile)

sudo guix system reconfigure /etc/config.scm

Roll Back System

sudo guix system roll-back

Roll back a user profile

guix package --roll-back

Remove Old System Generations

sudo guix system delete-generations

Delete User Profile Generations

guix package --delete-generations

List System Generations

sudo guix system list-generations

List User Profile Generations

guix package --list-generations

nix

Update Package Channels

nix-channel --update

Upgrade Packages in User Profile

nix-env -u

Upgrade a Specific Package

nix-env -u package-name

Install a Package

nix-env -iA nixpkgs.package-name

Remove a Package

nix-env -e package-name

List All Installed Packages

nix-env -q

NixOS System Management Cheat Sheet

Update System Channel

sudo nix-channel --update

Rebuild and Upgrade System

sudo nixos-rebuild switch --upgrade

Remove Old Generations

sudo nix-collect-garbage -d

Collect Garbage Without Deleting Generations

sudo nix-collect-garbage

List System Generations

sudo nix-env --list-generations

List User Generations

nix-env --list-generations

AUR Helpers

AUR helpers are tools that simplify installing and managing packages from the Arch User Repository (AUR). They handle downloading PKGBUILDs, resolving dependencies, and compiling/installing packages automatically.

Helper Language Description
yay Go Fast, user-friendly, actively maintained. Most popular.
paru Rust Feature-rich, colorized output, yay-compatible syntax.
trizen Perl Lightweight, interactive, handles dependencies well.
pikaur Python Clean UI, supports systemd & split packages.

yay (Yet Another Yaourt)

Install from AUR manually (if you don’t have an AUR helper yet):

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Examples:

yay -S package-name       # Install a package from AUR or official repo
yay -R package-name       # Remove a package
yay -Syu                  # Full system upgrade (official + AUR)
yay -Ss keyword           # Search for a package
yay -Qi package-name      # Show package info

paru

Install from AUR:

git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si

Examples:

paru -S package-name      # Install a package
paru                      # Interactively update system and AUR
paru -Rns package-name    # Remove package with unneeded dependencies
paru -Qe                  # List all explicitly installed packages

trizen

Install from AUR:

git clone https://aur.archlinux.org/trizen.git
cd trizen
makepkg -si

Examples:

trizen -S package-name    # Install a package
trizen -R package-name    # Remove a package
trizen -Syua              # Sync, update system and AUR
trizen -Ss keyword        # Search for packages

Legacy Package Management

Before package managers installing and updating software was difficult and time consuming.

The desired package would be downloaded as source code in a tarball (a compressed tar file)

tar -xvf SOURCE.tar.gz # Decompress tarball
cd SOURCE              # Enter the directory of the source code
make                   # BUild the executable
sudo make install      # Insall executable into the system

Using this method there are a few issues:

  • No way to uninstall
  • No dependancy resolution

This gave rise to dependancy hell. Dependancy Hell is when the software package cannot build because it needs other software installed, and then that software doesn’t install because of its dependancies. This can go on and on.

The next generation of package managment was the creation of tools, like dpkg and rpm. These allowed executable software to be installed on the system, but would not install if depenancies are missing, leading to RPMHell, and having to install rpm files in order so that the final desired software will build.

Today’s main tools, apt/apt-get, yum/dnf solve a lot of these problems as they are able to install dependancies along with the desired packages.

Snap, Flatpak, and AppImage attempt to solve dependancy issues by including the exact dependancies needed in the package eliminating the need to install them system wide.

Final Thoughts

Some tips that have worked for me. I have used Debian and its derivatives, as well as RedHat and its derivatives as well as Arch.

  • Update repositories before upgrading the system.
  • Check for packages installed having upgrades available and upgrade before installing new packages.
  • Stick with your distribution’s native package management tool.
  • When the package management tool isn’t working as expected check the man page for correct syntax.
man apt
man apt-get
man yum
man dnf
man pacman

Package Managers exist to make System Administration easier. Keeping your system up-to-date closes security holes, and adds newer features. There will be times when the software you want isn’t in the distribution’s repository. At those times consider if it is essential. If it is you may have to build it from source and install it at the correct location on your system for it to function correctly.