Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of deleting folder under linux

Shulou Source: shulou.com Published: 2022-06-02 00:56:44 10月19日 Update

This article will explain in detail the method of deleting folders under linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

How to delete a folder under linux: you can delete it using the [rm-rf directory name] command, such as [rm-rf / var/log/httpd/access], which means deleting the / var/log/httpd/access directory and all files and folders under it.

Rm is fine, but you need to add two parameters-rf:

Rm-rf directory name

-r is recursive downwards, and no matter how many directories there are, delete them as well.

-f means to delete directly and forcibly without giving any hints.

For example: delete a folder instance:

Rm-rf / var/log/httpd/access

The / var/log/httpd/access directory and all files and folders under it will be deleted

There may be a problem here. If you use it this way directly, the system may not authorize this operation and give a Permission denied prompt.

At this point, it is necessary to add sudo as the license for the authorized operation before rm-rf, that is, the name of the sudo rm-rf folder)

For example: delete file instance:

Rm-f / var/log/httpd/access.log

The / var/log/httpd/access.log file will be forcibly deleted

One thing to remind you: you must be very careful when using this rm-rf. Linux does not have a recycle bin.

Of course, rm has more parameters and usage that can be viewed by man rm.

This is the end of the method of deleting folders under linux. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Files folders directories methods more parameters names examples that is articles tips good practical two content commands Recycle Bin meaning articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux OPPO Reno Apple MySQL