How to remove package and all its files

The dnf man page discusses autoremove and clean commands, but neither seem to remove package files.

autoremove removes unused packages and clean removes unused repo files. I’m looking for something that removes package files (i.e., files and directories created on install or during use).

How do you identify and remove these files? Is there a way to do this with dnf?

You mean config files in your home directory? Package managers aren’t allowed to touch those, you will have to find and delete them yourself.

3 Likes

Packages are removed using dnf sudo dnf remove <package name> which removes all the related system files and if necessary directories. The config files for the user are, as stated just above, left for the user to find and remove. Those files will normally be in or under the users home directory or maybe for some may be located under the /etc directory.

1 Like

Does this mean files put in /etc and /var/lib or similar?

Is there a way to track these files? I understand some are well named and placed, but to speed up the process and boost assurance, is there a tool that tracks which config files belong to which package? Or another way to ask it is, is there a tool that tracks all the files on your system owned by a certain package?

I’d like to automate the process as much as possible.

rpm -ql packagename

will list all files that were installed.

1 Like

Thank you, that works well. It doesn’t check the home directory and only works
while the package is installed, but is still usable.

For now I’ll just make a habit of using a fuzzy finder to cleanup after package removals.

sk -m | xargs -o rm -ri

(skim includes hidden files by default, fzf does not.)

This also works well:

fd -H <pkg> | xargs -o rm -ri

If those files are modified by user, they are not removed but renamed with .rpmsave extension (to preserve the changes made by the user). If they are not modified, they are removed by dnf remove command.

Thank you for explaining. Understood.

What is this referring to then in the Software app?

image

What dnf command do the two options correspond to?

To reproduce: install Apostrophe, create and save a new file, uninstall.

This only works with flatpaks.

2 Likes

Got it!