How to Remove Packages From Ubuntu via Command-Line

Managing your Ubuntu system effectively involves more than just installing new software; it also requires the skill to clean up and remove unnecessary packages. Understanding how to remove packages from Ubuntu via the command line is essential for maintaining a clean, efficient, and secure operating system. This process helps free up space, reduce security risks, and ensure your system runs smoothly.

Here are key points to remember when removing packages from Ubuntu:

  • Understand the package management system: Ubuntu uses APT (Advanced Package Tool) to simplify the software management process.
  • Identify the package: Ensure you know the exact name of the package you wish to remove.
  • Use the correct command: Depending on your needs, you can use apt-get remove or apt-get purge.
  • Consider dependencies: Be aware that removing some packages might affect others that depend on them.
  • Check for residual configuration files: These might remain even after package removal.
  • Update the package database: After removal, update the package database with apt-get update.
  • Use autoremove: This command helps remove unneeded packages that were automatically installed.
  • Backup: Always consider backing up important data before making significant changes.

Now that you have the necessary knowledge, let’s explore the technical details of removing packages from Ubuntu using the command line.

Update Ubuntu Packages Lists

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

sudo apt update

Remove Package From Ubuntu

Use the apt remove command to remove a package. For instance, to eliminate “example-package,” run the following command.

sudo apt remove example-package

Use the apt purge command to remove the package and all its configuration files. For instance, to purge “example-package,” run the following command:

sudo apt purge example-package

Remove Dependencies From Ubuntu

After removing a package, consider eliminating unneeded dependencies as well. To do this, execute the apt autoremove command. For instance, run the following command to remove all unnecessary dependencies.

sudo apt autoremove

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 it will not break other packages.

sudo apt autoremove <package name>

Restore Removed Package

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

sudo apt install package-name


There you have it! We’ve walked through the steps to uninstall packages from Ubuntu, making your system leaner and more efficient. Whether you’re using Ubuntu 20.04, 18.04, or any other version, the apt command is your go-to tool for cleaning up unwanted software. Just a few commands can significantly tidy up your system. Remember, regular maintenance with these steps can keep your Ubuntu running smoothly. So, give your system a little TLC and keep it in top shape!

Joshua James
Follow me
Latest posts by Joshua James (see all)