Home > Article > Operation and Maintenance > How to delete a folder in linux
Just rm directly, but you need to add two parameters -rf, namely: rm -rf directory name
-r means to recurse downward, no matter how many levels of directories there are, delete them all;
-f means to directly forcibly delete them without any prompt. (Recommended learning: linux operation and maintenance)
For example: deleting a folder instance:
rm -rf /var/log/httpd/access
will delete /var/log /httpd/access directory and all files and folders under it
(There may be a problem here. If you use it directly like this, the system may not authorize this operation and a Permission denied prompt will appear. .
At this time, you need to add sudo as the permission for the authorized operation before rm -rf, that is: sudo rm -rf The name of the folder)
For example: Delete file instance:
rm -f /var/log/httpd/access.log
The file /var/log/httpd/access.log will be forcibly deleted.
It should be reminded that you must be extra careful when using this rm -rf, Linux does not Recycle bin.
Of course, rm has more other parameters and usages, you can view them with man rm.
There is another method that is also very useful:
mkdir a 创建目录a rmdir a 删除目录a 注意:rmdir只能删除空目录,如果目录里面有文件,那么删除失败
The above is the detailed content of How to delete a folder in linux. For more information, please follow other related articles on the PHP Chinese website!