dpkg is a package manager for Debian oriented system,
It is very useful tool for install, build, manage and remove packages. Also can support debian/Ubuntu based operating system, like Mint,kubuntu,etc. We cannot download and install packages automatically. This post describe how to maintain the dpkg on the system.
1. How to Install a Package:
-i is to be install .deb package or we can use --install. For example,
# dpkg -i packagename.deb
dpkg -i firefox-mozilla-build_31.0-0ubuntu1_amd64.deb
2. List Installed Packages:
List all the installed packages on your system use -l
dpkg -l
or
dpkg --get-selections
3. Get Specific Installed package:
Do you like to view Specific package installed on your system,
dpkg -l | grep samba
ii samba 2:3.6.18-1ubuntu3 i386 SMB/CIFS file, print, and login server for Unix
ii samba-common 2:3.6.18-1ubuntu3 all common files used by both the Samba server and client
ii samba-common-bin 2:3.6.18-1ubuntu3 i386 common files used by both the Samba server and client
or
dpkg --get-selections | grep samba
samba install
samba-common install
samba-common-bin install
4. To check your installed package size:
echo "Space Package Name" && echo " --------------------------" && dpkg-query --show --showformat='${Package;}\t${Installed-Size}\n'|grep -v deinstall|awk '{ printf "%.2f MB \t %s \n", $2/(1024),$1}'|grep firefox
Space Package Name
--------------------------
60.30 MB firefox
0.87 MB firefox-locale-en
0.06 MB kubuntu-firefox-installer
5. To know list of package content:
dpkg -c liblqr-1-0_0.4.1-2_i386.deb
drwxr-xr-x root/root 0 2012-06-08 20:34 ./
drwxr-xr-x root/root 0 2012-06-08 20:34 ./usr/
drwxr-xr-x root/root 0 2012-06-08 20:34 ./usr/lib/
drwxr-xr-x root/root 0 2012-06-08 20:34 ./usr/lib/i386-linux-gnu/
-rw-r--r-- root/root 79312 2012-06-08 20:34 ./usr/lib/i386-linux-gnu/liblqr-1.so.0.3.1
6. To Check Installed Package Location:
To get list files installed to your system from package-name. For example use firefox,
dpkg -L firefox
/.
/usr
/usr/bin
/usr/lib
/usr/lib/firefox-addons
7. Fix a broken package:
dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
If you may get an error same as above run the command
dpkg --configure -a
8. Determine whether a Package is installed or not:
dpkg -s samba
Package: samba
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 22064
Maintainer: Ubuntu Developers
Architecture: i386
Version: 2:3.6.18-1ubuntu3
Replaces: samba-common (<= 2.0.5a-2)
9. Remove a Package:
Do you want to remove the Firefox from your system try with below command.
# sudo dpkg -r package_name
sudo dpkg -r firefox
10. Find out dpkg version:
dpkg --version
Debian `dpkg' package management program version 1.16.12 (i386).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
11. For more command:
dpkg --help
Just use the above dpkg command with Enjoy!.
Comments (0)