apt
install software on Debian and Ubuntuapt is the package manager for Debian-family systems. It downloads a program and everything it depends on from the distribution’s repositories, and later updates the whole system with two commands.
apt update refreshes the list of what is available; apt upgrade installs the newer versions.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
Hit means the list has not changed; Get means a newer one was downloaded. No software is installed by this step.
Twelve installed packages have newer versions. "apt upgrade" would install them.
apt works out what else is needed and lists everything it will do before doing it.
One new package, nothing removed. Larger changes ask for confirmation at this point.
Switches
A switch changes how the command behaves. These are the ones used day to day; man apt lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-y- Answer yes to prompts. For scripts.
--no-install-recommends- Install only the hard dependencies, not the suggested extras.
-s- Simulate: show what would happen, change nothing.
--purge- With remove, also delete the package’s configuration files.
--reinstall- With install, install the package again over itself.
-f- Fix broken dependencies.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
sudo apt update && sudo apt upgradeThe routine update: refresh the list, then install what is newer.
apt search "packet capture"Searches package names and descriptions.
apt show nginxShows a package’s version, size, dependencies and description.
sudo apt autoremoveRemoves packages that were installed as dependencies and are no longer needed.
In cybersecurity
Updating is the single most effective security task on a Linux machine.
The fix usually existed before the attack. Regular "apt update && apt upgrade", or unattended-upgrades, closes those doors.
apt verifies every repository’s signature. A warning about an unsigned or changed repository should stop you, not be clicked through.
Adding a repository gives its owner the power to install software as root on your machine at every update. Add as few as you can.