I've been using Linux for about a month and a half, and I'm wondering what really happens when software is removed with commands such as `yay -R`, `apt remove`, or `dnf remove`. If a package is uninstalled, is the system returned to exactly how it was before installation? I'm especially curious about application caches, configuration files, downloaded package archives, logs, dependencies, and files created while using the program.
4 Answers
Usually, uninstalling removes the files that belonged to the package itself. It generally does not remove data created by the program afterward, such as personal files, caches, or user configuration. Those may remain so that reinstalling the application can restore your previous setup.
User-specific leftovers commonly remain in locations such as `~/.cache`, `~/.config`, and `~/.local/share`. System-wide configuration, logs, and other files manually created outside the package can remain too. Package managers avoid deleting these automatically because they might contain settings or data you still want.
The package manager may also keep the downloaded package archive in its cache. Dependencies that are no longer required can usually be cleaned up with the package manager’s dependency-removal command, but that is separate from deleting application data. In practice, an uninstall removes the managed program files, not every trace associated with the software.
`apt autoremove` is not a general cleanup command for every leftover file. It removes packages that were automatically installed as dependencies and are no longer needed. With APT, `apt purge package-name` removes the package plus its system-level packaged configuration files, including leftovers from a previously removed package, but it still does not remove data in your home directory.

So `purge` is more thorough than `remove`, but I would still need to check my home directory and package cache separately?