Linux第一周學習筆記(12)
2.3:ls命令
ls –l命令:列出文件詳細信息
ls –i命令: 查看inode號
ls –lh命令:查看文件大小
ls –la命令:查看所有文件以及隱藏的文件
ls –lt命令:按時間的順序排序
ls –ld命令:只列目錄本身(d不加把目錄下面的文件及目錄列出來)
which ll命令:查看別名
ll是ls –l的一個別名
2.4:文件類型
使用ls -l命令查看文件後,在左側的第一列第一位表示設備類型
d:表示目錄
-:表示普通文件(包含文本文檔及帶色標記的二進制文檔)
c: 表示字符串的設備(如:鼠標、鍵盤)
L:軟件連接或者硬連接文件(軟連接相當於一個快捷方式)
s:通訊文件(如:進程相互間的通訊)
cat命令:可查看普通文本文檔,帶色標記的二進制文檔不能打開
-------------------------------------------------------------------------------------------------------------------
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
-rw-------(權限).1(有多少個文件使用了相同的inode)root(表示所有者是) root(所屬組) 1418(文件大小1.4k) 1月 22 08:19(文件創建時間) anaconda-ks.cfg
--------------------------------------------------------------------------------------------------------------------
[root@daizhihong01 ~]# ls -i anaconda-ks.cfg
33581218 anaconda-ks.cfg
---------------------------------------------------------------------------------------------------------------------
[root@daizhihong01 ~]# ls -lh anaconda-ks.cfg
-rw-------. 1 root root 1.4K 1月 22 08:19 anaconda-ks.cfg
[root@daizhihong01 ~]# ls -la
總用量 28
dr-xr-x---. 3 root root 147 1月 24 22:37 .
dr-xr-xr-x. 17 root root 265 1月 24 22:48 ..
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
-rw-------. 1 root root 935 1月 26 05:47 .bash_history
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
drwx------. 2 root root 48 1月 26 04:29 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@daizhihong01 ~]# ls -lta
總用量 28
-rw-------. 1 root root 935 1月 26 05:47 .bash_history
drwx------. 2 root root 48 1月 26 04:29 .ssh
dr-xr-xr-x. 17 root root 265 1月 24 22:48 ..
dr-xr-x---. 3 root root 147 1月 24 22:37 .
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@daizhihong01 ~]# ls -la
總用量 28
dr-xr-x---. 3 root root 147 1月 24 22:37 .
dr-xr-xr-x. 17 root root 265 1月 24 22:48 ..
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
-rw-------. 1 root root 935 1月 26 05:47 .bash_history
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
drwx------. 2 root root 48 1月 26 04:29 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@daizhihong01 ~]# ls -d /root/
/root/
[root@daizhihong01 ~]# ls -l /root/
總用量 4
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
[root@daizhihong01 ~]# ls -ld /root/
dr-xr-x---. 3 root root 147 1月 24 22:37 /root
[root@daizhihong01 ~]# ls -l
總用量 4
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
[root@daizhihong01 ~]# ll
總用量 4
-rw-------. 1 root root 1418 1月 22 08:19 anaconda-ks.cfg
-------------------------------------------------------------------------------------------------------------
[root@daizhihong01 ~]# which ll
alias ll='ls -l --color=auto'
/usr/bin/ls
--------------------------------------------------------------------------------------------------------------
-----------------------------------ls命令參數-----------------------------------------------------------------
-a:顯示所有檔案及目錄(ls內定將檔案名或目錄名稱為“.”的視為影藏,不會列出);
-A:顯示除影藏文件“.”和“..”以外的所有文件列表;
-C:多列顯示輸出結果。這是默認選項;
-l:與“-C”選項功能相反,所有輸出信息用單列格式輸出,不輸出為多列;
-F:在每個輸出項後追加文件的類型標識符,具體含義:“*”表示具有可執行權限的普通文件,“/”表示目錄,“@”表示符號鏈接,“|”表示命令管道FIFO,“=”表示sockets套接字。當文件為普通文件時,不輸出任何標識符;
-b:將文件中的不可輸出的字符以反斜線“”加字符編碼的方式輸出;
-c:與“-lt”選項連用時,按照文件狀態時間排序輸出目錄內容,排序的依據是文件的索引節點中的ctime字段。與“-l”選項連用時,則排序的一句是文件的狀態改變時間;
-d:僅顯示目錄名,而不顯示目錄下的內容列表。顯示符號鏈接文件本身,而不顯示其所指向的目錄列表;
-f:此參數的效果和同時指定“aU”參數相同,並關閉“lst”參數的效果;
-i:顯示文件索引節點號(inode)。一個索引節點代表一個文件;
--file-type:與“-F”選項的功能相同,但是不顯示“*”;
-k:以KB(千字節)為單位顯示文件大小;
-l:以長格式顯示目錄下的內容列表。輸出的信息從左到右依次包括文件名,文件類型、權限模式、硬連接數、所有者、組、文件大小和文件的最後修改時間等;
-m:用“,”號區隔每個文件和目錄的名稱;
-n:以用戶識別碼和群組識別碼替代其名稱;
-r:以文件名反序排列並輸出目錄內容列表;
-s:顯示文件和目錄的大小,以區塊為單位;
-t:用文件和目錄的更改時間排序;
-L:如果遇到性質為符號鏈接的文件或目錄,直接列出該鏈接所指向的原始文件或目錄;
-R:遞歸處理,將指定目錄下的所有文件及子目錄一並處理;
--full-time:列出完整的日期與時間;
--color[=WHEN]:使用不同的顏色高亮顯示不同類型的。
Linux第一周學習筆記(12)