Package management in Linux refers to the process of installing, updating, configuring, and removing software packages in a system. Each Linux distribution (Ubuntu, Fedora, Arch, etc.) has its own package management system that handles software efficiently.
A package manager is a tool that helps install, upgrade, and remove software. Examples:
- APT (Advanced Package Tool) → Used in Debian-based distros (Ubuntu, Debian)
- DNF/YUM (Dandified Yum) → Used in RHEL-based distros (Fedora, CentOS)
- Pacman → Used in Arch Linux
- Zypper → Used in openSUSE
A repository (repo) is a collection of software packages stored on a remote server, which package managers access to download and install software.
- Official Repositories → Maintained by the Linux distro (e.g., Ubuntu’s
main,universerepos). - Third-Party Repositories → Extra software sources (e.g., PPAs in Ubuntu, EPEL in CentOS).
APT manages .deb packages in Debian-based systems.
- Update package lists:
sudo apt update
- Upgrade all packages:
sudo apt upgrade
- Install a package (e.g.,
vim):sudo apt install vim
- Remove a package:
sudo apt remove vim
Manages .rpm packages in Red Hat-based distros.
- Update package lists:
sudo dnf update # Newer systems (Fedora, RHEL 8+) sudo yum update # Older systems (RHEL 7, CentOS 7)
- Install a package:
sudo dnf install vim
- Remove a package:
sudo dnf remove vim
Pacman manages .pkg.tar.zst packages in Arch-based systems.
- Update package lists:
sudo pacman -Sy
- Upgrade all packages:
sudo pacman -Syu
- Install a package:
sudo pacman -S vim
- Remove a package:
sudo pacman -R vim
Package managers automatically install dependencies (other required software) when installing a package.
Example: Installing vlc also installs dependent libraries.
- APT (
autoremoveunused dependencies):sudo apt autoremove
- DNF (
autoremovenot needed dependencies):sudo dnf autoremove
- Pacman (
remove unused packages):sudo pacman -Rns $(pacman -Qdtq)
- APT:
apt search package-name
- DNF:
dnf search package-name
- Pacman:
pacman -Ss package-name
For users who prefer a graphical interface:
- Ubuntu (APT) → Synaptic Package Manager
- Fedora (DNF) → GNOME Software
- Arch Linux (Pacman) → Pamac
Drishya is a system administrator managing an Ubuntu-based server for a research team. The team needs Python 3, Jupyter Notebook, and NumPy installed for their machine-learning experiments. Drishya also needs to ensure the system stays updated while keeping disk usage optimized.
Before installing anything, Drishya updates the package list to get the latest versions.
sudo apt update- This downloads the latest package metadata from Ubuntu repositories.
- Ensures that APT fetches the newest available versions when installing software.
The research team requires Python and Jupyter Notebook, so Drishya installs them:
sudo apt install python3 python3-pip jupyter-notebook -ypython3→ Installs Python 3.python3-pip→ Enables package installation viapip.jupyter-notebook→ Installs Jupyter Notebook for interactive Python coding.-y→ Automatically confirms the installation to avoid manual input.
After installation, Drishya confirms everything is working.
python3 --version
jupyter-notebook --versionExpected output:
Python 3.10.12
6.5.2
Instead of using pip, Drishya installs NumPy via APT for better package management.
sudo apt install python3-numpy -yVerifying the installation:
python3 -c "import numpy; print(numpy.__version__)"Expected output:
1.21.5
To free up space, Drishya removes unnecessary dependencies.
sudo apt autoremove -y- This cleans up old libraries that were installed as dependencies but are no longer needed.
To ensure security patches and updates are applied, Drishya upgrades all installed packages:
sudo apt upgrade -yFor a complete system upgrade (including kernel and major releases):
sudo apt full-upgrade -y✅ Python 3, Jupyter, and NumPy are successfully installed.
✅ The system is optimized with removed unused packages.
✅ Regular updates are ensured for security and performance.