For yum/dnf - What is the difference/relation between `remove` and `erase`?

For yum/dnf - What is the difference/relation between remove and erase ?

When is mandatory use one approach over the other?

In many tutorials available in the web I found mostly for remove but almost nothing about erase - but the latter exists for some reason, right?.

There is no difference. It is an alias, a deprecated one.

Remove Command

Command: remove
Aliases: rm
Aliases for explicit NEVRA matching: remove-n, remove-na, remove-nevra
Deprecated aliases: erase, erase-n, erase-na, erase-nevra

So the former name was remove - I assume to avoid confusions or for simplicity the deprecated erase alias was created, right? Something similar about update/upgrade, right?

I don’t think that’s right. I’m not a code historian, or anything, but if I look at the old yum repository’s documentation for the yum command, it seems that in yum remove and erase were treated as equals.

Sometime after dnf replaced yum, there was a decision made to only make one of those (remove | erase) the “real” command. The following bug report is worth looking at. The second comment gives some context on why this was done.

There should be one reference command that will be used in guides

It makes sense to make only one command the reference command to make documentation consistent. But keep the other one (as an alias) for compatibility’s sake. What also is interesting is it seems that they originally chose to make “erase” the reference command, but eventually changed it to “remove”.

Bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1160806

Also see:
https://github.com/rpm-software-management/dnf/pull/195

Interesting … huge thanks.