I accidentally used the rm command on a directory, and it removed the entire directory. I figured that only rmdir should be able to do that.
Which command should I have used to have it fail on directories? And if it’s a command line argument of rm, how do I turn that into its default behavior?
NAME
rm - remove files or directories
[...]
By default, rm does not remove directories. Use the --recursive (-r or -R) option to remove each listed directory, too, along with all of its contents.
[...]
Do you have rm aliased ro something ?
Example here:
$ mkdir -p test
$ rm test
rm: cannot remove 'test': Is a directory
If that was the command then it should not have removed anything except for a file at that path.
A directory should have complained as in the above example, even if sudo is there.
Was it in a longer string and possibly malformed by a pipe or something?
No, none of that, and shiarta definitely was a directory, not even a symlink to one.
I should add, perhaps, that this is not the first time that I run into this issue. It happened before, some years ago. On my Manjaro Cinnamon, it appears to be the default behavior of rm.
And it’s not the only weird thing either; even though my fstab has only a single swap partition defined, when I shut Manjaro down it reports shutdown jobs of 4 swap partitions, each ending with the extension .part1.
But that’s an issue to look into some other time, and in another thread.