Remove packages using dpkg

dpkg can be used to

  1. install packages
  2. remove packages
  3. know the current status of packages

When we decide to remove a package, we must be clear that we want to remove or purge a package. When we remove packages using dpkg, it does not remove the configuration files and the state of a package will be rc.

Let’s remove a package called vim (assuming it is present in your system)

$ sudo dpkg --remove vim
(Reading database ... 239395 files and directories currently installed.)
Removing vim ...
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/vi (vi) in auto mode.
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/view (view) in auto mode.
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/ex (ex) in auto mode.
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/rview (rview) in auto mode.

Let’s see the status of the package

dpkg --list vim
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                              Description
+++-====================================-====================================-========================================================================================
un  vim                                  <none>                               (no description available)

The state is un, because there were no configuration files corresponding to vim and the package is now completely uninstalled. Read more about package states.

Let’s see the status of one other package called usplash whose state is rc (the configuration files are still present)

$ dpkg --list usplash

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                              Description
+++-====================================-====================================-========================================================================================
rc  usplash                              0.5.49                               Userspace bootsplash utility

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s