Home >Operation and Maintenance >Linux Operation and Maintenance >How to delete a folder in linux
How to delete a folder under Linux: You can use the [rm -rf directory name] command to delete, such as [rm -rf /var/log/httpd/access], which means deleting /var/log/httpd /access directory and all files and folders under it.
Just rm directly, but you need to add two parameters -rf, namely:
(Recommended tutorial: linux video tutorial )
rm -rf 目录名字
-r means to recurse downward, no matter how many levels of directories there are, delete them all;
-f means to forcefully delete them directly without any prompt.
For example: Deleting a folder instance:
rm -rf /var/log/httpd/access
will delete the /var/log/httpd/access directory and all files and folders under it
(This may appear This is a problem. 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 before rm -rf as the permission for the authorized operation. That is: sudo rm -rf the name of the folder)
For example: deleting a file instance:
rm -f /var/log/httpd/access.log
will forcefully delete the file /var/log/httpd/access.log
It should be reminded that you must be extra careful when using this rm -rf. Linux does not have a recycle bin.
Of course, rm has more other parameters and usages, you can view them with man rm.
Related recommendations: linux tutorial
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!