The apt command
command-line interface 22 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.
Subcommands in the examples
apt install- Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match.
apt list- list is somewhat similar to dpkg-query --list in that it can display a list of packages satisfying certain criteria.
apt update- update is used to download package information from all configured sources.
apt autoremove- autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer…
apt autocleanapt remove- Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match.
apt search- search can be used to search for the given regex(7) term(s) in the list of available packages and display matches.
apt upgrade- upgrade is used to install available upgrades of all packages currently installed on the system from the sources configured via…
apt full-upgrade- full-upgrade performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a…
apt purge- Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match.
apt show- Show information about the given package(s) including its dependencies, installation and download size, sources the package is available…
Examples
sudo apt update
apt list --upgradable
sudo apt upgradeUpgrade everything that's safe to upgrade
sudo apt full-upgradeAlso handles dependency changes (may remove packages)
apt --version
sudo apt install htop
sudo apt install htop tree curlMultiple at once
sudo apt install -y htopAuto-confirm prompts
sudo apt remove htopRemoves the program, keeps config files
sudo apt purge htopRemoves the program AND its config files
sudo apt autoremoveRemoves packages that were only installed as dependencies and are no longer needed
sudo apt autocleanClears out old downloaded .deb files from cache
sudo apt install --reinstall htop
sudo apt install nginx
sudo apt remove --purge htop
apt search nginx
apt search "web server"
apt show nginx
apt list --installed
apt list --installed | grep nginx
sudo apt install -f"Fix" — installs missing dependencies
sudo apt install gitMake sure git is available
Lessons that use apt
- apt — Package Manager Basics
- Installing & Removing Packages
- Searching & Inspecting Packages
- dpkg — Low-Level Package Tool
- nginx — Your First Web Server
- Mission: New Hire Setup
- Mission: The Upgrade Window