系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux rmdir命令

Linux中如何使用rmdir命令指南

時間:2014-12-04 16:02:46 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時看資訊 2. 請使用手機瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20141204/31929.html 手機查看 評論

  我們都知道Linux命令中的rm命令主要用于刪除文件,那么 rmdir命令又有什么作用呢?下面小編就給大家介紹下Linux命令中rmdir命令的主要功能吧。

 Linux中如何使用rmdir命令指南

  rmdir是常用的命令,該命令的功能是刪除空目錄,一個目錄被刪除之前必須是空的。(注意,rm - r dir命令可代替rmdir,但是有很大危險性。)刪除某目錄時也必須具有對父目錄的寫權(quán)限。

  1.命令格式:

  rmdir [選項]。。。 目錄。。。

  2.命令功能:

  該命令從一個目錄中刪除一個或多個子目錄項,刪除某目錄時也必須具有對父目錄的寫權(quán)限。

  3.命令參數(shù):

  - p 遞歸刪除目錄dirname,當(dāng)子目錄刪除后其父目錄為空時,也一同被刪除。如果整個路徑被刪除或者由于某種原因保留部分路徑,則系統(tǒng)在標(biāo)準(zhǔn)輸出上顯示相應(yīng)的信息。

  -v, --verbose 顯示指令執(zhí)行過程

  4.命令實例:

  實例一:rmdir 不能刪除非空目錄

  命令:

  rmdir doc

  輸出:

 。踨oot@localhost scf]# tree

  。

  |-- bin

  |-- doc

  | |-- info

  | `-- product

  |-- lib

  |-- logs

  | |-- info

  | `-- product

  `-- service

  `-- deploy

  |-- info

  `-- product

  12 directories, 0 files

 。踨oot@localhost scf]# rmdir doc

  rmdir: doc: 目錄非空

 。踨oot@localhost scf]# rmdir doc/info

  [root@localhost scf]# rmdir doc/product

 。踨oot@localhost scf]# tree

  。

  |-- bin

  |-- doc

  |-- lib

  |-- logs

  | |-- info

  | `-- product

  `-- service

  `-- deploy

  |-- info

  `-- product

  10 directories, 0 files

  說明:

  rmdir 目錄名 命令不能直接刪除非空目錄

  實例2:rmdir -p 當(dāng)子目錄被刪除后使它也成為空目錄的話,則順便一并刪除

  命令:

  rmdir -p logs

  輸出:

 。踨oot@localhost scf]# tree

  。

  |-- bin

  |-- doc

  |-- lib

  |-- logs

  | `-- product

  `-- service

  `-- deploy

  |-- info

  `-- product

  10 directories, 0 files

 。踨oot@localhost scf]# rmdir -p logs

  rmdir: logs: 目錄非空

 。踨oot@localhost scf]# tree

  。

  |-- bin

  |-- doc

  |-- lib

  |-- logs

  | `-- product

  `-- service

  `-- deploy

  |-- info

  `-- product

  9 directories, 0 files

 。踨oot@localhost scf]# rmdir -p logs/product

 。踨oot@localhost scf]# tree

  。

  |-- bin

  |-- doc

  |-- lib

  `-- service

  `-- deploy

  |-- info

  `-- product

  7 directories, 0 files

  上面就是Linux rmdir命令的作用介紹了,該命令只可刪除空目錄,不可刪除含有隱藏或系統(tǒng)文件的目錄,所以在使用的時候要格外注意。

標(biāo)簽 Linux 命令

發(fā)表評論

0

沒有更多評論了

評論就這些咯,讓大家也知道你的獨特見解

立即評論

以上留言僅代表用戶個人觀點,不代表系統(tǒng)之家立場

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄