Is "dnf remove" supposed to clear the package's cache folders?

On my system (both Fedora 32 and 33) this certainly doesn’t happen, ~/.cache has even had folders of packages removed months ago (albeit they could have been wiped if the location had grown past a certain size).

What is the reasoning not to touch the package’s data in ~/.cache since by definition no persistent storage should be located there?


dnf only removes files and directories owned by a package, and according to the packaging guidelines linked above, Fedora packages cannot put files and directories to the user’s home directory at the installation time (the program itself can create files and directories in there after it is launched by the user, but those files and directories are not owned by the package). So in short: no, dnf does not touch user’s home directories, you need to clean it yourself.


Hi, I know this isn’t related to your question to start from, but I see that you like to “keep things clean”, so a good tip is to run sudo dnf autoremove once in a while, to see and remove unnecessary packages left behind. :slight_smile:

1 Like

Is that command safe to use without removing dependent packages?

Yes, I believe so. It removes packages that were dependencies of packages that were already removed, not dependents of them.

However, sometimes those can be packages that you still want to have. In those cases, just reinstall them on their own.


For instance this command (source) prints the presumably dormant directories in ~/.cache:

for dir in `find ~/.cache -type d -mtime +30`; do test `find $dir -type f -mtime -30 -print -quit` || echo $dir; done

This prints any directories that have a modification time greater than 30 days and no files modified within the last 30 days.

I personally only removed the folders belonging to now-deleted programs.