We all know that the rm command in the Linux command is mainly used to delete files, then what is the role of the rmdir command? The following small series will introduce you to the main functions of the rmdir command in the Linux command.
rmdir is commonly used commands, functions of the command is to delete empty directories, before a directory is deleted must be empty. (Note that the rm - r dir command can be used instead of rmdir, but it is very dangerous.) When you delete a directory, you must also have write access to the parent directory.
1. Command format:
rmdir [options]. . . table of Contents. . .
2. Command Function:
This command deletes one or more subdirectory entries from a directory. When deleting a directory, it must also have write access to the parent directory.
3. Command parameters:
- p Recursively deletes the directory dirname. When the parent directory is empty after the subdirectory is deleted, it is also deleted. If the entire path is deleted or part of the path is reserved for some reason, the system displays the corresponding information on the standard output.
-v, --verbose Display instruction execution
4. Command Example:
Instance 1: rmdir cannot delete non-empty directories
Command:
rmdir doc
Output:
[root @localhost scf]# tree
.
|
-- bin
|
-- doc
|
|
-- info
|
`-- product
|
-- lib
|
-- logs
|
|
-- info
|
`-- product
`-- service
`-- deploy
|
-- info
`-- product
12 directories, 0 files
[root@localhost scf]# rmdir doc
rmdir: doc: directory Non-empty
[root@localhost scf]# rmdir doc/info
[root@localhost scf]# rmdir doc/product
[root@localhost scf]# tree
.
|
-- bin
|
-- doc
|
-- lib
|
-- logs
|
|
-- info
|
`-- product
`-- service
`-- deploy
|
-- info
`-- product
10 directories, 0 files
Description:
The rmdir directory name command cannot directly delete non-empty directories
>
Instance 2: rmdir -p When the subdirectory is deleted and made it empty, then delete the
command:
rmdir -p logs
Output:
[root@localhost scf]# tree
.
|
-- bin
|
-- doc
|
-- lib
|
-- logs
|
`-- product
`-- service
`-- deploy
|
-- info
`-- product
10 directories, 0 files
[root@localhost scf]# rmdir -p logs
rmdir: logs : Directory is not empty
[root@localhost scf]# tree
.
|
-- bin
|
-- doc
|
-- lib
|
-- logs
|
`-- product
`-- service
`-- deploy
|
-- info
`-- product
9 directories, 0 files
[root@localhost scf]# rmdir -p logs/product
[ Root@localhost scf]# tree
.
|
-- bin
|
-- doc
|
-- lib
`-- service
`-- deploy
|
-- info
`-- product
7 directories, 0 files
The above is the role of the Linux rmdir command. This command can only delete empty directories and cannot be deleted. A directory with hidden or system files, so be careful when using it.
When we use a computer, we sometimes find that the system time is out of order. So
Linux Container container is a kernel virtualization technology, referred to as LXC, is a lightweigh
The Ubuntu system automatically detects errors in the program and alerts the user w
Once a computer system is attacked by malware, there is a risk of leaking private data. In addition
Linux command line daily use technology
Linux no network installation GCC skills
Linux system how to build ldap server
How Linux can quickly modify the sql file in the specified ID
Linux system strace operation example summary
What is the difference between the Linux command rmdir and rm?
Ubuntu 12.04 via XRDP Remote Desktop Method
Teach you how to install Nessus software in Kali Linux
Linux blocking browser request alert method on browser
What should I do if the Shell command cannot be used after the Linux system is installed?
Linux system iptables error iptables: Protocol wrong how to do?
Win8 Getting Started Guide: You will be
As Outlook starts to enter safe mode Microsoft withdraws KB3114409 update
Where is the installation path for the Win10 Edge browser?
Personalized win7 practical tips big run (2)
In addition to China, Surface RT tablets sold out more
Win10 preview version upgrade to 9860 version
Win7 Tips: How to quickly clean up the jump list and protect privacy
How to customize the Win8 interface using the Windows 8 Start Screen Editor
Copy a large number of files under Windows, use Robocopy
Why is the webpage not full screen? How to set the webpage full screen method