Skip to main content

Command Palette

Search for a command to run...

Package Management in Linux

Published
β€’3 min read
A

DevOps engineer sharing daily learnings on Linux, Docker, Kubernetes, CI/CD, and Cloud.

What is package management?

Package management is the process of:

  • Installing software

  • Updating packages

  • Removing applications

  • Managing dependencies

In Linux, software is distributed as packages and handled by package managers.

πŸ“Œ A package contains:

  • Application binaries

  • Configuration files

  • Dependencies

  • Metadata (version, description)

Role of package manager :

Without package managers:

  • You’d manually download software

  • Resolve dependencies yourself

  • Risk breaking the system

Package managers:

  • Automatically handle dependencies

  • Fetch software from trusted repositories

  • Keep systems secure and updated

Types of Linux Packages

Package TypeDistributions
.debUbuntu, Debian
.rpmRHEL, CentOS, Rocky, Alma
.apkAlpine Linux
  1. πŸ“¦ apt (Debian / Ubuntu) :
  • Used in Debian-based systems

  • Works with .deb packages

Common commands :

sudo apt update
sudo apt install nginx
sudo apt remove nginx
sudo apt upgrade
  1. πŸ“¦ yum (Older RHEL / CentOS) :
  • Used in older RHEL-based systems

  • Handles .rpm packages

Common commands :

sudo yum install httpd
sudo yum remove httpd
  1. dnf (Modern RHEL / Fedora) :
  • Successor to yum

  • Faster and better dependency handling

sudo dnf install httpd
sudo dnf update
  1. πŸ“¦ apk (Alpine Linux) :
  • Lightweight package manager

  • Common in Docker containers

apk add curl
apk del curl

Repositories :

Repositories are trusted software sources that Linux uses to install and update packages automatically.

  • A repository is a storage location where Linux packages are kept

  • Package managers download software from repositories, not random websites

  • Repositories contain:

    • Software packages

    • Version information

    • Dependency details

    • Security updates

πŸ“Œ This ensures safe, verified, and consistent software installation

πŸ“Œ Always prefer official repositories for security.

Example :

/etc/apt/sources.list
/etc/yum.repos.d/

πŸ”„ Package Management Workflow

Package management in Linux follows a standard step-by-step workflow:

  1. Update Package Index :

    The system fetches the latest package information from repositories.

     apt update #Ubuntu
     dnf makecache #RHEL
    
  2. Search for a Package :

    Find available software in repositories.

     apt search nginx #Ubuntu
     dnf search nginx #RHEL
    
  3. Install the Package

    Download and install the package along with its dependencies.

     apt install nginx #Ubuntu
     dnf install nginx #RHEL
    
  4. Use / Configure the Software

    Start the service or edit configuration files as needed.

  5. Update Installed Packages

    Keep software secure and up to date.

     apt upgrade #Ubuntu
     dnf update #RHEL
    
  6. Remove the Package (If Needed)

    Uninstall software cleanly.

     apt remove nginx #Ubuntu
     dnf remove nginx #RHEL
    

    Linux package managers fetch β†’ install β†’ update β†’ remove software automatically while handling dependencies for you.

Common Beginner Mistakes ⚠️

  • Forgetting apt update

  • Mixing package managers

  • Installing from untrusted sources

  • Removing system-critical packages

πŸ”š Conclusion

Package management makes Linux:

  • Stable

  • Secure

  • Easy to maintain

Understanding package managers is essential for Linux admins and DevOps engineers.

Linux Essentials

Part 3 of 5

Linux Essentials is a practical series covering core Linux concepts from a DevOps perspectiveβ€”architecture, filesystem, permissions, processes, networking, and servicesβ€”focused on real-world usage in production and cloud environments.

Up next

Basic Linux Commands

Linux is controlled mainly through the command line.Knowing basic Linux commands helps you: Navigate the file system Manage files and directories Inspect system information Work efficiently on servers This guide covers the most commonly used Li...