Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between rm and rm -rf [closed]

Tags:

linux

I am fairly new to linux and I found this command 'rm -rf' which is confusing. I wanted to know whats the difference between 'rm' and 'rm -rf' and when should those be used?

like image 348
user95025 Avatar asked Dec 02 '22 18:12

user95025


2 Answers

rm is the same as "del". It deletes the specified file. It will not delete directories. It will also warn you about deleting some files.

rm -rf adds the "recursive" and "force" flags. It will remove the specified file and silently ignore any warnings when doing so. If it is a directory, it will remove the directory and all its contents, including subdirectories.

like image 192
Eric Avatar answered Dec 23 '22 00:12

Eric


Check out the man page. rm removes files and -rf are to options: -r remove directories and their contents recursively, -f ignore nonexistent files, never prompt.

like image 22
David Avatar answered Dec 22 '22 23:12

David