diff --git a/knowledge base/apt.md b/knowledge base/apt.md index 942d7f4..02516aa 100644 --- a/knowledge base/apt.md +++ b/knowledge base/apt.md @@ -3,17 +3,77 @@ ## TL;DR ```sh -# mark all packages as non-explicitly installed -apt-mark auto $(sudo apt-mark showmanual) +# Update the packages lists. +sudo apt update -# remove orphaned packages -apt autoremove --purge +# Upgrade the system. +sudo apt upgrade +sudo apt dist-upgrade + +# Look for packages. +apt search 'ansible' +apt search --names-only 'python' + +# Show details of packages. +apt show 'vlc' + +# List a package's dependencies. +apt depends 'ufw' + +# Install packages. +sudo apt install 'nano' 'python3-zstd/stable' + +# Remove packages. +sudo apt remove 'dhclient' 'sudo' +sudo apt remove --purge 'bluez' +sudo apt purge 'crda' + +# Remove orphaned packages. +sudo apt autoremove --purge + +# List packages. +sudo apt list +sudo apt list --upgradable +sudo apt list --installed + +# List explicitly installed packages only. +sudo apt-mark showmanual + +# Mark packages as explicitly installed. +sudo apt-mark manual 'vim' 'unattended-upgrades' + +# List non-explicitly installed packages only. +sudo apt-mark showauto + +# Mark packages as non-explicitly installed. +sudo apt-mark auto 'zsh' 'bash-completion' +sudo apt-mark auto $(sudo apt-mark showmanual) + +# Reconfigure packages. +sudo dpkg-reconfigure 'mariadb-server' +``` + +## Automate security upgrades + +Leverage `unattended-upgrades` for this. + +```sh +# Check what packages would be installed. +sudo unattended-upgrade -d --dry-run + +# Run manually. +sudo unattended-upgrade ``` ## Further readings - [Apt configuration] - [Configuring Apt sources] +- [Unattended Upgrades] +- [cheat.sh] + [apt configuration]: https://wiki.debian.org/AptConfiguration [configuring apt sources]: https://wiki.debian.org/SourcesList +[unattended upgrades]: https://wiki.debian.org/UnattendedUpgrades +[cheat.sh]: