Uninstall packages in Ubuntu
How To

How to Uninstall Apt Packages from Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

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:

list installed packages on ubuntu

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'
search for specific package from the list of the installed packages in ubuntu

Step 2: Remove the package

đź’ˇ
Using 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]
remove package including unnecessary packages that were installed and no longer needed

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
remove packages from ubuntu including the configuration files

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:

apt remove vs apt purge: What’s the Difference?
To uninstall an application in the Ubuntu terminal, you can use: sudo apt remove package_name But in various forums, you may come across the suggestion to use the apt purge command for removing applications completely. This leaves you confused because using apt purge is quite similar…

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.