`rm -rf ` and `rm -r` have the same results

Solution 1:

In Ubuntu the rm command behaves as expected in removing files we own without prompting when running with option -f.

Example for a write-protected file:

:~/Test$ rm test.txt
rm: remove write-protected regular empty file ‘test.txt’? n
:~/Test$ rm -f test.txt
:~/Test$

Root will be able to remove all files irrespect of permissions. This is why we may not see a difference from option -f when running sudo rm.

We should be aware that the behaviour of Unix commands may be different on a different OS.

Please also take care to double check your command when running rm recusively (-r). This command when accidentally issued on the wrong path will irreversibly purge all files there. This may be dangerous to your system health, even more so when run without prompting for errors (-f).

Solution 2:

Here is an explanation of what both options do.

-f Remove all files (whether write-protected or not) in a directory without prompting the user. In a write-protected directory, however, files are never removed (whatever their permissions are), but no messages are displayed. If the removal of a write-protected directory is attempted, this option will not suppress an error message.

-r Recursively remove directories and subdirectories in the argument list. The directory will be emptied of files and removed. The user is normally prompted for removal of any write-protected files which the directory contains. The write-protected files are removed without prompting, however, if the -f option is used, or if the standard input is not a terminal and the -i option is not used. Symbolic links that are encountered with this option will not be traversed. If the removal of a non-empty, write-protected directory is attempted, the utility will always fail (even if the -f option is used), resulting in an error message.About rm

See also Commands Reference