Install software with apt
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 projectsThe everyday commands
| Command | Does |
|---|---|
sudo apt update | refreshes the list of packages and versions (do it first) |
apt search WORD | finds packages by name or description |
apt show NAME | a package's description, version and size |
sudo apt install NAME | installs it (-y answers yes for you) |
apt list --installed | everything installed |
sudo apt upgrade | installs newer versions of what you have |
sudo apt remove NAME | removes it (purge removes its settings too) |
Installing needs sudo, because it changes the whole system. Searching and showing don't.
apt search treeapt show treeA 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:
| System | Install a package |
|---|---|
| Ubuntu, Debian | sudo apt install tree |
| Fedora, Red Hat | sudo dnf install tree |
| Arch | sudo 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.
Your task
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.
- Refresh the package list (not done yet)
- tree is installed and shows projects (not done yet)
- nginx is installed and running (not done yet)
- curl localhost gets its welcome page (not done yet)
The checklist ticks itself off as you work in the terminal: any way that gets the result counts.
Hints come one at a time, then one way to do it. Try each before the next.
What this lesson uses, in one place.
apt update- Refresh the list of packages and versions (sudo apt update) More on apt
apt install- Install packages (sudo apt install NAME) More on apt
apt- Install, remove and search for software (Ubuntu and Debian) More on apt
dpkg- List installed packages
Every everyday command on one page: the Linux commands cheat sheet.