The packages are managed using the apt command-line tool in Debian-based Linux distributions, including Ubuntu, Debian, Linux Mint, and others. We can utilize the apt package manager to delete, add, update and upgrade the packages. This tool is very helpful in removing packages from the system.
This quick guide will explain the methods for uninstalling the package with apt package manager using this outline:
- Method 1: Uninstalling the Packages Using the “apt remove”
- Method 2: Uninstalling Packages Using the “apt autoremove”
- Method 3: Uninstalling the Packages Using the “apt purge”
- Remove Cache Files Using apt Package Manager
Method 1: Uninstalling the Packages Using the “apt remove”
The most commonly used command to uninstall packages in Debian derivatives is the “apt remove” command. The apt remove command uninstalls the package only, but related configuration files and dependencies are not deleted.
Delete Only Executable Files of a Package
To uninstall the vim package with the apt remove command, run this command as we did here to remove the vim:
$ sudo apt remove vim
Before deleting the package, a confirmation prompt will open up; write “y” to continue uninstalling the package.
Delete Package Without Asking For Permission
To avoid the confirmation prompt and remove the package directly, use the “y” option with the apt remove command as shown below:
$ sudo apt remove vim -y
The output shows that the vim package is indirectly deleted this time without asking for confirmation.
Delete Multiple Packages
We can delete multiple packages with a single apt remove command by writing their names with spaces. For instance, to remove three packages simultaneously, execute this command:
$ sudo apt remove package-1 package-2 package-3
It will remove all three packages at once with a single command.
Method 2: Uninstalling Packages Using the “apt autoremove”
To remove the deleted package dependencies that remain in the system after deleting the package, we can use the “autoremove” command.
We used the “autoremove” command to remove the package named “vim”:
$ sudo apt autoremove vim
The Vim package dependencies are removed.
Method 3: Uninstalling the Packages Using the apt purge
Another way to uninstall the package with the apt package is by utilizing the apt purge command. The specified package with configuration files is removed with the apt-purge command.
Remove Package and the Configuration Files
To uninstall the vim package in Linux using the apt manager, run the below-stated command:
$ sudo apt purge vim
The vim application and its config file are uninstalled.
Remove the Package, Configuration Files, and Dependencies
We can remove the vim package completely, including the vim package, its configuration files, and dependencies, by running the below single command:
$ sudo apt purge --auto-remove vim
The vim package is completely uninstalled from the system.
How to Remove Cache Files Using apt Package Manager?
If you have installed one program more than once and deleted the package, there might be some cache of that package files that remained in the system. These cache files can be deleted for the package with the apt clean command:
$ sudo apt clean vim
The cache files for the vim package are also deleted.
Conclusion
The commands to uninstall packages using apt package manager are: “sudo apt remove <package-name>”, “sudo apt autoremove <package-remove>”, and “sudo apt purge –autoremove <package-name>”. This post has practically demonstrated the working of all the commands to uninstall packages using the apt package manager.