APT, Package Management, and Linux Networking

What you will learn

In this lesson you will learn:

  1. What a package manager is and why it exists
  2. How apt works on Debian/Ubuntu (repositories, metadata, dependencies)
  3. The most useful apt commands for DevOps work
  4. Linux networking basics (interfaces, IP, DNS, routing)
  5. Common Linux networking commands and what to use them for

1) How package managers work (the big picture)

1.1 The problem package managers solve

On a Linux server you often need to install software like:

A package manager solves these problems:

1.2 Packages, repositories, and metadata

On Debian/Ubuntu:

The most important mental model:

1.3 Dependencies (why apt is so valuable)

Most software depends on libraries.

When you run:

sudo apt install nginx

apt will automatically install the required dependencies so that Nginx works.

1.4 Where apt reads repository configuration

Common files:

A typical entry looks like:

deb http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse

Meaning:


2) APT essentials (commands you’ll actually use)

2.1 Update package lists

sudo apt update

If you forget this, you may not see the latest versions.

2.2 Install a package

sudo apt install curl
sudo apt install nginx

2.3 Remove a package

sudo apt remove nginx

This keeps configuration files in many cases.

2.4 Purge (remove including config)

sudo apt purge nginx

2.5 Upgrade installed packages

sudo apt upgrade

For a “bigger” upgrade (may remove/install packages):

sudo apt full-upgrade

2.6 Search and inspect packages

apt search nginx
apt show nginx
apt-cache policy nginx

2.7 Clean up

sudo apt autoremove
sudo apt autoclean
sudo apt clean

2.8 Check what files a package installed

dpkg -L nginx

2.9 Find which package owns a file

dpkg -S /usr/sbin/nginx

2.10 Hold a package (prevent upgrades)

Useful in production to avoid unexpected upgrades.

sudo apt-mark hold nginx
sudo apt-mark unhold nginx

3) Security and best practices with apt

3.1 Don’t blindly run scripts

Prefer installing from official repositories. If you must use third-party repos, understand what you add.

3.2 Know what changed

Before upgrades:

3.3 Reproducibility

In DevOps, the goal is repeatable builds.


4) Linux networking basics

4.1 Interfaces and IP addresses

An interface can be:

IP address types:

4.2 DNS (name resolution)

DNS turns names into IP addresses.

Important files/commands:

4.3 Routing

Routing decides how packets leave your machine.

Key concept:


5) Networking commands (what to use and why)

5.1 See IP addresses and interfaces

ip addr
ip link

Old command (still common):

ifconfig

5.2 Routing table

ip route

5.3 Test connectivity

ping 8.8.8.8
ping google.com

If IP ping works but DNS ping fails, your DNS is likely broken.

5.4 DNS lookup

getent hosts google.com
nslookup google.com

dig google.com

5.5 Check listening ports and services

ss -tulpen

Common patterns:

ss -tulpen | grep :22
ss -tulpen | grep :80

5.6 Check active connections

ss -tunp

5.7 Download / HTTP testing

curl -I https://example.com
curl -v https://example.com

5.8 Tracing the path (where packets go)

traceroute google.com

# often better on firewalled networks
tracepath google.com

5.9 Quick bandwidth / throughput checks

Common tools:

5.10 ARP / Neighbor table

ip neigh

5.11 Firewall (very common in DevOps)

Depending on distro:


Practice tasks

  1. Update apt metadata, install curl, and verify its version
  2. Use apt show to inspect nginx
  3. Display your IP address and default route
  4. Use ss to confirm what ports are listening on your machine
  5. Use dig or nslookup to verify DNS resolution