How to Remove Packages on Ubuntu Command Line


Ubuntu users can easily uninstall packages from their system using the command line terminal. Doing so successfully requires knowledge of specific commands and procedures, such as removing a package and configuration files or dependencies that are no longer needed. To help ensure successful removal without creating any issues in your system, this guide provides detailed steps on uninstalling a package on a Ubuntu system.

Step 1: Update Ubuntu package lists

Before uninstalling a package, it’s a good practice to update the package lists on your system to ensure that you have the latest information about available packages. Open a terminal and run the following command.

sudo apt update

Step 2: Remove the package

To remove a package, you can use the apt remove command. For example, to remove the package “example-package,” you would run the following command.

sudo apt remove example-package

You can also use the apt purge command to remove the package and all its configuration files. For example, to purge the package “example-package,” you would run the following command:

sudo apt purge example-package

Step 3: Remove dependencies

After you remove a package, you may also want to remove any dependencies that are no longer needed. To do this, you can use the apt autoremove command. For example, you would run the following command to remove all dependencies that are no longer needed.

sudo apt autoremove

Example output:

When running the autoremove command, you will see a prompt to confirm the uninstallation process. Type Y and press enter to confirm the uninstallation.

An alternative way of removing packages is to use the autoremove command and the package name together. This saves time and can be used if you are confident that it will not break other packages.

sudo apt autoremove <package name>

Step 4: Restore a package that was accidentally uninstalled

If you accidentally uninstalled a package, you can restore it using the following command.

sudo apt install package-name

Conclusion

Uninstalling packages on Ubuntu is a straightforward process that can be completed in just a few steps. By using the apt package manager and its various commands, you can easily remove packages and their dependencies from your system without any problems.

See also
How to Install qBittorrent on Ubuntu 22.04 or 20.04

Leave a Comment

Share to...