基础命令 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