Update and upgrade
sudo apt update
Refresh the package lists
sudo apt upgrade
Upgrade, never remove packages
sudo apt full-upgrade
Upgrade, allow removals if needed
Use it when upgrade holds packages back; read the removal list
first.
apt list --upgradeable
List packages with updates
sudo apt install --only-upgrade <pkg>
Upgrade one package only
sudo apt -s upgrade
Simulate, change nothing
sudo apt -y upgrade
Answer yes to prompts
sudo apt-get dist-upgrade
Script-friendly full-upgrade
Install and remove
sudo apt install <pkg>
Install a package
sudo apt install <pkg1> <pkg2>
Install several at once
sudo apt remove <pkg>
Remove, keep config files
sudo apt purge <pkg>
Remove including config files
sudo apt autoremove
Remove unneeded dependencies
sudo apt autoremove --purge
Also delete their config
sudo apt install ./<file>.deb
Install a local .deb with deps
sudo apt reinstall <pkg>
Reinstall a package
sudo apt install <pkg>=<version>
Install an exact version
sudo apt install -t <release> <pkg>
Install from another release
sudo apt install --no-install-recommends <pkg>
Skip recommended packages
sudo apt install -f
Repair broken dependencies
sudo apt build-dep <pkg>
Install build dependencies
sudo apt satisfy "<dep-string>"
Install from a dependency string
Search and inspect
apt search <term>
Search names and descriptions
apt show <pkg>
Show version, depends, size
apt list --installed
List installed packages
apt list --installed | grep <name>
Is it installed?
apt list --all-versions <pkg>
Show every available version
apt policy <pkg>
Installed, candidate, sources
apt depends <pkg>
What a package needs
apt rdepends <pkg>
What needs a package
apt-cache pkgnames <prefix>
Complete package names
apt changelog <pkg>
Show the package changelog
apt download <pkg>
Fetch the .deb without installing
Sources and cache
sudo apt edit-sources
Edit the sources file
sudo apt modernize-sources
Convert .list to .sources
ls /etc/apt/sources.list.d/
See extra repositories
sudo apt clean
Delete all downloaded .deb files
sudo apt-get autoclean
Delete obsolete downloads only
du -sh /var/cache/apt/archives
Size of the download cache
apt -o Dir::Cache=<dir> update
Override a config option
apt-get check
Verify no broken dependencies
dpkg pairing
dpkg -l
List installed packages
dpkg -l <pattern>
Status of matching packages
dpkg -L <pkg>
Files a package installed
dpkg -S <path>
Which package owns a file
dpkg -s <pkg>
Installed status and details
sudo dpkg -i <file>.deb
Install a .deb, no deps
Does not fetch dependencies; follow with apt install -f if it
fails.
sudo dpkg --configure -a
Finish interrupted installs
dpkg --get-selections
Dump package selections
dpkg --print-architecture
Show native architecture
sudo dpkg --add-architecture <arch>
Enable a foreign architecture