- Hack Your Life! - http://www.hackourlife.com -

How to Install or Remove DEB Packages Using dpkg (Ubuntu / Debian)

This post explains how to install, uninstall, verify deb packages on Debian or Ubuntu. dpkg is the command that allows one to install or uninstall a .deb package in Ubuntu or Debian Linux. Here is how to use it.

Before we begin, it is important to note that you should use dpkg only in the event of unavailability of package through apt-get or aptitude.

Installing a Deb Using dpkg -i

syntax: dpkg -i package-file-name

-i is to install a package. To verify or check for a package already installed use dpkg -l followed by grepping for packagename as shown below:

dpkg -l | grep -i 'subsonic'

Output would show something like this:

ii  subsonic    4.7    A web-based music streamer, jukebox and Podcast receiver

The above command shows that the package subsonic is installed properly. ‘ii’ specifies status ‘installed ok installed’.

Removing or Uninstalling a Deb using dpkg -r

dpkg with -r option removes the installed package. As shown below:

sudo dpkg -r subsonic
(Reading database ... 42139 files and directories currently installed.)
Removing subsonic ...
 Removing any system startup links for /etc/init.d/subsonic ...
   /etc/rc0.d/K99subsonic
   /etc/rc1.d/K99subsonic
   /etc/rc2.d/S99subsonic
   /etc/rc3.d/S99subsonic
   /etc/rc4.d/S99subsonic
   /etc/rc5.d/S99subsonic
   /etc/rc6.d/K99subsonic
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot

Now lets check the status of the package again.

dpkg -l | grep -i 'subsonic'
rc  subsonic  4.7   A web-based music streamer, jukebox and Podcast receiver

rc stands for ‘removed ok config-files’. The remove action doesn’t purge the configuration files. The status of each installed package will be available in /var/lib/dpkg/status. We can remove the config files using this:

sudo dpkg -P subsonic
(Reading database ... 42131 files and directories currently installed.)
Removing subsonic ...
Purging configuration files for subsonic ...
 Removing any system startup links for /etc/init.d/subsonic ...
dpkg: warning: while removing subsonic, directory '/var/subsonic' not empty so not removed.

That should remove the package completely.