← All lessons
System administration · Lesson 2 of 7

Installing software

On Linux you rarely download installers from websites. Each distribution (Ubuntu, Debian, Fedora and so on) keeps a repository of tested packages, and a package manager fetches them, installs whatever else they need and keeps them up to date.

Debian and Ubuntu use apt. First refresh the list of what's available, then install:

$ sudo apt update            # fetch the latest package lists
$ sudo apt install nginx     # install a package
$ sudo apt upgrade           # update everything installed
$ sudo apt remove nginx      # uninstall it
$ apt search image editor    # find packages

update and upgrade are easy to mix up. update only refreshes the list of what's available; it changes nothing installed. upgrade actually installs the newer versions. You usually run them together: sudo apt update && sudo apt upgrade.

Fedora, Red Hat and their relatives use dnf: sudo dnf install nginx, sudo dnf upgrade, sudo dnf remove nginx. It refreshes its lists by itself. Arch uses pacman, and Alpine uses apk; the ideas are the same.

Keeping packages up to date is the single most useful thing you can do for a server's security, since most updates fix known holes. Ubuntu's unattended-upgrades can install security fixes automatically. Some updates, like a new kernel, only take effect after a restart.

Practice

On Ubuntu, install the package git.

More info

Quick reference

apt updateRefresh the package lists (Debian, Ubuntu).
apt upgradeInstall updates.
apt install, apt removeAdd or remove a package.
apt search wordFind packages.
dnf install, dnf upgradeThe same on Fedora and Red Hat.

The other Linux courses