Linux deletion folder commands include: 1. rmdir command, used to delete empty folders, the syntax format is "rmdir [-p] folder name"; 2. rm command, used to delete a file or Folder, the syntax format is "rm -rf folder name".
#The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.
① Linux delete folder command: rmdir
rmdir command usage scenario:
When there is an empty directory to be deleted, you can use the rmdir command. If the given directory is not an empty directory, an error message will appear.
Command syntax:
rmdir [-p] [目录名]
-p After deleting the specified directory, if the upper directory of the directory has become an empty directory, delete it together.
Example of rmdir command to delete a folder:
There is only dir1 directory under directory team03. When deleting dir1, team03 will also be deleted
#rmdir –p team03/dir1
② Linux delete folder command: rm
rm command usage scenario:
Many people are accustomed to using rmdir to delete folders, but rmdir is only suitable for deleting empty folders. Once the folder is not If it is empty, you will fall into deep distress. At this time, you can use the rm -rf command.
Command syntax:
rm -rf 目录名字
-r is recursive downward, no matter how many levels of directories there are, delete them all
-f means to delete directly without any prompt.
rm command to delete a folder example:
rm -rf /var/log/httpd/access
will delete the /var/log/httpd/access directory And all files and folders under it
Note when using the rm command:
Be very careful when using this rm -rf. Linux does not have a recycle bin. Many friends did not see this important prompt information before using it, so it is difficult to retrieve it after deleting it. In addition, rm is also a commonly used Linux file deletion command.
Related recommendations: "Linux Video Tutorial"
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!