基礎命令 ls
作用:
用於查看文件或目錄信息
常用參數
-l 長格式顯示信息
-a 顯示所有文件(隱藏文件)
-h 以KB顯示字節
-d 顯示目錄信息
-i 查看i節點號
案例1 長格式顯示信息 (-l)
[root@localhost ~]# ls -l
總用量 0
-rw-r--r--. 1 root root 0 12月 2 05:29 1.txt
#信息說明
-rw-r--r--. #權限
root root #所有者
12月 2 05:29 #創建月份、時間
1.txt #文件名稱
案例2 顯示所有文件(-a)
[root@localhost ~]# ls -a
. .abc.swp .bash_profile .cshrc .viminfo
.. .bash_history .bashrc .tcshrc .Xauthority
1.txt .bash_logout .bashrc.swp .test
#"."點開頭的文件,表示隱藏文件。
案例3 顯示文件大小(-h)
[root@localhost ~]# ls -lh
總用量 0
-rw-r--r--. 1 root root 0 12月 2 05:29 1.txt
#查看文件大小時,需要搭配-l 以長格式顯示
案例4 顯示目錄(-d)
[root@localhost ~]# ls -d /bin/
/bin/
#-d 的作用是把目錄像文件一樣顯示出來
案例5 查看節點號(-i)
[root@localhost ~]# ls -i
130563 1.txt 130872 test