file命令
stat命令
显示对象的详细信息(状态)
Access:上一次访问时间。
Modify:上一次修改时间——指“内容的修改”。
Change:上一次状态/属性修改时间——指“属性(如权限、大小等的修改)”。
stat -f 显示有关文件系统(而非文件)的信息
stat -t 以一行的格式显示信息【在shell脚本中有用!】
du命令
du file1 file2 显示指定文件/目录的大小
-s 显示当前目录的大小(而不包括显示子目录)
-h 以K、M、G这样易读的单位显示
-c 显示大小并最后计算count总和大小
du | sort -nr 按文件大小排序
du -h --max-depth=1 输出当前目录下各个子目录的大小
file file1 file2
file -b //查看文件类型
file -f //读出文本文件中每一行的文件,并判别文件类型【脚本中查看文件类型】[root@localhost shell]# file test.txt
test.txt: ASCII text
[root@localhost shell]# file -b test.txt
ASCII text
[root@vm_hosts ~]# cat file.txt
/etc/passwd
string just a test txt
[root@vm_hosts ~]# file -f file.txt
/etc/passwd: ASCII text
string just a test txt: cannot open `string just a test txt' (No such file or directory)
stat命令
显示对象的详细信息(状态)
[root@localhost lyj]# stat .
File: "."
Size: 4096 Blocks: 8 IO Block: 4096 目录
Device: fd00h/64768d Inode: 1572865 Links: 3
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2015-10-13 03:14:08.797401158 +0800
Modify: 2015-10-08 03:32:55.600587141 +0800
Change: 2015-10-08 03:32:55.600587141 +0800
注意这三个“时间”的不同:
Access:上一次访问时间。
Modify:上一次修改时间——指“内容的修改”。
Change:上一次状态/属性修改时间——指“属性(如权限、大小等的修改)”。
stat -f 显示有关文件系统(而非文件)的信息
stat -t 以一行的格式显示信息【在shell脚本中有用!】
[root@localhost lyj]# stat -f .
File: "."
ID: ad73353be9b38fb8 Namelen: 255 Type: ext2/ext3
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 12901535 Free: 7968969 Available: 7313609
Inodes: Total: 3276800 Free: 3151282
[root@localhost lyj]# stat -t .
. 4096 8 41ed 0 0 fd00 1572865 3 0 0 1444677248 1444246375 1444246375 4096
du命令
du file1 file2 显示指定文件/目录的大小
-s 显示当前目录的大小(而不包括显示子目录)
-h 以K、M、G这样易读的单位显示
-c 显示大小并最后计算count总和大小
du | sort -nr 按文件大小排序
du -h --max-depth=1 输出当前目录下各个子目录的大小
[root@localhost ~]# du -sh /etc/passwd
4.0K /etc/passwd
[root@localhost ~]# du -h --max-depth=1 /etc
28K /etc/rpm
52K /etc/udev
20K /etc/audisp
20K /etc/ConsoleKit
4.0K /etc/thnuclnt
72K /etc/init
40K /etc/logrotate.d