Skip to main content

Command Palette

Search for a command to run...

Linux Package Management for DevOps Beginners | apt, dpkg, snap

Master package managers in Linux to streamline installs, updates, and automation in DevOps workflows.

Updated
Linux Package Management for DevOps Beginners | apt, dpkg, snap
A
🚀 Code. Automate. Innovate. Hi, I’m Abdulrahman, a passionate DevOps Engineer and Software Developer on a mission to bridge the gap between code and production. With a love for automation, cloud-native solutions, and cutting-edge tech, I turn complex problems into seamless, scalable systems. 💡 What I Do: Build robust CI/CD pipelines that deliver software at the speed of thought. Architect cloud infrastructure that scales with a single command. Transform manual processes into automated workflows that just work. Break down silos and foster collaboration between teams. 🔧 Tech Stack I ❤️: Containers (Docker), Orchestration (Kubernetes), Infrastructure as Code (Terraform), CI/CD (Jenkins, GitLab), Cloud (AWS/GCP/Azure), and scripting like it’s my superpower. 📝 Why This Blog? This is where I share my journey, lessons learned, and the latest trends in DevOps and software engineering. Whether you're a seasoned pro or just starting out, join me as we explore the tools, tricks, and best practices that make the tech world tick. 🌟 Let’s Build the Future, One Pipeline at a Time. Connect with me, share your thoughts, and let’s automate the world together!
  • 🎯 Target Audience: Beginners in DevOps & DevSecOps
  • 🧠 Key Concepts: apt, dpkg, snap, automation scripts
  • Estimated Read Time: ~8 minutes
  • 📚 Series: Yes, Part of “Linux for DevOps Beginners”
  • 🌍 Real-World Focus: Automating software installs & updates in CI/CD pipelines

Why This Matters in DevOps

In DevOps & DevSecOps, package management = speed + consistency. You’ll constantly install, update, and secure tools across servers, containers, and CI/CD pipelines.

Knowing how to work with apt, dpkg, and snap is essential for:

  • Automating provisioning scripts (Ansible, Terraform, Dockerfiles).
  • Ensuring systems stay patched & secure.
  • Standardizing environments across dev, staging, and prod.

1️⃣ Keeping Systems Updated —> apt update & apt upgrade

sudo apt update
sudo apt upgrade -y
  • apt update → refreshes the list of available packages.
  • apt upgrade → installs the latest versions of installed packages.

DevOps Use Case: Include these in provisioning scripts to ensure every VM or container has the latest security patches before deploying apps.

Pro Tip: Use -y in automation scripts to skip prompts.


2️⃣ Installing Packages —> apt install

sudo apt install nginx -y

This installs Nginx (or any other package + dependencies).

DevOps Use Case:

  • Set up web servers (nginx, apache2)
  • Install databases (mysql-server, postgresql)
  • Install runtimes (python3, nodejs)

Real-world example (automation):

#!/bin/bash
sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx mysql-server python3-pip

3️⃣ Low-Level Package Control —> dpkg -i

sudo dpkg -i custom-package.deb

Unlike apt, dpkg doesn’t resolve dependencies automatically.

DevOps Use Case:

  • Install custom .deb builds not available in public repos.
  • Deploy proprietary tools or older versions pinned for compatibility.

Pro Tip: Run sudo apt -f install after dpkg -i to auto-fix broken dependencies.


4️⃣ Modern Packaging —> snap install

sudo snap install docker

Why Snap matters:

  • Self-contained (ships app + dependencies).
  • Works across multiple Linux distros.
  • Easy rollback & version control.

DevOps Use Case: Snap is useful when:

  • Running the same app across heterogeneous systems.
  • Deploying cloud-native & containerized workloads without worrying about dependency hell.

Common Mistakes to Avoid

⚠️ Forgetting apt update → you’ll install outdated packages. ⚠️ Using dpkg for general installs → prefer apt unless it’s a custom .deb. ⚠️ Ignoring automation → manually installing packages breaks consistency across environments. ⚠️ Mixing apt & snap versions → can cause conflicts if the same app exists in both formats.


Quick Recap

  • apt update && apt upgrade → Keep systems secure & updated.
  • apt install → Install packages & dependencies.
  • dpkg -i → Low-level control for .deb files.
  • snap install → Portable, self-contained apps.

Master these tools, and you’ll be able to automate environment setup like a pro 🚀.


If this helped you understand package management in Linux, share it with a fellow DevOps beginner. Next in the series: Phase 7: Compression & Archiving 🗜️


👨‍💻 Written by: Abdulrahman A. Muhamad 🌐 LinkedIn | GitHub | Portfolio

Linux for DevOps Beginners: From Shell to Production

Part 6 of 8

Beginner-friendly Linux series for DevOps & SREs. Learn file systems, permissions, processes, networking, automation & security with hands-on examples. Build a solid foundation before diving into cloud & containers.

Up next

Linux 🗜️ Phase 7: Compression & Archiving for DevOps Beginners

Learn tar, gzip, zip, and unzip to automate packaging, backups, and deployments.