1 Answers
What is the difference between the 'rm' and 'rm -r' commands in Unix/Linux?
The rm
command is used to delete files in Unix/Linux system. When using rm
, you can only delete individual files, and if you try to delete a directory with rm
, an error will be generated. On the other hand, the rm -r
command is used to delete directories and their contents recursively.
When would you use each one?
- Use
rm
when you want to delete individual files or empty directories. - Use
rm -r
when you want to delete directories and their contents recursively.
It is important to be cautious when using the rm -r
command as it will not ask for confirmation before deleting files and directories. Make sure you are absolutely certain before using this command to avoid accidental deletion of important data.
Please login or Register to submit your answer