How to cleanly remove a package from a Debian-based distribution

When you uninstall an application from Linux, make sure you're doing it in such a way as to remove both configuration files and dependencies.

How to cleanly remove a package from a Debian-based distribution

If you're using Ubuntu or any other Debian-based distribution in your data centers, on-premises servers, or desktops, you've probably run into an instance where you needed to uninstall a piece of software. So you log in and run the command: sudo apt-get remove packagename (where packagename is the actual name of the package to be removed). 

However, doing that leaves behind a number of things, primarily dependencies and configuration files. These straggling apps and files not only take up space, but they could ("could" being the operative word) cause security issues. You don't want that. So what do you do? 

SEE: Choosing your Windows 7 exit strategy: Four options (TechRepublic Premium)

With just two simple commands you can cleanly remove those packages. What are those commands? Let me demonstrate. 

Say you've installed Wordpress on a server and want to cleanly remove it. To first uninstall Wordpress and remove all configuration files, issue the command:

sudo apt-get purge wordpress

Once this command completes, you can then remove all of the dependencies that were installed alongside Wordpress with the command: 

sudo apt-get autoremove

When that final command finishes, Wordpress will have been removed, along with all of its configuration files and dependencies. If you need to remove an application from a Linux server or desktop, using these two simple commands is the way to go.

Also see


Image: Jack Wallen