13

In Ubuntu, or any Linux, when I decide to remove a program and then later reinstall it, I notice that it didn't remove anything I previously made, thus making it a little pointless for me, as I like to freshly install stuff often. Whenever I decide to reinstall it it's just like it was before I removed the program. Why is this?

I'm used to uninstalling something similar to Windows or Android in that it completely removes everything and the only real way to recover that data would be to either save it somewhere, or if they give me an option to log in to recover it, is there a way to do that on Linux too?

Sometimes I remove it from the Ubuntu Software center and use sudo apt-get --purge remove [application].

I'm using Ubuntu 18.10, I have nothing to uninstall right now I'm just curious.

Zanna
  • 72,312

3 Answers3

29

That's not quite true. No package operation should remove user data, ever, under any circumstances.

The reasoning for this is simple: The application doesn't own the data. You do.

Firstly, as an aside, other than the Ubuntu login screen, if an application asks you to log in, then your data is almost certainly not on your machine. The log in process is most likely related to an online authentication mechanism to provide access to your data stored somewhere else. Android and iOS have a (limited) ability to sync small amounts of user and configuration data for applications with "cloud" servers, but that doesn't necessarily disappear after uninstalling an application either.

All OSs (including Windows* and Android) are dependent on removal scripts. These presume that you want the software to go away but keep the configuration so that you can install it again later. The --purge option to apt merely removes configuration files.

If you're making modifications outside your own data (/home) then we assume you know what you're doing so your system continues to behave to your configuration. It's easy to rm -R the config files yourself, it's not so easy to get your specific customised version of things back the way you had set them up. So these scripts tend to err on the side of caution.

These scripts make various assumptions about what was installed and they are frequently written by humans who can make mistakes. Sometimes the software does something special, particularly when the software has dependencies.

We (Ubuntu developers) do do tests on test systems. We install the software into a clean installation of Ubuntu, and then we run apt remove and apt --purge remove and verify that the system returned to the expected (pre-installed) state.

If you do see a situation where a package is installed, no modifications are made to the config, and the package is then removed but files remain, then please file a bug against that package.

An alternative is to use snap, which houses the application entirely in its own environment.

*(in fact, this is one of the top ways Windows applications install malware, by "piggybacking" malware onto applications you choose to install, and then not removing them when you uninstall them.)

14

sudo apt remove or uninstalling an application normally from the Software Center will just uninstall the regular package files and leave configuration behind, so that reinstalling the package later will usually pretty much restore your previous state of the application.

sudo apt purge or sudo apt remove --purge instead will uninstall a package and additionally remove residual system-wide configuration files afterwards. You can also use those to purge the residual configuration of a previously only removed package.

The package manager will never delete user data or user configuration files though, which is created during the run-time of the application. Those files are not tracked and the user is responsible themselves to clean them out of their home directory, if they don't want to keep them. (Theoretically a package could contain a post-remove script that checks common user data locations for files it might have created, but that should normally not be the case)

Byte Commander
  • 110,243
0

In Windows, you always have some trace of the invasive program in the registry that must be removed manually. Anything related to AV, populates the Win architecture heavily… Plus, Windows requires a third party app to fully remove a program. Ccleaner and Revo are among them.

In Ubuntu, apt purge removes almost everything, if not all. A manual search in Synaptic Package Manager shows the entire deletion process. It can be double checked by running apt purge or inversely, by searching it in Synaptic.

You must be prudent and precise using that app, it’s a hot place to be.

Mikemecanic
  • 141
  • 5