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

What is the command to delete a folder in linux

青灯夜游
Release: 2023-01-03 09:25:44
Original
122245 people have browsed it

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

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

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

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

will delete the /var/log/httpd/access directory 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!

Related labels:
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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template