It is not only the matter of understanding rm
, but you should also be familiar with what the sudo
does. Rm is a command to delete files and directories (with proper options), sudo changes the scope of user rights (you run the command with other user privileges). If you type sudo rm
, you are running the rm command with root privileges instead of your user ones.
So the answer can be:
"rm -f *" -> delete all files in current directory which you have rights to without asking. That means all files that belongs to you or the group you are member. This command omits all directories in current directory. If you need to delete everything, use rm -rf
instead.
"sudo rm *" -> delete all files in current directory and ask if you really want to do it when some of the files are without write permissions. If you want to delete every file (not directory, as mentioned before), you should add the option -f
. It doesn't matter who owns the files in this directory this time, because you are acting as root (linux administrator).
It is not therefore possible to create a file or directory which can not be removed by sudo rm
and can be removed by rm
. The superuser (root) can do everything.
the
– Vinayak – 2015-01-21T22:25:19.287-f
option will not remove files from a directory that is write-protected. More info here: What's the idea behind rm not removing non-writable file by default?A detailed explanation of the
– Vinayak – 2015-01-21T22:32:12.083rm
command is available here: The rm Command