CentOS中檔案夾基本操作命令的講解

來源:互聯網
上載者:User

   CentOS中檔案夾基本操作命令的講解

  ls--顯示指定目錄下內容

  說明:ls 顯示結果以不同的顏色來區分檔案類別。藍色代表目錄,灰色代表普通檔案,綠色代表可執行檔,紅色代表壓縮檔,淺藍色代錶鏈接檔案。

  -a---顯示所有內容,包括隱藏檔案

  說明:在Linux系統中,以“.”開頭的就是隱藏檔案或隱藏目錄。

  -l---以長格式(內容更詳細)顯示檔案或目錄的詳細資料。

  說明:ls -l命令可以簡寫成ll,

  輸出的資訊共分為7組:

  檔案類別和檔案許可權、連結數或子目錄個數、檔案所有者、檔案所屬組、檔案大小(單位為位元組B)、檔案建立或修改時間、檔案名稱。

  檔案類別:第一組前1位表示檔案類別,“-”代表普通檔案,“d”代表目錄,“l”代表符號連結,“c”代表字元裝置,“b”代表塊裝置

  檔案許可權:第一組後9位表示檔案許可權,前3位為user、中間3位為group、後三位為other的許可權

  -d---顯示目錄本身的屬性而不是目錄中的內容。

  1 [root@localhost ~]# ls -ld /home

  2 drwxr-xr-x. 4 root root 4096 9月 22 10:41 /home

  3 [root@localhost ~]# ls -d /home

  4 /home

  5 [root@localhost ~]#

  -h---以K、M、G等單位顯示檔案大小(預設為位元組)

  1 [root@localhost ~]# ls -h /home

  2 justin lost+found

  3 [root@localhost ~]# ls -lh /home

  4 總用量 20K

  5 drwx------. 27 justin justin 4.0K 9月 22 13:19 justin

  6 drwx------. 2 root root 16K 9月 18 15:30 lost+found

  7 [root@localhost ~]#

  -R---若目錄下有檔案,也將檔案依序列出

  1 [root@localhost ~]# ls -lR /home

  2 /home:

  3 總用量 20

  4 drwx------. 27 justin justin 4096 9月 22 13:19 justin

  5 drwx------. 2 root root 16384 9月 18 15:30 lost+found

  6 /home/justin:

  7 總用量 32

  8 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 公用的

  9 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 模板

  10 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 視頻

  11 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 圖片

  12 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 文檔

  13 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 下載

  14 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 音樂

  15 drwxr-xr-x. 2 justin justin 4096 9月 22 10:49 案頭

  16 /home/justin/公用的:

  17 總用量 0

  18 /home/justin/模板:

  19 總用量 0

  20 /home/justin/視頻:

  21 總用量 0

  22 /home/justin/圖片:

  23 總用量 0

  24 /home/justin/文檔:

  25 總用量 0

  26 /home/justin/下載:

  27 總用量 0

  28 /home/justin/音樂:

  29 總用量 0

  30 /home/justin/案頭:

  31 總用量 0

  32 /home/lost+found:

  33 總用量 0

  34 [root@localhost ~]#

  -t---將檔案按照建立時間的先後次序列出

  1 [root@localhost ~]# ls -l /home

  2 總用量 20

  3 drwx------. 27 justin justin 4096 9月 22 13:19 justin

  4 drwx------. 2 root root 16384 9月 18 15:30 lost+found

  5 -rw-r--r--. 1 root root 0 9月 22 15:21 t

  6 [root@localhost ~]# ls -lt /home

  7 總用量 20

  8 -rw-r--r--. 1 root root 0 9月 22 15:21 t

  9 drwx------. 27 justin justin 4096 9月 22 13:19 justin

  10 drwx------. 2 root root 16384 9月 18 15:30 lost+found

  11 [root@localhost ~]#

  說明:ls命令還可以結合萬用字元“?”或“*”一起使用,問號“?”可以匹配檔案名稱中的一個任一字元,而“*”可以匹配檔案名稱中的任意多個字元。這兩個萬用字元同樣也適用於Shell環境中的其他大多數命令。

  1 gssapi_mech.conf popt.d xml

  2 gtk-2.0 portreserve yp.conf

  3 hal postfix yum

  4 host.conf ppp yum.conf

  5 hosts prelink.cache yum.repos.d

  6 hosts.allow prelink.conf

  7 hosts.deny prelink.conf.d

  8 [root@localhost etc]# ll -d /etc/po*.d

  9 drwxr-xr-x. 2 root root 4096 1月 11 2010 /etc/popt.d

  10 [root@localhost etc]# ll -d /etc/po?.d

  11 ls: 無法訪問/etc/po?.d: 沒有那個檔案或目錄

  12 [root@localhost etc]#

  du---顯示檔案或目錄大小

  -h或--human-readable---以K,M,G為單位,提高資訊的可讀性

  1 [root@localhost src]# du -h nagios-3.5.0.tar.gz

  2 1.8M nagios-3.5.0.tar.gz

  3 [root@localhost src]# du nagios-3.5.0.tar.gz

  4 1748 nagios-3.5.0.tar.gz

  5 [root@localhost src]#

  -a---顯示全部目錄和其次目錄下的每個檔案所佔的磁碟空間

  -b或-bytes---顯示目錄或檔案大小時,以byte為單位

  1 [root@localhost local]# du -b src/nagios-3.5.0.tar.gz

  2 1789376 src/nagios-3.5.0.tar.gz

  3 [root@localhost local]#

  -c或--total---顯示每個目錄或檔案的大小外,同時也顯示所有目錄或檔案的總和

  -m或--megabytes---以1MB為單位

  -s---只顯示各檔案大小的總合

  1 [root@localhost local]# du -sh src/

  2 41M src/

  3 [root@localhost local]#

  -x---只計算同屬同一個檔案系統的檔案

  -L---計算所有的檔案大小

  df---顯示檔案系統的狀況;主要用來瞭解系統中已經掛載的各個檔案系統的磁碟使用方式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.