1, rmdir: delete the entire folder
When using the rmdir command to delete a directory, you need to leave the deleted directory, and the deleted directory must be empty , otherwise the deletion will fail.
rmdir test //删除空文件夹,test为文件夹名
2. rm command: delete a file or directory, it cannot be restored after deletion
Use the rm command to delete a file. Once deleted, it cannot be recovered.
Some parameters can be used to assist deletion during deletion:
-f
: Forced deletion without prompt-r
: Recursively delete the contents of the directory-i
: interactive mode, prompt whether to delete
example:
- Delete the test.txt file:
sudo rm test.txt
- Delete the test folder:
sudo rm -r test
(the -r parameter must be used) - Forcibly delete all files under the test folder directory:
sudo rm -rf test