Linux命令總結ls

命令說明:

ls #list directory contents(列出目錄內容)


常用參數:

-a #顯示隱藏文件,Linux下隱藏文件是以"."開頭的

-l #長格式顯示文件的屬性(文件類型、文件權限、用戶、用戶組 )

-d #顯示目錄

-h #以人類可讀的方式顯示文件大小

-i #顯示文件的inode索引節點號

-t #按照修改時間排序

-r #倒序排列

-F #在不同類型文件的文件名後面加上相應的標識(類型爲d(目錄)的文件名後面加"/")

-p #只在目錄文件的文件名後面加上斜線"/"的標識

--color=auto #顯示顏色,系統中已定義相應的別名

--time-style=long-iso #格式化屬性時間(以人類可讀的方式)


##範例實踐

##創建/root/tools目錄,並顯示目錄下的隱藏文件

[root@Template ~]# ls -la /root/tools/

total 8

drwxr-xr-x 2 root root 4096 Jan 8 16:59 .

dr-xr-x---. 3 root root 4096 Jan 8 16:59 ..


##長格式顯示/etc/services文件

[root@Template ~]# ll /etc/services

-rw-r--r--. 1 root root 641020 Oct 2 2013 /etc/services


##以人類可讀的方式顯示/etc/services文件

[root@Template ~]# ll -h /etc/services

-rw-r--r--. 1 root root 626K Oct 2 2013 /etc/services


##顯示/etc/services文件的inode索引節點號

[root@Template ~]# ll -hi /etc/services

2616359 -rw-r--r--. 1 root root 626K Oct 2 2013 /etc/services


##格式化/etc/services文件的修改時間

[root@Template ~]# ll --time-style=long-iso /etc/services

-rw-r--r--. 1 root root 641020 2013-10-02 17:06 /etc/services


##當前目錄下的文件進行倒序(降序)排列

[root@Template ~]# ll --time-style=long-iso

total 44

-rw-------. 1 root root 1080 2018-12-08 20:12 anaconda-ks.cfg

-rw-r--r--. 1 root root 21764 2018-12-08 20:12 install.log

-rw-r--r--. 1 root root 5890 2018-12-08 20:09 install.log.syslog

drwxr-xr-x 2 root root 4096 2019-01-08 16:59 tools

[root@Template ~]# ll --time-style=long-iso -r

total 44

drwxr-xr-x 2 root root 4096 2019-01-08 16:59 tools

-rw-r--r--. 1 root root 5890 2018-12-08 20:09 install.log.syslog

-rw-r--r--. 1 root root 21764 2018-12-08 20:12 install.log

-rw-------. 1 root root 1080 2018-12-08 20:12 anaconda-ks.cfg


##查看/etc目錄是否存在

[root@Template ~]# ls -ld /etc/

drwxr-xr-x. 78 root root 4096 Jan 8 16:41 /etc/


##計算出/etc/目錄下有多少個目錄

[root@Template ~]# ls -F /etc/|grep "/$"|wc -l

76

[root@Template ~]# ls -p /etc/|grep "/$"|wc -l

76

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章