LINUX命令之stat及显示的三个时间戳

<Linux系统stat指令用法>

stat指令:文件/文件系统的详细信息显示。html

stat命令主要用于显示文件或文件系统的详细信息,该命令的语法格式以下:node

 

-f  不显示文件自己的信息,显示文件所在文件系统的信息linux

-L  显示符号连接vim

-t  简洁模式,只显示摘要信息bash

 

  事实上,stat命令显示的是文件的I节点信息。Linux文件系统以块为单位存储信息,为了找到某一个文件所在存储空间的位置,用I节点对每一个文件进行索引。数据结构

  

   所谓的I节点,是文件系统管理的一个数据结构,是一个64字节长的表,包含了描述文件所必要的所有信息,其中包含了文件的大小,类型,存取权限,文件的全部者==spa

 

man 2 stat

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  new‐
              line after each use of FORMAT

 

用stat命令查看printout.c的属性:code

xc@xc-HP-Pavilion-dv4-Notebook-PC:~/workspace$ stat printout.c 
  文件:'printout.c'
  大小:310       	块:8          IO 块:4096   普通文件
设备:801h/2049d	Inode:39060450    硬连接:1
权限:(0664/-rw-rw-r--)  Uid:( 1000/      xc)   Gid:( 1000/      xc)
最近访问:2017-06-09 14:55:49.337795926 +0800
最近更改:2017-06-09 14:25:50.692033236 +0800
最近改动:2017-06-09 14:25:50.736034690 +0800
建立时间:-

stat显示出inode的内容--inode包含文件的元信息,具体来讲有如下内容:
  * 文件的字节数
  * 文件拥有者的User IDorm

  •   * 文件的Group ID

  * 文件的读、写、执行权限
  * 文件的时间戳,共有三个
  * 连接数,即有多少文件名指向这个inode(索引节点,它用来存放档案及目录的基本信息,包含时间、档名、使用者及群组等)
  * 文件数据block的位置.htm

  • 三个时间戳

stat printout.c后显示的是如下三个时间戳:

最近访问:2017-06-09 14:25:50.692033236 +0800
最近更改:2017-06-09 14:25:50.692033236 +0800
最近改动:2017-06-09 14:25:50.736034690 +0800
建立时间:-


cat print.out 以后:

最近访问:2017-06-09 14:55:49.337795926 +0800
最近更改:2017-06-09 14:25:50.692033236 +0800
最近改动:2017-06-09 14:25:50.736034690 +0800
建立时间:-

咱们发现第一个时间发生了改变。第二个时间戳表示文件最后改动的时间,第三个时间戳表示文件属性修改时间。

vim printout.c后,

最近访问:2017-06-09 15:23:41.630104952 +0800
最近更改:2017-06-09 15:23:41.630104952 +0800
最近改动:2017-06-09 15:23:41.686105714 +0800
建立时间:-

三个时间戳都发生了改变。

若是 chmod a-x printout.c(chmod改变文件属性)

最近访问:2017-06-09 15:23:41.630104952 +0800 最近更改:2017-06-09 15:23:41.630104952 +0800 最近改动:2017-06-09 15:25:31.255640354 +0800 建立时间:-

相关文章
相关标签/搜索