Whenever you uninstall or remove a program in Ubuntu or Debian using apt / apt-get or the Ubuntu Software, only the binaries are removed but some of the related configuration and data files are left on your system.

You can remove the configuration files which are normally in the /etc folder along with the data which normally resides in the /var folder when uninstalling a program. User-specific data which is stored in the user's home directory will have to be manually deleted.

Steps to remove all configuration and data when uninstalling application in Ubuntu and Debian:

  1. Launch terminal.
  2. Search for package name if you dont know the exact name.
    $ sudo apt list --installed | grep mariadb
    
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    
    mariadb-client-10.3/focal,now 1:10.3.22-1ubuntu1 amd64 [installed,automatic]
    mariadb-client-core-10.3/focal,now 1:10.3.22-1ubuntu1 amd64 [installed,automatic]
    mariadb-common/focal,now 1:10.3.22-1ubuntu1 all [installed,automatic]
    mariadb-server-10.3/focal,now 1:10.3.22-1ubuntu1 amd64 [installed,automatic]
    mariadb-server-core-10.3/focal,now 1:10.3.22-1ubuntu1 amd64 [installed,automatic]
    mariadb-server/focal,now 1:10.3.22-1ubuntu1 all [installed]
  3. Fully remove the program along with config files using apt.
    $ sudo apt purge mariadb-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      galera-3 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
      libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl
      libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
      libhttp-date-perl libhttp-message-perl libio-html-perl
      liblwp-mediatypes-perl libmysqlclient21 libsnappy1v5 libterm-readkey-perl
      libtimedate-perl liburi-perl mariadb-client-10.3 mariadb-client-core-10.3
      mariadb-common mariadb-server-10.3 mariadb-server-core-10.3 mysql-common
      socat
    Use 'sudo apt autoremove' to remove them.
    The following packages will be REMOVED:
      mariadb-server*
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 68.6 kB disk space will be freed.
    Do you want to continue? [Y/n]
    ##### snipped
  4. Confirm deletion if asked.
  5. Completely remove unused dependent packages along with configuration file.
    $ sudo apt autoremove --purge
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      galera-3* libcgi-fast-perl* libcgi-pm-perl* libconfig-inifiles-perl*
      libdbd-mysql-perl* libdbi-perl* libencode-locale-perl* libfcgi-perl*
      libhtml-parser-perl* libhtml-tagset-perl* libhtml-template-perl*
      libhttp-date-perl* libhttp-message-perl* libio-html-perl*
      liblwp-mediatypes-perl* libmysqlclient21* libsnappy1v5*
      libterm-readkey-perl* libtimedate-perl* liburi-perl* mariadb-client-10.3*
      mariadb-client-core-10.3* mariadb-common* mariadb-server-10.3*
      mariadb-server-core-10.3* mysql-common* socat*
    0 upgraded, 0 newly installed, 27 to remove and 0 not upgraded.
    After this operation, 173 MB disk space will be freed.
    Do you want to continue? [Y/n]
    ##### snipped 
  6. Check if configuration and data files still exist.
    $ sudo ls -l /etc/mysql /var/lib/mysql
    ls: cannot access '/etc/mysql': No such file or directory
    ls: cannot access '/var/lib/mysql': No such file or directory

    Some program does not properly clean up so the configuration and data files might still exist.

Guide compatibility:

Operating System
Ubuntu 16.04 LTS (Xenial Xerus)
Ubuntu 16.10 (Yakkety Yak)
Ubuntu 17.04 (Zesty Zapus)
Ubuntu 17.10 (Artful Aardvark)
Ubuntu 18.04 LTS (Bionic Beaver)
Ubuntu 18.10 (Cosmic Cuttlefish)
Ubuntu 19.04 (Disco Dingo)
Share this guide!
Discuss the article:

Comment anonymously. Login not required.

Share!