Skip to content

Install software with apt

AdvancedLesson 44 of 667 min

Refresh the package list, search for and install tools with apt, see what is installed, remove what you don’t need and set up a web server in two commands.

On Linux you rarely download software from a website. A package manager installs it from your distribution's own collection, called a repository, along with everything it needs, and keeps it up to date. Ubuntu and Debian use apt. The system here is a simulation in your browser: no real accounts, passwords or software are involved. The packages here are a small pretend catalogue, and nothing is downloaded.

When a command is missing, the shell often says which package has it:

tree projects

The everyday commands

CommandDoes
sudo apt updaterefreshes the list of packages and versions (do it first)
apt search WORDfinds packages by name or description
apt show NAMEa package's description, version and size
sudo apt install NAMEinstalls it (-y answers yes for you)
apt list --installedeverything installed
sudo apt upgradeinstalls newer versions of what you have
sudo apt remove NAMEremoves it (purge removes its settings too)

Installing needs sudo, because it changes the whole system. Searching and showing don't.

apt search tree
apt show tree

A whole server in one line

Packages can be big things too. sudo apt install nginx installs a web server, starts it as a service, and sets it to start at every boot. Check it with systemctl status nginx and curl localhost.

Other systems

The idea is the same everywhere; the command differs:

SystemInstall a package
Ubuntu, Debiansudo apt install tree
Fedora, Red Hatsudo dnf install tree
Archsudo pacman -S tree
macOS (Homebrew)brew install tree

Your turn

Refresh the package list, install tree and use it to show the projects folder. Then install the web server nginx on your laptop and check with curl localhost that it answers.

Next