Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of the rmdir command in Linux

Shulou Source: shulou.com Published: 2022-06-01 18:01:54 09月10日 Update

This article mainly introduces the use of the rmdir command in Linux. It is very detailed and has a certain reference value. Friends who are interested must finish reading it!

The Linux common command rmdir command is used to delete empty directories. When the directory is no longer in use, or the disk space has reached the usage limit, you need to delete the directory that has lost its use value.

Rmdir is used to delete empty directories

Add that you can delete one or more empty subdirectories from a directory with the rmdir command. This command removes one or more subdirectories from a directory, where dirname represents the directory name. If no path is specified in dirname, delete the directory specified by dirname under the current directory; if the path is included in dirname, delete the directory at the specified location. When you delete a directory, you must have write access to its parent directory.

Note: the subdirectory should be empty before it is deleted. That is, all files in this directory must be rm, and the current working directory must be above the deleted directory, not the deleted directory itself, nor a subdirectory of the deleted directory.

Although you can also recursively delete all files in a directory and the directory itself with the rm command with the-r option, it is dangerous to do so.

Syntax rmdir (option) (parameter) option-p or-- parents: delete the specified directory if the upper directory of the directory has become empty;-- ignore-fail-on-non-empty: this option causes the rmdir command to ignore the error message caused by deleting a non-empty directory;-v or-verboes: displays the detailed execution of the command;-- help: displays the help information of the command -- version: displays the version information of the command. Parameter directory list: an empty directory list to delete. When multiple empty directories are deleted, directory names are separated by spaces.

For example, delete the subdirectory named www under the working directory:

Rmdir www delete the subdirectory named Test in the www directory under the working directory. If the www directory becomes empty after the Test is deleted, the www will also be deleted.

The following command of rmdir-p www/Test is equivalent to rmdir a/b/c, rmdir a www/Test b, rmdir a

Rmdir-p a/b/c above is all the content of this article "what is the use of rmdir commands in Linux?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Directory command empty directory subdirectory subdirectory information multiple work value content parameter file directory name article path help great dangerous upper layer between Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi NVidia Microsoft Shulou Information