stat 命令
2013-06-20 by dongnan
举个栗子
默认输出:
stat nvram
文件:"nvram"
大小:8684          块:24         IO 块:4096   普通文件
设备:805h/2053d    Inode:7340527     硬链接:1
权限:(0600/-rw-------)  Uid:( 1000/ dongnan)   Gid:( 1000/ dongnan)
最近访问:2013-06-17 09:45:10.343982430 +0800
最近更改:2013-06-17 09:45:56.443980833 +0800
最近改动:2013-06-17 09:45:56.443980833 +0800
创建时间:-
文件系统格式:
stat -f nvram
文件:"nvram"
ID:93d4549bdd73dacb 文件名长度:255     类型:ext2/ext3
块大小:4096       基本块大小:4096
块:总计:36046291   空闲:27515706   可用:25684652
Inodes: 总计:9158656    空闲:8947063
简要信息:
# 在一行中显示了全部的信息
stat -t nvram
nvram 8684 24 8180 1000 1000 805 7340527 1 0 0 1371433510 1371433556 1371433556 0 4096
格式化输出:
stat -c '%Z| %s' nvram
1371433556| 8684
命令参数
NAME
       stat - display file or file system status
SYNOPSIS
       stat [OPTION]... FILE...
DESCRIPTION
   Display file or file system status.
   Mandatory arguments to long options are mandatory for short options too.
   -L, --dereference
          follow links
   -f, --file-system
          display file system status instead of file status
   -c  --format=FORMAT
          use the specified FORMAT instead of the default; output a newline after each use of FORMAT
   --printf=FORMAT
          like --format, but interpret backslash escapes, and do not output a mandatory trailing newline; if you want a newline, include \n in FORMAT
   -t, --terse
          print the information in terse form
其它
在Linux中没有文件创建时间的概念。只有文件的访问时间、修改时间、状态改变时间。
也就是说不能知道文件的创建时间:
- 如果文件创建后就没有修改过,修改时间=创建时间。
- 如果文件创建后,状态就没有改变过,那么状态改变时间=创建时间。
- 如果文件创建后,没有被读取过,那么访问时间=创建时间(基本不太可能)。
与文件相关的几个时间:
- 访问时间,读一次这个文件的内容,这个时间就会更新。
- 修改时间,对文件内容修改一次,这个时间就会更新。
- 状态改变时间,通过chmod命令更改一次文件属性,这个时间就会更新。查看文件的详细的状态、准确的修改时间等,可以通过stat命令文件名。