Ubuntu

How to Uninstall a Package on Ubuntu 22.04

Sometimes we have to uninstall the packages from Ubuntu either they are of no more use to us, or we have to free the space for installing some new applications. As we know, Ubuntu can be managed easily through the command line interface by using different commands, so we can manage the applications by using the different commands. In this blog, we are going to learn the methods by which we can uninstall the packages on Ubuntu.

How to uninstall a package on Ubuntu

To install, update, or uninstall the packages on Ubuntu, we use the APT package manager, so there are different options that are used to uninstall the packages on Ubuntu. These options are listed down:

Option 1: Uninstall a package on Ubuntu using the remove command

We can use the “remove” command to uninstall the package on Ubuntu, but this option of the apt package manager will only delete the package without deleting its configuration files.

For example, we will use this option to remove the package of Vim:

$ sudo apt remove vim -y

You can delete any package on Ubuntu by replacing the “vim” with the name of the particular package in the above command.

Option 2: Uninstall a package on Ubuntu using the auto-remove command

Another option that is used with the apt package manager is “auto-remove” and using this option we can remove the configuration files and packages which are of no more use for a long time, and use this command:

$ sudo apt auto-remove -y

Option 3: Uninstall a package on Ubuntu using the purge command

There is an option used mostly with the apt package manager is of “Purge” which not only removes the package but also all the configuration files associated with that specific package.

For example, we will again uninstall the Vim package using the command:

$ sudo apt purge vim -y

Option 4: Uninstall a package on Ubuntu using the dpkg command

Other than the apt package manager, we also have a dpkg manager that is also used to manage the packages on Ubuntu, especially the Debian packages, so we can also uninstall any package using the dpkg with its “-r” option.

For example, we want to uninstall the vlc media player using the command:

$ sudo dpkg -r vlc

Option 5: Uninstall a package on Ubuntu using the snapd utility

In the latest version of Ubuntu which is the Jammy Jellyfish, the snap utility is being installed by default which is used to install packages from the snapcraft store. The packages that are downloaded and installed using the snapd utility can only be uninstalled by using the snap utility.

For example, we will uninstall the rocketchat-server using the snap command:

$ sudo snap remove rocketchat-server

Conclusion

To free up the space on Ubuntu so that new packages can be installed as well as the other programs can be run smoothly, we have to uninstall the packages which are of no use. In this write-up, different techniques are being explored using which we can uninstall the packages on Ubuntu.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.