Linux命令學習總結:rmdir,linuxrmdir

來源:互聯網
上載者:User

Linux命令學習總結:rmdir,linuxrmdir

命令簡介:

該命令用用來刪除空目錄,如果目錄非空,則會出現錯誤。可以使用rm刪除目錄中的檔案後,使用rmdir刪除目錄。也可以使用rm -rf替代rmdir命令。這是一個非常簡單的命令。

 

命令文法:

rmdir [OPTION]... DIRECTORY...

 

命令參數:

參數

長參數

描敘

--ignore-fail-on-non-empty

忽略任何應目錄裡面有資料檔案而造成的錯誤

-p

--parents

遞迴刪除目錄

-v

--verbose

顯示命令執行的詳細資料

--help

顯示命令線上協助

--version

顯示命令版本資訊

 

 

使用樣本:

 

1: 查看rmdir命令的協助資訊

[root@DB-Server ~]# rmdir --help
Usage: rmdir [OPTION]... DIRECTORY...
Remove the DIRECTORY(ies), if they are empty.
 
      --ignore-fail-on-non-empty
                  ignore each failure that is solely because a directory
                  is non-empty
  -p, --parents   Remove DIRECTORY and its ancestors.  E.g., `rmdir -p a/b/c' is
                  similar to `rmdir a/b/c a/b a'.
  -v, --verbose   output a diagnostic for every directory processed
      --help     display this help and exit
      --version  output version information and exit
 
Report bugs to <bug-coreutils@gnu.org>.

也可以使用下面命令查看rmdir文檔資訊

[root@DB-Server ~]# man rmdir

 

2: 使用rmdir刪除空目錄

如果目錄非空,則會出現錯誤資訊。

[root@DB-Server ~]# ls /root/kerry/
file1
[root@DB-Server ~]# rmdir kerry
rmdir: kerry: Directory not empty
[root@DB-Server ~]# rm -f /root/kerry/*
[root@DB-Server ~]# rmdir kerry

 

3:顯示命令執行時的詳細資料

 

[root@DB-Server ~]# mkdir test1  test2 test3
[root@DB-Server ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog  test1  test2  test3
[root@DB-Server ~]# rmdir -v test1  test2 test3
rmdir: removing directory, test1
rmdir: removing directory, test2
rmdir: removing directory, test3

 

4:遞迴刪除目錄,如下所示,首先建立目錄kerry,在kerry目錄下建立空目錄tmp,接下來空目錄test

 

[root@DB-Server ~]# mkdir -p kerry/tmp/test
[root@DB-Server ~]# tree kerry
kerry
`-- tmp
    `-- test
 
2 directories, 0 files
[root@DB-Server ~]# rmdir -p kerry/tmp/test

 

5:忽略任何應目錄裡面有資料檔案而造成的錯誤

 

[root@DB-Server ~]# mkdir kerry
 
[root@DB-Server ~]# cd kerry
 
[root@DB-Server kerry]# touch file1
 
[root@DB-Server kerry]# cd ..
 
[root@DB-Server ~]# rmdir --ignore-fail-on-non-empty kerry/

Linux下的rmdir命令強制移除非空目錄的格式?(最好舉個例子)

Linux中rmdir命令是用來刪除空的目錄。
使用方式: rmdir [-p] dirName
參數: -p 是當子目錄被刪除後使它也成為空白目錄的話,則順便一併刪除。

舉例說明:
rmdir folder1
刪除名字為folder1的子目錄。

rmdir -p folder1/folder2
刪除名字為folder1裡面的folder2這個子目錄,如果刪除folder2這個子目錄後,folder1也成了空目錄的話,那麼folder1也會一同被刪除。

如果你想刪除非空目錄,使用rmdir估計是不行的哦。
要使用rm才可以的。
使用方式:rm [options] name...

參數 [options]:
-i 刪除前逐一詢問確認。
-f 即使原檔案屬性設為唯讀,亦直接刪除,無需逐一確認。
-r 將目錄及以下之檔案亦逐一刪除。

舉例說明:
刪除所有.java檔案;刪除前逐一詢問確認 :
rm -i *.java

將 project子目錄及子目錄中所有檔案刪除 :
rm -r project

祝你使用順利!
 
怎在命令列模式下學習LINUX

登陸與關機
(1)登陸
在login:後輸入
user機號(這表示斷行符號鍵)
在password:後輸入
123456(注意在螢幕上不顯示)
出現$提示符,表示正常進入普通使用者狀態。
(2)關機
在$後輸入
halt
等螢幕上顯示System halted時,再關電源。

man命令

man命令用於查看Linux各種命令的使用說明,用法如下:

man 命令名
參考背景資料或利用man命令,熟悉掌握以下基本命令的使用方法:
ls;按條件列出檔案
cd;進入某個目錄
cp;複製檔案
mkdir;建立目錄
rmdir;刪除目錄
mv;移動檔案/目錄
rm;刪除檔案
cat;顯示檔案內容
more;分布顯示檔案內容
less;分頁顯示檔案內容
file;檔案類型判斷
du;查看目錄佔用空間
df;查看磁碟空間
mount;裝載檔案系統
umount;卸載檔案系統
chmod;修改檔案屬性
chown;修改所有人許可權
pwd;查看當前路徑
which;尋找程式所在路徑
3、系統管理基本命令
Linux是真正的多使用者多任務作業系統,任何人使用Linux系統時都要以用某個帳號先進行
登陸,帳號名就是使用者名稱。
使用者的管理必須在root使用者權限下進行操作,請務必小心!!!
參考背景資料或利用man命令,熟悉掌握以下命的使用方法:
useradd;添加新使用者
userdel;刪除使用者
passwd;修改密碼
finger;查看某使用者資訊
groupadd;添加組
groupdel;刪除群組
ps;進程資訊
nice;以特定優先順序運行進程
renice;
kill;殺死特定進程
top;查看當前系統資源情況
free;釋放佔用記憶體
cal;日曆
date;日期
uname;作業系統名稱
login;登入
logout;退出
exit;退出
halt;關機
shutdown;關機

先多多熟悉那些基本命令,當自己重新學windows!
net.pku.edu.cn/...al.pdf 下載這個電子書看看吧~~~先看看一下裡面的指令,然後在自己實踐並熟悉!
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.