Bootstrap FreeKB - Linux Commands - Using DPKG to manage Debian packages in Linux
Linux Commands - Using DPKG to manage Debian packages in Linux

Updated:   |  Linux Commands articles

First, download a .deb file to your computer. For example, this URL has the Wine .deb file: https://pkgs.org/debian-sid/debian-main-i386/wine_1.8.2-1_all.deb.html.

Use the -i or --install option to install or update a package.

[root@server1 ]# dpkg -i package_name.deb
[root@server1 ]# dpkg --install package_name.deb

 

Use the -R or--recursive option to install all of the packages listed in a particular directory.

[root@server1 ]# dpkg -R /home/user1/Downloads/
[root@server1 ]# dpkg --recursive /home/user1/Downloads/

 

The -C option can be used to ensure the package does not have some issue. In this example, there are a couple issues.

[root@server1 ]# dpkg -CThe following packages have been unpacked but not yet configured.They must be configured using dpkg --configure or the configuremenu option in dselect form them to work: wine    Windows API implementation - standard suiteThe following packages are only half configured, probably due to problemsconfiguring them the first time. The configuration should be retried usingdpkg --configure <package> or the configure menu option in dselect: isc-dhcp-server  ISC DHCP Server for automatic IP address assignment

 

The --configure option can be used to configure a package for the first time. For example, we can configure wine:

[root@server1 ]# dpkg --configure wine

 

Use the dpkg-reconfigure command to reconfigure a package that has already been installed.

[root@server1 ]# dpkg-reconfigure package_name.deb

 

One of the tricky options is to memorize the difference between an upper case -S and a lower case -s with dpkg. Use the upper case -S (or --search) option to list what package a file belongs to. In this example, the netstat package belongs to the net-tools package.

[root@server1 ]# dpkg -S /bin/netstat
net-tools: /bin/netstat

[root@server1 ]# dpkg --search /bin/netstat
net-tools: /bin/netstat

 

Use the -s or --status option displays information about the package. In this example, information about logrotate is displayed.

[root@server1 ]#dpkg -s package_name.deb[root@server1 ]#dpkg --status package_name.debPackage: logrotateStatus: install ok installedPriority: importantSection: adminInstalled-Size: 149Maintainer: Paul Martin <pm@debian.org>Architecture: i386Version: 3.8.1-4Depends: libc6 (>= 2.8), libpopt0 (>= 1.14), libselinux1 (>= 1.32), cron | anacron | cron-daemon, base-passwd (>= 2.0.3.4)Recommends: mailxBreaks: postgresql-common (<= 126)Conffiles: /etc/logrotate.conf 176edd439a499501372cf3d04e795810 /etc/cron.daily/logrotate d2281ecb6f898b446ac8a5984ab5a243Description: Log rotation utility The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files.  Logrotate allows for the automatic rotation compression, removal and mailing of log files.  Logrotate can be set to handle a log file daily, weekly, monthly or when the log file gets to a certain size.  Normally, logrotate runs as a daily cron job.

 

Use the -r or --remove option to uninstall a package, but keep the configuration file.

[root@server1 ]# dpkg -r package_name.deb
[root@server1 ]# dpkg --remove package_name.deb

 

Use the -P or --purge option to uninstall a package and also delete the configuration file.

[root@server1 ]# dpkg -P package_name.deb
[root@server1 ]# dpkg --purge package_name.deb

 

Use the -l or --list option to list information about a package.

[root@server1 ]# dpkg -l package_name.deb
[root@server1 ]# dpkg --list package_name.deb

 

Use the -L or --listfiles option to list all of the files used by the package (list where the files have been installed)

[root@server1 ]# dpkg -L package_name.deb
[root@server1 ]# dpkg --listfiles package_name.deb

 

Use the --contents option to view the contents of a .deb file.

[root@server1 ]# dpkg --contents package_name.deb
[root@server1 ]# dpkg --contents wine-version.deb
-rwxr-xr-x root/root      1153 2016-05-12 18:04 ./usr/bin/wine
drwxr-xr-x root/root         0 2016-05-12 18:04 ./usr/lib/
drwxr-xr-x root/root         0 2016-05-12 18:04 ./usr/lib/wine/
-rwxr-xr-x root/root       155 2016-05-12 14:21 ./usr/lib/wine/wineapploader
-rwxr-xr-x root/root       378 2016-05-12 14:21 ./usr/lib/wine/wineserver

 

Use the -I option to view all of the files and dependencies installed by the package.

[root@server1 ]# dpkg -I package_name

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 12ab90 in the box below so that we can be sure you are a human.