# 【Linux高頻命令專題(5)】rmdir
標簽(空格分隔): Linux
---
## 簡述
rmdir是常用的命令,該命令的功能是刪除空目錄,一個目錄被刪除之前必須是空的。(注意,rm - r dir命令可代替rmdir,但是有很大危險性。)刪除某目錄時也必須具有對父目錄的寫權限。
### 命令格式
> rmdir [選項]... 目錄...
### 命令參數
-p 遞歸刪除目錄dirname,當子目錄刪除后其父目錄為空時,也一同被刪除。如果整個路徑被刪除或者由于某種原因保留部分路徑,則系統在標準輸出上顯示相應的信息
-v, --verbose 顯示指令執行過程
## 常用范例
```
# rmdir 不能刪除非空目錄
[root@iZ23x7r1tuqZ test]# rmdir 1-1/
rmdir: failed to remove 1-1/: Directory not empty
# rmdir -p 當子目錄被刪除后使它也成為空目錄的話,則順便一并刪除
[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: 目錄非空
[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
```
- Apache
- 【Apache運維基礎(1)】Apache的安裝與使用
- 【Apache運維基礎(2)】主配置文件說明
- 【Apache運維基礎(3)】虛擬主機配置說明
- 【Apache運維基礎(4)】Apache的Rewrite攻略(1)
- 【Apache運維基礎(5)】Apache的Rewrite攻略(2).htaccess文件
- 【Apache運維基礎(6)】Apache的日志管理與分析
- 工具篇
- supervisor進程管理器
- Haproxy安裝與配置
- Nginx
- 【nginx網站性能優化篇(1)】gzip壓縮與expire瀏覽器緩存
- 【nginx網站性能優化篇(2)】反向代理實現Apache與Nginx的動靜分離(LNMPA)
- 【nginx網站性能優化篇(3)】反向代理實現負載均衡
- 【nginx網站性能優化篇(4)】理解nginx的高并發原理及其配置調優
- 【nginx運維基礎(1)】Nginx的編譯安裝與使用
- 【nginx運維基礎(2)】Nginx的配置文件說明及虛擬主機配置示例
- 【nginx運維基礎(3)】Nginx的編譯PHP
- 【nginx運維基礎(4)】Nginx的日志管理(日志格式與定時分割日志)
- 【nginx運維基礎(5)】Nginx的location攻略
- 【nginx運維基礎(6)】Nginx的Rewrite語法詳解
- 【nginx運維基礎(7)】配置SSL支持https訪問
- 【nginx運維基礎(8)】配置支持http2協議
- 【nginx運維基礎(9)】了解PHP-FPM 與 Nginx 的通信機制
- 其它
- Apache與Nginx下php隱藏http頭部版本信息的實現方法
- CURL與PHP-CLI的應用【CLI篇】
- CURL與PHP-CLI的應用【Curl篇】
- Linux之SAMBA共享服務
- 【Linux常識篇(1)】所謂的正向代理與反向代理
- 【Linux常識篇(2)】理解inode
- 【Linux常識篇(3)】文件及文件夾的ctime atime mtime的含義詳解
- centOS使用手記
- 服務器日志分析
- 高頻命令
- df
- mv
- gzip
- cp
- tar
- touch
- cat
- uniq
- nl
- more
- rmdir
- less
- mkdir
- head
- rm
- tail
- 五大查詢命令
- vi&vim
- ls與目錄結構
- grep
- awk
- sed
- 其他高頻命令