Home > Operation and Maintenance > Linux Operation and Maintenance > How to delete a folder in linux

How to delete a folder in linux

(*-*)浩
Release: 2019-11-07 09:19:48
Original
3409 people have browsed it

Just rm directly, but you need to add two parameters -rf, namely: rm -rf directory name

How to delete a folder in linux

-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
Copy after login

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
Copy after login

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只能删除空目录,如果目录里面有文件,那么删除失败
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template