How to Uninstall Apt Packages from Ubuntu
Installed a package but no longer need it? Learn how to remove a package using the apt command in Ubuntu.
So you have installed a package, used it for a while and now you no longer need it.
And in that case, removing the package is the best way to save some extra space on your drive.
To remove a package from Ubuntu, you will have to execute a command in the following manner:
sudo apt remove [package_name]
Want more detailed steps for the removal of the package? Here's a detailed guide for you.
Remove packages from Ubuntu
To remove a package, you will have to enter the exact package name.
So let's start with how you can find the package's exact name.
Step 1: Find the name of the package
To list the installed packages, use the following command:
apt list --installed
And it will give you a long list of installed packages:
You may look for your package one by one but it is not a convenient way.
And in that case, you can use the grep command to filter the output by specifying the package name:
apt list --installed | grep 'package_name'
So let's say I want to look for a package named nala
so I will be using the following:
apt list --installed | grep 'nala'
Step 2: Remove the package
sudo apt remove
will only remove the package and the configuration files will remain intact. Once you know the exact package name, execute the command in shown fashion:
sudo apt remove [package_name]
So let's say I want to remove a package named nala
, so I will be using the following:
sudo apt remove nala
I would recommend using the --auto-remove
flag with the above command to remove packages that were automatically installed and are no longer required:
sudo apt remove --auto-remove [package_name]
Advanced Tip: Remove the package including config files on Ubuntu
As I mentioned earlier, using the apt remove
command will not remove the configuration file.
So if you want to remove the package, including the configuration files, you will have to use the purge
flag instead of remove
:
sudo apt purge [package_name]
But I would recommend using the --auto-remove
flag here too for removing packages that are not required anymore and just sitting there:
sudo apt purge --auto-remove [package_name]
So let's say I want to remove a package named nala
including the configuration files, then I will be using the following:
sudo apt purge --auto-remove nala
That's all it takes to remove the package, including the configuration files.
What's the difference between apt remove and apt purge?
If you are curious to learn more about the difference between apt remove
and apt purge
, we have a detailed guide for you:
I hope the given guide will solve the queries you previously had.
And if you still have doubts or suggestions, let me know in the comments.
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.