High and low-level package tools
high-level tools (which are in charge of ensuring that the tasks of dependency resolution and metadata searching are performed).
low-level tools (which handle in the backend the actual installation, upgrade, and removal of package files).
dpkg is a low-level package manager for Debian-based systems. It can install, remove, provide information about and build *.deb packages but it can’t automatically download and install their corresponding dependencies.
When use dpkg?
Package not available in repository
You will most likely choose to install a package from a deb file when it not available in the distribution’s repositories and therefore cannot be downloaded and installed through a high-level tool. Since low-level tools do not perform dependency resolution, they will exit with an error if we try to install a package with unmet dependencies.
# dpkg -i file.deb
Listing installed packages
When you first get your hands on an already working system, chances are you’ll want to know what packages are installed.
list all currently installed packages
Find out file installed by which package
dpkg --search /etc/nginx/nginx.conf
Remove a package from system
dpkg -r package_name
'-r' only remove package but leaves configuration files
dpkg -P package_name
'-P' will remove package along with it's configuration files
View the contents of a deb package
dpkg -c package_name.deb
List the location of files installed from a package
dpkg -L package_name
Unpack a package without install or configure it
dpkg --unpack package_name.deb
Verify package integrity
dpkg -V [package_name]
Verifies the integrity of package-name or all packages if omitted, by comparing information from the installed paths with the database metadata.
apt (Advanced Package Tool) is the command-line tool for handling packages.
|apt install||apt-get install|
|apt search||apt-cache search|
|apt show||apt-cache show|
|apt update||apt-get update|
|apt list --installed||dpkg -l|
|apt edit-sources||vi /etc/apt/sources.list|
|apt autoremove||apt-get autoremove|
|apt puge||apt-get puge ; aptitude puge|
apt-get is a high-level package manager for Debian and derivatives, and provides a simple way to retrieve and install packages, including dependency resolution, download and installation. Unlike dpkg, apt-get does not work directly with *.deb files, but with the package name.
Download and unpack source code of package
apt-get source vsftpd
Download without installation
apt-get download vsftpd
Auto remove a package and it's sub-packages
The ‘autoremove‘ sub command is used to auto remove packages that were certainly installed to satisfy dependencies for other packages and but they were now no longer required.
apt-get autoremove vsftpd
Clean up .deb cache files
The ‘autoclean‘ command deletes all .deb files from /var/cache/apt/archives to free-up significant volume of disk space.
aptitude is another high-level package manager for Debian-based systems, and can be used to perform management tasks (installing, upgrading, and removing packages, also handling dependency resolution automatically) in a fast and easy way. It provides the same functionality as apt-get and additional ones, such as offering access to several versions of a package.
When use aptitude?
- Install or remove a package from repository
aptitude install package_name aptitude remove / purge package_name
` The option remove will uninstall the package but leaving configuration files intact, whereas purge will erase every trace of the program from your system.
- Search for a package
# aptitude search nginx p lua-nginx-memcached - Pure Lua memcached client driver for the n p lua-nginx-redis - Pure Lua redis client driver for the nginx i nginx - small, powerful, scalable web/proxy server v nginx:i386 - i A nginx-common - small, powerful, scalable web/proxy server i A nginx-core - nginx web/proxy server (core version)
|p||no trace of the package exists on the system|
|i||the package is installed|
|v||the package is virtual|
|A||the package was automatically installed|