Using DPKG and APT to install software on Debian-based distributions of Linux By Armando Caussade, http://armandocaussade.org/ Version 2.2. August 3, 2019. Copyright © 2019 Armando Caussade. Some rights reserved. Creative Commons License BY-NC-ND 4.0. ----- INTRODUCTION I use a variety of software packages on my Linux computers, which I install almost exclusively using DPKG and APT. Both DPKG and APT work with DEB-type installable files, and the samples included below serve to illustrate most uses. The DPKG system (DPKG stands for Debian Package) is a low level utility used to install and remove packages under Debian-based distributions of Linux (Debian, Ubuntu, Linux Mint, etc.). Installations can only be done locally, since packages cannot be retrieved from Internet repositories, and in most cases dependency issues cannot be resolved. On the other side, the APT system (APT stands for Advanced Packaging Tool) is a high-level collection of utilities that can search and install packages on a Linux system by connecting to Internet repositories; packages can also be removed and reinstalled. Being a higher-level tool, APT is able to resolve system dependencies intelligently. EXAMPLES OF DPKG 1. To list all packages installed on a Linux System: $ dpkg -l 2. To list all files associated with a package: $ dpkg -L # Used with installed packages. $ dpkg -c "package.deb" # Used with installable DEB files. 3. To show information about a specific package: $ dpkg -s # Used with installed packages. $ dpkg -I "package.deb" # Used with installable DEB files. 4. To show what package owns a file on a Linux System: $ dpkg -S /path/file 5. To install a DEB file: $ sudo dpkg -i ./ # This is the standard way to install a DEB file. $ sudo dpkg -i --force-architecture ./ # This will force the installation of a 32-bit DEB file into a 64-bit system. 6. To remove a package from a Linux system, while keeping configuration files: $ sudo dpkg -r # This will remove the software, while keeping log and configuration files. $ sudo dpkg -P # This will remove everything, including logs and configuration. EXAMPLES OF APT 1. To update the Internet repositories on a Linux system: $ sudo apt-get update 2. To upgrade the software that is already installed on a Linux system: $ sudo apt-get upgrade # This installs newest versions of all packakes in the system. $ sudo apt-get dist-upgrade # In addition to upgrading, this intelligently handles package dependencies. $ sudo apt-get full-upgrade # In addition to upgrading, this may also remove installed packages that may conflict. 3. To search for installed packages on a Linux system: $ apt-cache search # This checks whether the packake has been installed. $ apt-cache show # This provides basic details about the packake. $ apt-cache list # This lists all files associated with the package. $ apt-cache depends # This lists all dependencies required by the package. 4. To download a package from an Internet repository, without installing: $ sudo apt-get download # This downloads an installable DEB file to the current directory. $ sudo apt-get install --download-only # This downloads a package with all dependencies to /var/cache/apt/archives, without installing. $ sudo apt install --simulate ./ # This does not install anything, but will list dependencies required by an installable DEB file. $ sudo apt-get source # This downloads the source code of the package. 5. To install a package, with dependencies, from the Internet repositories: $ sudo apt-get install # This will download a package from the distribution's repository and install it. $ sudo apt-get install ./ # This will install a local, installable DEB file. $ sudo apt-get install -f # This attempts to download and install missing dependencies from a previously installed package. 6. To reinstall a broken package: $ sudo apt-get install --reinstall # This will download and reinstall from the distribution's repository. $ sudo apt-get install ./ --reinstall # This will reinstall a local, installable DEB file. 7. To remove a package from a Linux system: $ sudo apt-get remove # This will remove the software, while keeping log and configuration files. $ sudo apt-get purge # This will remove everything, including logs and configuration. 8. To clean out a Linux system of old packages: $ sudo apt-get autoremove # This will remove installed software packages that are no longer necessary. $ sudo apt-get clean # This will remove archived package files that have already been installed. ###