ls
普通文件: -,f目录文件: d链接文件(符号链接): L设备文件:
字符设备:c
块设备:b
命名管道: p套接字文件: s
linux文件时间戳时间分为三种类型:创建时间,修改时间:open访问时间:读写改变时间:源数据发生改变时间
在linux中同目录中,目录和文件是不能同名的ls :列出目录内容ls -a查看所有文件
[root@docker-node1 scripts]# ls -a
. .. cmdline-jmxclient-0.10.3.jar jmx-zabbix.sh jstat.sh .jstat.sh.swp jvm_name.sh jvm_status.sh jvm_thread_num.sh local.gc
[root@docker-node1 scripts]#
.:为当前目录..:父目录ls -A 则不显示
root@zabbix_agentd scripts]# ls -A
jmx-zabbix.sh jstat.sh jvm_name.sh jvm_status.sh jvm_thread_num.sh nginx_status.sh redis_hits.sh redis_info.sh tcp-status.sh usr.gc
去掉颜色:
[root@zabbix_agentd scripts]# ls --color=never
查看文件详细内容
[root@zabbix_agentd scripts]# ls -l
total 48
-rwxr-xr-x. 1 root root 4878 Jul 5 14:09 jmx-zabbix.sh
-rwxr-xr-x. 1 root root 554 Jul 6 22:18 jstat.sh
-rwxr-xr-x. 1 root root 409 Jul 5 14:10 jvm_name.sh
-rwxr-xr-x. 1 root root 135 Jul 5 14:09 jvm_status.sh
-rwxr-xr-x. 1 root root 391 Jul 5 14:09 jvm_thread_num.sh
-rwxr-xr-x. 1 root root 1489 Jul 7 13:24 nginx_status.sh
-rwxr-xr-x. 1 root root 744 Jul 8 06:46 redis_hits.sh
-rwxr-xr-x. 1 root root 8794 Jul 7 18:22 redis_info.sh
-rwxr-xr-x. 1 root root 2687 Jul 6 08:34 tcp-status.sh
-rw-r--r--. 1 root root 0 Jul 7 10:40 usr.gc
[root@zabbix_agentd scripts]#
文件类型-rw-r--r--. 1 root root 0 Jul 7 10:40 usr.gc左第一位是-则为普通文件,为l则是链接文件,后面9位则是权限数字1位硬连接数root 为所有者,属主root 属组接着是最近一次修改的时间最后是文件名
我们使用ll -l是查看目录内容属性,如果查看目录属性则ll -l -d 即可
[root@zabbix_agentd scripts]# ls -ld /var/
drwxr-xr-x. 19 root root 4096 Jul 2 05:51 /var/
[root@zabbix_agentd scripts]#
逆序显示-r
[root@zabbix_agentd scripts]# ls -l
total 48
-rwxr-xr-x. 1 root root 4878 Jul 5 14:09 jmx-zabbix.sh
-rwxr-xr-x. 1 root root 554 Jul 6 22:18 jstat.sh
-rwxr-xr-x. 1 root root 409 Jul 5 14:10 jvm_name.sh
-rwxr-xr-x. 1 root root 135 Jul 5 14:09 jvm_status.sh
-rwxr-xr-x. 1 root root 391 Jul 5 14:09 jvm_thread_num.sh
-rwxr-xr-x. 1 root root 1489 Jul 7 13:24 nginx_status.sh
-rwxr-xr-x. 1 root root 744 Jul 8 06:46 redis_hits.sh
-rwxr-xr-x. 1 root root 8794 Jul 7 18:22 redis_info.sh
-rwxr-xr-x. 1 root root 2687 Jul 6 08:34 tcp-status.sh
-rw-r--r--. 1 root root 0 Jul 7 10:40 usr.gc
[root@zabbix_agentd scripts]# ll -lr
total 48
-rw-r--r--. 1 root root 0 Jul 7 10:40 usr.gc
-rwxr-xr-x. 1 root root 2687 Jul 6 08:34 tcp-status.sh
-rwxr-xr-x. 1 root root 8794 Jul 7 18:22 redis_info.sh
-rwxr-xr-x. 1 root root 744 Jul 8 06:46 redis_hits.sh
-rwxr-xr-x. 1 root root 1489 Jul 7 13:24 nginx_status.sh
-rwxr-xr-x. 1 root root 391 Jul 5 14:09 jvm_thread_num.sh
-rwxr-xr-x. 1 root root 135 Jul 5 14:09 jvm_status.sh
-rwxr-xr-x. 1 root root 409 Jul 5 14:10 jvm_name.sh
-rwxr-xr-x. 1 root root 554 Jul 6 22:18 jstat.sh
-rwxr-xr-x. 1 root root 4878 Jul 5 14:09 jmx-zabbix.sh
[root@zabbix_agentd scripts]#
递归查看-R
[root@zabbix_agentd etc]# ll -R zabbix/
zabbix/:
total 16
drwxr-xr-x. 2 root root 4096 Jul 8 06:46 scripts
-rw-r--r--. 1 root root 11145 Jul 7 20:12 zabbix_agentd.conf
drwxr-xr-x. 2 root root 37 Jun 25 17:04 zabbix_agentd.d
zabbix/scripts:
total 48
-rwxr-xr-x. 1 root root 4878 Jul 5 14:09 jmx-zabbix.sh
-rwxr-xr-x. 1 root root 554 Jul 6 22:18 jstat.sh
-rwxr-xr-x. 1 root root 409 Jul 5 14:10 jvm_name.sh
-rwxr-xr-x. 1 root root 135 Jul 5 14:09 jvm_status.sh
-rwxr-xr-x. 1 root root 391 Jul 5 14:09 jvm_thread_num.sh
-rwxr-xr-x. 1 root root 1489 Jul 7 13:24 nginx_status.sh
-rwxr-xr-x. 1 root root 744 Jul 8 06:46 redis_hits.sh
-rwxr-xr-x. 1 root root 8794 Jul 7 18:22 redis_info.sh
-rwxr-xr-x. 1 root root 2687 Jul 6 08:34 tcp-status.sh
-rw-r--r--. 1 root root 0 Jul 7 10:40 usr.gc
zabbix/zabbix_agentd.d:
total 4
-rw-r--r--. 1 root root 1531 May 23 05:04 userparameter_mysql.conf
[root@zabbix_agentd etc]#
显示文件大小以易读方式展示 -h
[root@zabbix_agentd scripts]# ls -sh
total 48K
8.0K jmx-zabbix.sh 4.0K jvm_name.sh 4.0K jvm_thread_num.sh 4.0K redis_hits.sh 4.0K tcp-status.sh
4.0K jstat.sh 4.0K jvm_status.sh 4.0K nginx_status.sh 12K redis_info.sh 0 usr.gc
[root@zabbix_agentd scripts]#
-i: inode号,index node,索引节点
[root@zabbix_agentd scripts]# ls -i
34743320 jmx-zabbix.sh 101534226 jvm_name.sh 34743324 jvm_thread_num.sh 102141001 redis_hits.sh 34674375 tcp-status.sh
101534232 jstat.sh 34743323 jvm_status.sh 101788499 nginx_status.sh 102140998 redis_info.sh 101788500 usr.gc
[root@zabbix_agentd scripts]#
我们在使用ls -R查看目录时也不竟然是理想的,你可以尝试tree
[root@zabbix_agentd zabbix]# yum install tree y
[root@zabbix_agentd zabbix]# tree scripts/
scripts/
├── jmx-zabbix.sh
├── jstat.sh
├── jvm_name.sh
├── jvm_status.sh
├── jvm_thread_num.sh
├── nginx_status.sh
├── redis_hits.sh
├── redis_info.sh
├── tcp-status.sh
└── usr.gc
0 directories, 10 files
[root@zabbix_agentd zabbix]#