DNF clean all

AI responds:
“Additionally, dnf clean all currently does not clean user-level cache when run without sudo. A feature request proposes that sudo dnf clean all should clean both user and system caches, but this is not yet implemented. For now, you may need to run ‘dnf clean all && sudo dnf clean all’ to clear both.”

Is it true in Fedora 43?

This is not a feature that I think should be implemented.

Either you are using DNF from root and any user cache is not consuled.
Or you are using DNF as a user and the system caches are not consulted.

Why is it necessary to clear both caches in one command?

1 Like
(sudo) dnf clean all 

does clean more than just cache, see DNF Command Reference — DNF @DNF_VERSION@-1 documentation

However that command is usually not required.

So why even running it if there is no need? Users seem to like the command because of „cleaning“…

1 Like

@barryascott
So I should act 1st as normal user:

sudo dnf clean all && sudo dnf -y --refresh upgrade && sudo dnf -y autoremove

Then as root:

sudo su -

dnf clean all && dnf -y --refresh upgrade && dnf -y autoremove

exit

Is this correct?

In almost all use cases you don’t want or need to run dnf as a user.
Always run as sudo dnf will be what you need to do.

You are running that as root. That is what sudo does, it runs the command as “super user” or “root”.

To run as a normal user, you leave out the “sudo” part.

4 Likes

you shouldn’t use (sudo) dnf clean all at all! What you trying to do with it?? Have you read DNF Command Reference — DNF @DNF_VERSION@-1 documentation in the meantime?

The sudo dnf upgrade command will re-generate dbcache, metadata, etc. anyways. dnf upgrade downloads less data and runs faster if you haven’t cleaned up all the metadata information in the previous step.

When you want to update you system, just run sudo dnf upgrade with an optional --refresh. By default, do not use -y. You don’t know what you will be asked.

Do not use sudo dnf autoremove if you don’t understand what it’s trying to do. Sometimes it tries to remove important packages.

2 Likes

-y in a sudo command is a bad habit and can lead to bricked systems.

2 Likes