TL;DR
To uninstall packages with Apt package manager, you can try these methods:
- Uninstalling Single Packages: Uninstall specific software with Apt, including options to retain configuration files
(apt remove)or perform a clean removal(apt purge). - Batch Uninstalling Multiple Packages: Efficiently remove multiple packages simultaneously using a text file
sudo xargs apt remove < package_list.txt.
To revert package uninstallations, use Apt’s versioning feature by checking available versions with apt policy and reinstalling the desired version using sudo apt install package_name=version. Follow these expert tips for efficient package management: choose the right uninstall command (apt remove or apt purge), batch uninstall with a text file and xargs, manage configuration files, and leverage advanced features like apt-mark hold and package pinning for precise system optimization.
Continue reading the guide below to learn two different methods to uninstall packages with Apt package manager. Also learn how to revert installation and tips for enhanced productivity.
In Linux, package management plays a pivotal role in maintaining a well-organized and efficient system. Apt, short for Advanced Package Tool, is a powerful package manager that simplifies the installation, removal, and management of software packages on various Linux distributions. Uninstalling packages with Apt is a crucial skill that empowers you to maintain a clean and optimized system effortlessly. In this article, I’ll explore different methods to uninstall packages with apt package manager, including how to remove single and multiple packages, handle configuration files and dependencies, and even revert package uninstalls. I will also discuss how to revert package installation and five tips to master the art of uninstalling using the apt package manager.
How to Uninstall Packages With Apt Package Manager
To uninstall packages with Apt Package Manager, you have two methods at your disposal. Firstly, for removing single packages, it’s a straightforward process – use apt remove to retain configuration files or apt purge for a clean removal. Secondly, to efficiently uninstall multiple packages simultaneously, create a text file with package names and utilize sudo xargs apt remove < package_list.txt.
1. Uninstalling Single Packages
Uninstalling a single package with Apt is a straightforward process that comes in handy when you want to tidy up your system by removing specific software. Follow these steps:
- Press Ctrl + Alt + T to open the Terminal.

- Use the following command to verify the package name and description before removal:
<strong>apt show package_name</strong> - This command will display detailed information about the specified package, including its name, version, description, and other relevant details.

- To remove the package without deleting its configuration files, use the apt remove command followed by the package name:
<strong>sudo apt remove package_name</strong> - This command will uninstall the specified package from your system while retaining its configuration files

- If you want to completely remove the package, including its configuration files, use the apt purge command:
<strong>sudo apt purge package_name</strong> - This command will not only uninstall the package but also delete its configuration files, freeing up disk space and ensuring a clean removal.

- After removing a package, you can automatically remove any residual dependencies that are no longer required using the apt autoremove command:
<strong>sudo apt autoremove</strong> - This command will identify and uninstall any packages that were automatically installed as dependencies but are no longer needed, helping to keep your system clutter-free.

2. Batch Uninstalling Multiple Packages
When it comes to a more comprehensive cleanup or uninstalling multiple packages simultaneously, Apt provides an efficient solution through batch uninstallation. This time-saving method ensures efficient package management while reducing manual effort. Apt provides an efficient way to do this with a single command:
- Prepare a text file containing the names of the packages you wish to remove, with each package name on a separate line.

- Use the following command to uninstall all the packages listed in the text file:
<strong>sudo xargs apt remove < package_list.txt</strong> - This command reads the package names from the
package_list.txtfile and uninstalls all the listed packages in a single batch operation.

How to Revert Package Uninstallations
Apt’s versioning feature comes to the rescue when you realize you need to bring back a previously uninstalled package. This functionality allows you to quickly and effortlessly rectify any unintended package removals and restore system stability. To do this:
- Use the apt policy command to view the available versions of a package:
<strong>apt policy package_name</strong> - This command will display information about the specified package, including its installed version and available versions in the repositories.

- To reinstall a specific package version, use the install option followed by the package name and the desired version: