Debian GNU/Linux, the foundational operating system for several Linux distributions including Knoppix, Kali, Ubuntu, Mint, etc., uses various package managers such as dpkg, apt, apt-get, aptitude, synaptic, tasksel, deselect, dpkg-deb, and dpkg-split.
We will briefly describe each of these package managers before focusing on the ‘dpkg‘ command.
Command | Description |
---|---|
apt | apt, short for advanced package tool in Debian-based systems used to install, remove, and update software packages. |
aptitude | aptitude is a text-based package manager for Debian which is a front-end to ‘apt‘, enabling users to manage packages easily. |
synaptic | synaptic is a graphical package manager that makes it easy to install, upgrade, and uninstall packages even for novices. |
tasksel | tasksel allows users to install all relevant packages related to a specific task, such as a desktop environment. |
deselect | deselect is a menu-driven package management tool initially used during the first install and is now replaced with aptitude. |
dpkg-deb | dpkg-deb interacts with Debian archives. |
dpkg-split | dpkg-split is useful for splitting and merging large files into chunks of smaller files to be stored on media of smaller sizes, such as floppy disks. |
dpkg is the main package management program in Debian and Debian-based systems that is used to install, build, remove, and manage packages. aptitude is the primary front-end to dpkg.
Some of the most commonly used dpkg commands along with their usages are listed here:
1. Install a Package on Ubuntu
To install a package using dpkg, you need to download .deb
package file from the following official package repository sites for Debian and Ubuntu-based distributions.
Once downloaded, you can install it using the -i
option followed by the name of the .deb
package file.
sudo dpkg -i 2048-qt_0.1.6-2+b2_amd64.deb
2. List Installed Packages on Ubuntu
To view and list all the installed packages, use the “-l
” option along with the command.
dpkg -l
To view a specific package installed or not use the option “-l
” along with the package name. For example, check whether the apache2 package is installed or not.
dpkg -l apache2
3. Remove a Package on Ubuntu
To remove the “.deb
” package, we must specify the package name “2048-qt” with the “-r” option, which is used to remove/uninstall a package.
sudo dpkg -r 2048-qt
You can also use ‘p
‘ option in place of ‘r'
which will remove the package along with the configuration file. The ‘r
‘ option will only remove the package and not the configuration files.
[root@tecmint~]# dpkg -p flashpluginnonfree
4. View Contents of a .deb Package
To view the content of a particular .deb
package, use the “-c
” option, which will display the contents of a deb package in long-list format.
dpkg -c 2048-qt_0.1.6-2+b2_amd64.deb
5. Check Status of Deb Package Installation
Using “-s
” option with the package name will display whether a deb package is installed or not.
dpkg -s 2048-qt
6. List Files Installed by Deb Package
To list the location of all the files installed by a particular package use the -L
option as shown.
dpkg -L 2048-qt
7. Install Multiple Deb Packages from a Directory
Recursively install all .deb
files found in specified directories and all of their subdirectories, use the '-R'
and '--install'
options.
For example, to install all '.deb'
packages from the directory named ‘debpackages‘.
sudo dpkg -R --install debpackages
8. Extract Contents of a Deb Package
To extract the contents of a .deb
package but does not configure the package, use the --unpack
option.
sudo dpkg --unpack 2048-qt_0.1.6-2+b2_amd64.deb
9. Reconfigure a Unpacked Deb Package
To configure a package that has been unpacked but not yet configured, use the “--configure
” option as shown.
sudo dpkg --configure flashplugin-nonfree
10. Updating Package Information in System Database
The “–-update-avail
” option replaces the old information with the available information for the package file in the package management system’s database.
sudo dpkg --update-avail package_name
11. Delete Information of Package
The action “--clear-avaial
” will erase the current information about what packages are available.
sudo dpkg –-clear-avail
12. Forget Uninstalled and Unavailable Packages
The dpkg command with the option “–forget-old-unavail” will automatically forget uninstalled and unavailable packages.
sudo dpkg --forget-old-unavail
13. Display dpkg Licence
dpkg --licence
14. Display dpkg Version
The “--version
” argument will display dpkg version information.
dpkg –version
15. View dpkg Help
The “--help
” option will display a list of available options of the dpkg command.
dpkg –help
That’s all for now. I’ll soon be here again with another interesting article. If I’ve missed any command in the list do let me know via comments.
Till then, Stay tuned and Keep connected to Tecmint. Like and share with us and help us spread. Don’t forget to mention your valuable thoughts in a comment.
Hello,
“dpkg -p flashpluginnonfree”
Should be -P for purge, not -p
I would like to remove some of the columns from the output of
dpkg -l
. I would also like to list just the packages I installed manually after a fresh Ubuntu installation or upgrade.I’ve installed cinnamon on my raspi 3 I’m a newbie, how do I extract it? where is it, I’ve tried all the above but to no avail.
I have got this error. How to solve it?
Setting up gnome-menus (3.13.3-9) …
/var/lib/dpkg/info/gnome-menus.postinst: 10: /var/lib/dpkg/info/gnome-menus.postinst: gnome-menus-blacklist: not found
dpkg: error processing package gnome-menus (–configure):
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
gnome-menus
E: Sub-process /usr/bin/dpkg returned an error code (1)
this is a perfect article.
To remove a package with configuration I think it is “-P” in caps. which is –purge. Removes a package including configuration files.
An example getting the package owning a specific file or directory might be helpful i.e.:
dpkg -S /usr/bin/nice
–>coreutils: /usr/bin/nice
At least I need this one occasionally for administrative purposes.
GREAT!
THANX.
@LinuxEnthusiastic:
1. dkpg is still a pre-requisite for passing LPIC-1 certification.
2. It’s largely distro-neutral. Sure, I can bypass dpkg on my Ubuntu machine by just using Ubuntu Software Centre (built over Synaptic, which is built over APT, which is built over dpkg), but the day I hit a non-Ubuntu Debian, I’m stuffed – unless I go back to source.
3. APT may be smarter (do you really mean “more user-friendly”?) but I think dpkg gives you more control, and for an administrator that would matter more.
Who use dpkg??
well APT is much smarter.
Well I Think, This article could have been a bit more Elaborative.