Installing programs using apt or Ubuntu Software in Ubuntu and other Debian derivatives will copy the binaries and configuration files to the intended locations. However, uninstalling with these tools will only remove the binaries, leaving the configuration and generated data files intact.

You can also set apt to remove the configuration files in the /etc folder along with the data that usually resides in the /var folder when uninstalling a program. However, user-specific data stored in the user’s home directory will have to be manually deleted.

Steps to completely remove program 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)