When you install programs in Ubuntu using apt or the Ubuntu Software Center, they download and install .deb packages along with their dependencies. These packages include executables, configuration files, and manual pages, which are placed in the appropriate system directories. During the installation, additional data files or directories specific to the application may also be created.
Uninstalling an application using apt or apt-get with the remove option doesn't delete all associated files. Dependencies and configuration files often remain on the system, leading to unnecessary clutter and potential conflicts if the package or its dependencies are reinstalled. To maintain system efficiency and organization, it's crucial to ensure a clean removal of these residual files.
To fully remove an application and its configuration files from Ubuntu, additional steps are required. This ensures that program binaries, configuration files, and other associated files are completely deleted. While apt can handle most components' removal, user-specific configuration and data files in the user's home directory might need manual deletion. A thorough cleanup helps maintain a clean system environment and optimizes disk space usage.
Steps to completely remove program in Ubuntu and Debian:
- Launch the terminal.
- Search for the package name if you don't 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]
- Fully remove the program along with its configuration 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
- Confirm deletion if prompted.
- Remove unused dependent packages along with their configuration files.
$ 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
- Check if configuration and data files still exist and delete them manually if necessary.
$ 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.
This guide is tested on Ubuntu:
Version | Code Name |
---|---|
22.04 LTS | Jammy Jellyfish |
23.10 | Mantic Minotaur |
24.04 LTS | Noble Numbat |
![](https://www.simplified.guide/_media/page/author/shakir/mohd-shakir-zakaria.jpg?w=200&tok=d15487)
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.