歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> CentOS中文件夾基本操作命令的講解

CentOS中文件夾基本操作命令的講解

日期:2017/3/2 16:24:40   编辑:Linux服務器

  CentOS中文件夾基本操作命令的講解

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

CentOS中文件夾基本操作命令的講解  三聯

  說明: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---顯示檔案系統的狀況;主要用來了解系統中已經掛載的各個文件系統的磁盤使用情況

12下一頁
Copyright © Linux教程網 All Rights Reserved