linux stat命令主要用于显示文件或文件系统的详细信息:

stat test.sh File: ‘test.sh’Size: 38         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 1269768     Links: 1
Access: (0640/-rw-r-----)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-07-30 15:13:20.692716580 +0800
Modify: 2022-07-30 15:12:49.869716580 +0800
Change: 2022-07-30 15:12:49.869716580 +0800Birth: -
155F7DE9-0DF3-E24F-B268-C06DA6DD2F44:/tmp/luolin # stat -f test.sh File: "test.sh"ID: 9574a1b9f6400775 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 5127839    Free: 3897457    Available: 3635313
Inodes: Total: 1310720    Free: 1183243

内容:

文件的字节数
文件拥有者的 User ID
文件的 Group ID
文件的读、写、执行权限
文件的时间戳,共有三个:
ctime 指 inode 上一次变动的时间
mtime 指文件内容上一次变动的时间
atime 指文件上一次打开的时间。
链接数,即有多少文件名指向这个
inode 文件数据 block 的位置

Linux下的三个时间:

  1. Access Time:简写为atime,表示文件的访问时间。当文件内容被访问时,更新这个时间 ls -l
  2. Modify Time:简写为mtime,表示文件内容的修改时间,当文件的数据内容被修改时,更新这个时间 ls -lc
  3. Change Time:简写为ctime,表示文件的状态时间,当文件的状态被修改时,更新这个时间,例如文件的链接数,大小,权限,Blocks数ls -lu

什么是 inode?
参考链接

参数说明:

-f  不显示文件本身的信息,显示文件所在文件系统的信息

stat -f test.sh File: "test.sh"ID: 9574a1b9f6400775 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 5127839    Free: 3897659    Available: 3635515
Inodes: Total: 1310720    Free: 1183324

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

stat -t test.sh
test.sh 38 8 81a0 0 0 fd00 1269768 1 0 0 1659165200 1659165169 1659165169 0 4096

-c 输出指定格式的文件信息

stat -c %a test.sh
640
stat -c %A test.sh
-rw-r-----

更多命令可以参考:

stat --help
Usage: stat [OPTION]... FILE...
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--help     display this help and exit--version  output version information and exitThe valid format sequences for files (without --file-system):%a   access rights in octal%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 modification, human-readable%Y   time of last modification, seconds since Epoch%z   time of last change, human-readable%Z   time of last change, seconds since Epoch

linux stat命令相关推荐

  1. linux常用命令(转载)

    Linux常用命令大全(非常全!!!) 最近都在和Linux打交道,感觉还不错.我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,比较短 ...

  2. linux if 命令判断条件总结

    linux if命令 关于文件属性的判断式 -a 如果文件存在 -b 如果文件存在,且该文件是区域设备文件 -c 当file存在并且是字符设备文件时返回真 -d 当pathname存在并且是一个目录时 ...

  3. linux paste变量,Linux paste命令详解

     Linux 命令大全 小白告诉你:Linux paste 命令用于合并文件的列. paste 指令会把每个文件以列对列的方式,一列列地加以合并. 语法 paste [-s][-d ][--help] ...

  4. linux unset命令,Linux unset命令

    Linux unset命令 Linux unset命令用于删除变量或函数. unset为shell内建指令,可删除变量或函数. 语法unset [-fv][变量或函数名称] 参数:-f 仅删除函数. ...

  5. linux wc 命令简介

    此wc命令不是让大家没有食欲的地方.而是linux下一个简单的小命令. NAME wc - word, line, character, and byte count SYNOPSIS wc [-cl ...

  6. linux mysql 命令 大全

    linux mysql 命令 大全 1.linux下启动mysql的命令:   mysqladmin start /ect/init.d/mysql start (前面为mysql的安装路径) 2.l ...

  7. Linux Find 命令精通指南

    作者:Sheryl Calish Linux find 命令是所有 Linux 命令中最有用的一个,同时也是最混乱的一个.它很难,因为它的语法与其他 Linux 命令的标准语法不同.但是,它很强大,因 ...

  8. linux ps命令大全,Linux ps命令例子汇总

    Linux ps命令主要用于查看系统运行的进程,确定进程运行的状态机是否占用过多资源等?下面学习啦小编通过实例来给大家详细介绍下Linux的ps命令,一起来了解下吧. Linux提供了当前进程的同时, ...

  9. linux用户在哪个文件夹,LINUX中用命令成功建立一个用户后信息会记录在哪个文件中...

    LINUX中用命令成功建立一个用户后信息会记录在哪个文件中 发布时间:2007-07-28 10:14:57来源:红联作者:MPiops 增加用户帐号后 新建用户的命令十分简单,在命令行下使用 use ...

  10. Linux常见命令(二)

    随着Linux应用的扩展许多同学开始接触Linux,根据学习Windwos的经验往往有一些茫然的感觉:不知从何处开始学起.虽然Linux桌面应用发展很快,但是命令在Linux中依然有很强的生命力.Li ...

最新文章

  1. HDU3434数学题
  2. JAVA class.getResource()的用法
  3. 不变违规:_registerComponent(...):目标容器不是DOM元素
  4. GTK+ VS MFC
  5. CodeForces - 1252E Songwriter(贪心)
  6. 使用代码判断某个note是否已经implemented
  7. c# 操作IIS应用程序池
  8. HttpWebRequest自动登录网站并获取网站内容(不包含验证码的网站)
  9. Oracle-索引分裂研究
  10. 如何使用LVM逻辑卷
  11. 将Hibernate中的枚举转换为自定义数值
  12. java 2 swing_Java Swing2 基本登錄框
  13. scratch 3 下载和安装
  14. 《穿越计算机的迷雾》 李忠 (确实写得非常好,赞一个)
  15. 软件的生命周期分为哪几个阶段
  16. java调用python实现校验一串字符串是否为单词
  17. 量子计算黑客松大赛-量子计算编程
  18. ssm+JSP计算机毕业设计英雄联盟赛事新闻管理系统qeg6l【源码、程序、数据库、部署】
  19. 知乎微信小程序广告真的猛的一塌糊涂
  20. 编程修养 - 来自网络整理

热门文章

  1. 东西方文化溯源和比较
  2. MFC——文本字体操作
  3. chrome 未响应_在Google Chrome中更好地响应网站测试
  4. 数据结构 --有向图
  5. 有向图的定义及Java实现
  6. 纵论WebAssembly.js在性能逆境下的召唤强援
  7. 降噪蓝牙耳机哪个牌子好?最便宜的蓝牙主动降噪耳机推荐
  8. “网络草根”月赚3000的十种方法
  9. RabbitMQ 重置用户名和密码的方法分享
  10. 数据结构入门学习之数据结构学些什么?