Skip to content

Latest commit

 

History

History
222 lines (176 loc) · 5.59 KB

File metadata and controls

222 lines (176 loc) · 5.59 KB

Package Management in Linux

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.


1. Key Components of Package Management

a) Package Managers

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

b) Repositories

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, universe repos).
  • Third-Party Repositories → Extra software sources (e.g., PPAs in Ubuntu, EPEL in CentOS).

2. Common Package Managers in Linux

a) APT (Debian, Ubuntu, Mint)

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

b) DNF/YUM (Fedora, RHEL, CentOS)

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

c) Pacman (Arch Linux, Manjaro)

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

3. Advanced Package Management

a) Handling Dependencies

Package managers automatically install dependencies (other required software) when installing a package.

Example: Installing vlc also installs dependent libraries.

b) Removing Unused Packages

  • APT (autoremove unused dependencies):
    sudo apt autoremove
  • DNF (autoremove not needed dependencies):
    sudo dnf autoremove
  • Pacman (remove unused packages):
    sudo pacman -Rns $(pacman -Qdtq)

c) Searching for Packages

  • APT:
    apt search package-name
  • DNF:
    dnf search package-name
  • Pacman:
    pacman -Ss package-name

4. GUI-Based Package Managers

For users who prefer a graphical interface:

  • Ubuntu (APT)Synaptic Package Manager
  • Fedora (DNF)GNOME Software
  • Arch Linux (Pacman)Pamac

Case Study: Managing Software with APT in Ubuntu

Scenario

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.


Step 1: Updating the Package List

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.

Step 2: Installing Python and Jupyter Notebook

The research team requires Python and Jupyter Notebook, so Drishya installs them:

sudo apt install python3 python3-pip jupyter-notebook -y

Explanation:

  • python3 → Installs Python 3.
  • python3-pip → Enables package installation via pip.
  • jupyter-notebook → Installs Jupyter Notebook for interactive Python coding.
  • -y → Automatically confirms the installation to avoid manual input.

Step 3: Verifying Installation

After installation, Drishya confirms everything is working.

python3 --version
jupyter-notebook --version

Expected output:

Python 3.10.12
6.5.2

Step 4: Installing NumPy Using APT

Instead of using pip, Drishya installs NumPy via APT for better package management.

sudo apt install python3-numpy -y

Verifying the installation:

python3 -c "import numpy; print(numpy.__version__)"

Expected output:

1.21.5

Step 5: Removing Unused Packages

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.

Step 6: Keeping the System Up to Date

To ensure security patches and updates are applied, Drishya upgrades all installed packages:

sudo apt upgrade -y

For a complete system upgrade (including kernel and major releases):

sudo apt full-upgrade -y

Outcome

Python 3, Jupyter, and NumPy are successfully installed.
The system is optimized with removed unused packages.
Regular updates are ensured for security and performance.