linux查看文件类型-file、状态-stat
首页 计算机相关 linux命令 linux查看文件类型-file、状态-stat
file 命令可以用来查看文件类型-i mime type
-s 读取字符或块设备文件最好指定[root@192 tmp]# file freecls
freecls: UTF-8 Unicode text
[root@192 tmp]# file -i freecls
freecls: text/plain; charset=utf-8
[root@192 tmp]# file dos.txt
dos.txt: ISO-8859 text, with CRLF line terminators[root@192 ~]# file -s /dev/sda1
/dev/sda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
[root@192 ~]# file -s /dev/sda2
/dev/sda2: Linux/i386 swap file (new style), version 1 (4K pages), \
size 524287 pages, no label, UUID=2156bb3d-de11-4dd5-8599-70b16d3ef6b5
stat 可以用来展示文件或文件系统的状态,-f 展示文件系统状态
查看文件的各种属性包括文件的最后访问时间(atime),最后修改时间(mtime),最后状态修改时间(ctime),文件权限等。[root@192 ~]# stat tmp.txt
File: ‘tmp.txt’
Size: 88 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051dInode: 33584620 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2018-07-02 21:59:09.152208149 -0400
Modify: 2018-07-02 21:58:52.838700532 -0400
Change: 2018-07-02 21:58:52.840700551 -0400
Birth: -[root@192 ~]# stat -f tmp.txt
File: "tmp.txt"
ID: 80300000000 Namelen: 255 Type: xfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 4453632 Free: 3947490 Available: 3947490
Inodes: Total: 8912384 Free: 8854646