Every server, virtual machine, and container starts with a simple requirement: software needs to be installed.
Whether you're setting up a web server, deploying a database, configuring monitoring tools, or preparing a Docker image, package managers are the tools that make software installation fast, reliable, and repeatable.
As part of my DevOps learning journey, I explored how Linux package managers work, why they matter in modern infrastructure, and how they help automate software provisioning.
In this article, I'll cover:
β
What package managers are
β
Why package management matters in DevOps
β
Using apt on Ubuntu
β
Understanding repositories and dependencies
β
yum and dnf basics
β
Why minimal server images are preferred
β
A real-world software installation workflow
Let's dive in.
Why Package Managers Matter in DevOps
Imagine installing software manually on every server:
- Download source code
- Install dependencies one by one
- Compile the application
- Configure everything manually
Not only would this take time, but it would also be difficult to reproduce consistently.
Package managers solve this problem by allowing you to install, update, and remove software using simple commands.
This becomes especially important in DevOps because:
- Dockerfiles use package managers to install software
- Configuration management tools like Ansible rely on package managers
- Cloud servers start with minimal operating systems
- Infrastructure should be repeatable and automated
Package managers are one of the foundations of modern infrastructure automation.
What Is a Package Manager?
A package manager is a tool that installs and manages software packages on a Linux system.
A package typically contains:
- Application files
- Dependencies
- Configuration information
- Installation instructions
- Metadata
Package managers handle several important tasks automatically.
Dependency Resolution
If Software A requires Libraries B and C, the package manager installs them automatically.
You don't need to manually track every dependency.
Software Repositories
Package managers download software from trusted repositories maintained by operating system vendors or software providers.
Correct File Placement
Installed files are placed in the proper Linux directories automatically.
For example:
/usr/bin β Executables
/etc β Configuration files
/usr/lib β Libraries
Version Tracking
Package managers keep track of installed software, making updates and removals much easier.
Understanding apt (Ubuntu Package Manager)
Since Ubuntu is one of the most popular Linux distributions in cloud environments, apt is a command you'll use frequently.
Refresh Package Information
sudo apt update
This command updates the local package catalog.
It does not install or upgrade software.
Think of it as refreshing a store's inventory before shopping.
Upgrade Installed Packages
sudo apt upgrade
This upgrades installed packages to newer available versions.
Install Software
Install Nginx:
sudo apt install nginx
Install multiple packages:
sudo apt install nginx docker.io
Remove Software
Remove a package:
sudo apt remove nginx
Remove a package and its configuration files:
sudo apt purge nginx
Clean Unused Dependencies
sudo apt autoremove
This removes packages that are no longer required.
Search for Packages
apt search nginx
View package details:
apt show nginx
List Installed Packages
apt list --installed
Useful when auditing a server.
Where Does apt Get Packages?
Package repositories are configured in:
/etc/apt/sources.list
and
/etc/apt/sources.list.d/
These files contain repository URLs where Ubuntu downloads software packages.
Most installations use Ubuntu's official repositories, but third-party repositories can also be added when necessary.
Understanding yum and dnf
While Ubuntu uses apt, Red Hat-based distributions use:
yumdnf
You'll encounter these when working with:
- Red Hat Enterprise Linux (RHEL)
- CentOS
- Fedora
- Amazon Linux
Common Command Equivalents
| Task | Ubuntu (apt) | RHEL/Fedora (dnf) |
|---|---|---|
| Update package info | apt update |
dnf check-update |
| Install package | apt install nginx |
dnf install nginx |
| Remove package | apt remove nginx |
dnf remove nginx |
| Upgrade packages | apt upgrade |
dnf upgrade |
| Search packages | apt search nginx |
dnf search nginx |
| Package details | apt show nginx |
dnf info nginx |
The concepts remain the same regardless of the distribution.
Only the commands change.
Why Minimal Server Images Matter
Modern DevOps practices encourage using minimal operating system images.
Why?
Improved Security
Every installed package increases the attack surface.
Less software means fewer vulnerabilities to patch and monitor.
Faster Provisioning
Smaller images:
- Download faster
- Boot faster
- Deploy faster
This becomes extremely important when working with containers.
Easier Maintenance
A minimal system contains only what your application needs.
This makes troubleshooting and auditing much simpler.
Reduced Resource Usage
Unused software consumes:
- Disk space
- Memory
- CPU resources
Minimal systems avoid unnecessary overhead.
A Real-World Installation Workflow
Let's walk through a practical example using Nginx.
Step 1: Update Package Information
sudo apt update
Step 2: Install Nginx
sudo apt install nginx -y
The -y flag automatically confirms installation prompts.
Step 3: Verify Service Status
sudo systemctl status nginx
Step 4: Start and Enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
This ensures Nginx starts automatically after server reboots.
Step 5: Verify Listening Ports
sudo ss -tulpn | grep :80
This confirms Nginx is listening on port 80.
Step 6: Check Logs
sudo tail -f /var/log/nginx/error.log
If something goes wrong, logs are usually the first place to investigate.
Quick Command Reference
| Command | Purpose |
|---|---|
apt update |
Refresh package catalog |
apt upgrade |
Upgrade installed packages |
apt install |
Install software |
apt remove |
Remove software |
apt purge |
Remove software and configs |
apt autoremove |
Remove unused dependencies |
apt search |
Search available packages |
apt show |
View package details |
apt list --installed |
List installed software |
dnf install |
Install packages on RHEL/Fedora |
systemctl status |
Verify service status |
Final Thoughts
Package managers are one of the most important tools in a DevOps engineer's toolkit.
They simplify software installation, automate dependency management, improve consistency, and make infrastructure easier to maintain.
Whether you're provisioning cloud servers, building Docker images, writing Ansible playbooks, or managing production environments, package management is a skill you'll use almost every day.
Understanding how package managers work today will make containerization, automation, and infrastructure management much easier as you continue your DevOps journey.
I'm documenting my DevOps learning journey and sharing beginner-friendly notes as I learn.
What package manager do you use most oftenβapt, dnf, yum, or something else?
Happy Learning! ππ§
Top comments (0)