Installing programs using apt or Ubuntu Software in Ubuntu and other Debian derivatives will download and install deb packages from the repositories, along with the dependencies. These deb packages, among others, contain executables, configuration files, and man files. These files are copied to the appropriate locations when a package is installed. The installation might also create data files or directories for the application.

Not all of these files are deleted when you uninstall an application using apt or apt-get using the remove option. The dependent packages are also left intact on your Ubuntu system.

You can use apt to remove program binaries along with the configuration and other files. apt can also uninstall unused dependent packages. However, you must manually delete user-specific configuration and data (dotfiles) in the user's home directory.

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.

Discuss the article:

Comment anonymously. Login not required.