How to remove & Purge any package from Linux Ubuntu completely

Remove a package from Linux UBUNTU machine completely or purge uninstalled package from Ubuntu box


Some time when remove any package from Ubuntu machine, it does not remove completely (Configuration file does not get remove). So here i am going to demonstrate how to remove package and config file completely.

Step 1 - Check installed package using dpkg command.

root@web02:~# dpkg --list vsftpd

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
ii  vsftpd                                    3.0.3-3ubuntu2            amd64                     lightweight, efficient FTP server written for security
root@web02:~#

In above example vsftpd package is installed, lets remove it. using command apt remove.

root@web02:~# apt remove vsftpd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  vsftpd
0 upgraded, 0 newly installed, 1 to remove and 44 not upgraded.
After this operation, 336 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 26227 files and directories currently installed.)
Removing vsftpd (3.0.3-3ubuntu2) ...
Processing triggers for man-db (2.7.5-1) ...
root@web02:~#

Vsftpd package has been removed succssfully, Now lets query and check package again using dpkg command.

root@web02:~# dpkg --list vsftpd

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
rc  vsftpd                                    3.0.3-3ubuntu2            amd64                     lightweight, efficient FTP server written for security
root@web02:~#

In above query vsftpd package has been remove but still package showing as rc. 

RC means selected package is R - remove/deinstall and C - config file available (only the config files are installed). Sometime we required to remove all the configuration file as well.

Let's remove RC package using apt purge command.


root@web02:~# apt purge vsftpd

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  vsftpd*
0 upgraded, 0 newly installed, 1 to remove and 44 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 26175 files and directories currently installed.)
Removing vsftpd (3.0.3-3ubuntu2) ...
Purging configuration files for vsftpd (3.0.3-3ubuntu2) ...
root@web02:~#

VSFTPD package and configuration file has been purged successfully, let's query and see if config file also remove.


root@web02:~# dpkg --list vsftpd

dpkg-query: no packages found matching vsftpd

No RC package and Config file is available in Ubuntu machine, Let's query using * method so that i will pull all the information.


root@web02:~# dpkg --list vsftpd*
dpkg-query: no packages found matching vsftpd*
root@web02:~#

Package and Config file  not found. You successfully removed.

!!!!!!!!!!!!  CHEERS  !!!!!!!!!