Home>Article>Operation and Maintenance> What is the command to delete a folder in linux

What is the command to delete a folder in linux

青灯夜游
青灯夜游 Original
2021-02-26 13:50:00 121821browse

Linux commands to delete folders: 1. rmdir command, use "rmdir [-p] folder name" to delete empty specified folders; 2. rm command, use "rm -rf folder Name" to delete the specified folder.

What is the command to delete a folder in linux

#The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.

linux delete folder

1. Use the rmdir command

Linux rmdir (full English Pin: remove directory) command to 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

Related recommendations: "Linux Video Tutorial

2. Use the rm command

The Linux rm (full English spelling: remove) command is used to delete a file or directory.

Syntax

rm [options] name...

Parameters:

  • -i Ask for confirmation one by one before deleting.

  • -f Even if the original file attribute is set to read-only, it will be deleted directly without confirming one by one.

  • -r Delete the files in the directory and below one by one.

Example:

rm -rf /var/log/httpd/access

will delete the/var/log/httpd/accessdirectory and all files and folders under it

For more programming-related knowledge, please visit:Programming Video! !

The above is the detailed content of What is the command 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