每天回顾linux命令(stat)

stat命令
stat命令用于显示文件的状态信息。

语法
stat (选项) (参数)

选项
-L:支持符号链接,当文件是链接文件时候,显示的是目标时间的stat

root@68fc0a9bc6dd:/home/wzm/testtail# stat aaa
  File: 'aaa' -> 'redis.conf'
  Size: 10              Blocks: 0          IO Block: 4096   symbolic link
Device: 70h/112d        Inode: 8398        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-11-12 06:13:26.834836056 +0000
Modify: 2017-11-12 06:13:26.834836056 +0000
Change: 2017-11-12 06:13:26.834836056 +0000
 Birth: -
root@68fc0a9bc6dd:/home/wzm/testtail# stat -L aaa
  File: 'aaa'
  Size: 57764           Blocks: 120        IO Block: 4096   regular file
Device: 70h/112d        Inode: 8384        Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-11-12 04:58:43.494831644 +0000
Modify: 2017-11-12 04:58:27.774885989 +0000
Change: 2017-11-12 04:58:27.774885989 +0000
 Birth: -

-f:显示文件系统状态而非文件状态

root@68fc0a9bc6dd:/home/wzm/testtail# stat  aaa
  File: 'aaa' -> 'redis.conf'
  Size: 10              Blocks: 0          IO Block: 4096   symbolic link
Device: 70h/112d        Inode: 8398        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-11-12 06:13:26.834836056 +0000
Modify: 2017-11-12 06:13:26.834836056 +0000
Change: 2017-11-12 06:13:26.834836056 +0000
 Birth: -
root@68fc0a9bc6dd:/home/wzm/testtail# stat -f aaa
  File: "aaa"
    ID: 0        Namelen: 242     Type: aufs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 4686334    Free: 1567559    Available: 1319878
Inodes: Total: 2436448    Free: 2233036

-t:以简洁方式输出信息

root@68fc0a9bc6dd:/home/wzm/testtail# stat  aaa
  File: 'aaa' -> 'redis.conf'
  Size: 10              Blocks: 0          IO Block: 4096   symbolic link
Device: 70h/112d        Inode: 8398        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-11-12 06:13:26.834836056 +0000
Modify: 2017-11-12 06:13:26.834836056 +0000
Change: 2017-11-12 06:13:26.834836056 +0000
 Birth: -
root@68fc0a9bc6dd:/home/wzm/testtail# stat -t aaa
aaa 10 0 a1ff 0 0 70 8398 1 0 0 1510467206 1510467206 1510467206 0 4096

-c或者–format=格式:使用指定格式代替默认值,每用一次指定格式换一新行。
格式相应定定义如下:

  %a   access rights in octal (note '#' and '0' printf flags)
  %A   access rights in human readable form
  %b   number of blocks allocated (see %B)
  %B   the size in bytes of each block reported by %b
  %C   SELinux security context string
  %d   device number in decimal
  %D   device number in hex
  %f   raw mode in hex
  %F   file type
  %g   group ID of owner
  %G   group name of owner
  %h   number of hard links
  %i   inode number
  %m   mount point
  %n   file name
  %N   quoted file name with dereference if symbolic link
  %o   optimal I/O transfer size hint
  %s   total size, in bytes
  %t   major device type in hex, for character/block device special files
  %T   minor device type in hex, for character/block device special files
  %u   user ID of owner
  %U   user name of owner
  %w   time of file birth, human-readable; - if unknown
  %W   time of file birth, seconds since Epoch; 0 if unknown
  %x   time of last access, human-readable
  %X   time of last access, seconds since Epoch
  %y   time of last data modification, human-readable
  %Y   time of last data modification, seconds since Epoch
  %z   time of last status change, human-readable
  %Z   time of last status change, seconds since Epoch
Valid format sequences for file systems:

  %a   free blocks available to non-superuser
  %b   total data blocks in file system
  %c   total file nodes in file system
  %d   free file nodes in file system
  %f   free blocks in file system
  %i   file system ID in hex
  %l   maximum length of filenames
  %n   file name
  %s   block size (for faster transfers)
  %S   fundamental block size (for block counts)
  %t   file system type in hex
  %T   file system type in human readable form

eg:

root@68fc0a9bc6dd:/home/wzm/testtail# stat redis.conf -c %n
redis.conf
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值