In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the methods to delete Linux directories". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "what are the methods to delete Linux directories" together!
Deleting directories using rmdir There are many ways to delete directories in Linux, either graphically using File Manager or via Terminal. This article describes how to delete directories using the command in the text interface.
Rmdir command is called "remove directory", which is used to delete empty directory command.
For example, delete an empty directory named "My Documents":
[root@localhost test]# rmdir MyDocuments
If the directory is not empty, an error is displayed:
rmdir: failed to remove 'MyDocuments': Directory not empty
Delete directories using rm command
The rm command is usually used to delete files in Linux. Parameters can be added to delete directories. For example, recursively deleting directories, using the recursion option-r or-R, prompts whether to continue deleting directories and files in directories as a whole if directories are write-protected. - f Force deletion without being prompted.
[root@localhost test]# rm -rf MyDocuments/
You can delete multiple directories in a single command, as shown in the following command. Command deletes all directories and their subdirectories without prompting for deletion.
[root@localhost test]# rm -rf dir1 dir2 dir3
use the Find command
The Find command helps users search for files and directories based on specific expressions. In addition, the command can be used to search directories and delete them based on specified search criteria.
Delete the directory named "MyDocuments" from the current directory
[root@localhost test]# find . -type d -name "MyDocuments" -exec rm -rf {} +
. Indicates execution in the current directory
-type d Search directories only
-name Specifies the directory name
-exec rm -rf execute rm to delete all directories i.e. contents
{} + appended at the end of rm command
Delete an empty directory
If you want to delete all empty directories, use the following command:
[root@localhost test]# find . -type d -empty -delete
-empty Limit only empty directories
-delete Delete all empty directories including subdirectories
Thank you for reading, the above is the "delete Linux directory method what" content, after the study of this article, I believe that we have a deeper understanding of the method of deleting Linux directory, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.