How to delete a folder in linux

尚
Original
2019-12-30 10:46:128638browse

How to delete a folder in linux

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

-r means downward recursion, regardless of whether How many levels of directories should be deleted together?

-f means to delete directly without any prompts.

Delete folder instance:

rm -rf /var/log/httpd/access

will delete /var/log /httpd/access directory and all files and folders under it

Recommended learning:linux tutorial

2. Use the rmdir command

Linux rmdir command Delete empty directories.

Syntax

rmdir [-p] dirName

Parameters:

-p means that when a subdirectory is deleted and it becomes an empty directory, it will be deleted as well.

Example

Delete the subdirectory named AAA in the working directory:

rmdir AAA

In the BBB directory under the working directory, delete the subdirectory named Test. If the BBB directory becomes empty after Test is deleted, BBB will also be deleted.

rmdir -p BBB/Test

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!

Statement:
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