apt-get install package1 package2
apt-get install --reinstall package1
Pinning packagesIf you need to pin a specific version of the package from being upgraded you can put the following into the /etc/apt/preferences.d/ directory (file libsasl2):
Package: libsasl2-2 Pin: version 2.1.23.dfsg1-8 Pin-Priority: 1001
Searching databaseThe arguments to apt-cache search are regular expressions themselves, and if more than one argument is specified, all of them have to match for a package to be included in the output.
apt-cache search packge1 apt-cache show packge1
Inquiring about package dependenciesDepends:
apt-cache depends packge1Reverse Depends:
apt-cache rdepends packge1
Deinstalling and purging packagesTo remove a package’s configuration files as well, specify the --purge option.
apt-get remove package1 apt-get remove --purge package1
Upgrading a stable systemExecuting this update/upgrade sequence on a regular basis will keep the system running smoothly and securely.
apt-get update apt-get --show-ugraded upgrade
Upgrading to a new Debian releaseWhen it is time to upgrade the entire system.
apt-get --show-upgraded dist-upgradeWith apt-get dist-upgrade, APT can pull in new packages and even remove packages that have been obsoleted.
HousekeepingAPT keeps its packages in a local cache (unless the file or cdrom acquisition method is used). Over time, the cache directory can fill up and consume vast amounts of space, especially on systems tracking testing or unstable. APT does not manage the contents of its cache directory /var/cache/apt/archives automatically. Instead, apt-get provides two methods to erase files in the cache. The first cleanup method checks each file in the cache and erases it only if it is not available on the mirrors anymore.
apt-get autocleanThe following removes all DEB files regardless of their availability on the mirror or not.
Resolving problemsLet APT handle the inconsistency automatically:
apt-get --fix-broken install
cron-aptThe cron-apt tool is designed to be invoked by cron to perform routine APT operations. It uses several directories below /etc/cron-apt for its configuration.
# Every night at 4 o'clock. 0 4 * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-aptOut of the box, the tool comes to life at a random moment between 4 and 5 o’clock (you can adjust schedule in /etc/cron.d/cron-apt) to update its cache and download all upgraded packages without installing them (using the --download-only option to apt-get).
apt-get install cron-aptI highly discourage the use of cron-apt to upgrade packages from the main Debian archive.