Get the App
SLTechnology News&Howtos  ›  Servers  › 

The use of stat Command in Linux

Shulou Source: shulou.com Published: 2022-06-03 03:39:42 09月22日 Update

This article uses simple and easy to understand examples to introduce the role of stat command in Linux and how to use it. The content of the article is compact step by step. I hope you can gain something from this article.

1, stat command role:

The stat command displays detailed attribute information for a file or directory, including file system status, in more detail than the ls command outputs.

2. Common options:

option

Function-f Displays file system status, not file status. - tPrint information in concise form

3. Examples:

1) No options are added by default

[root@localhost ~]# lsanaconda-ks.cfg ip.txt number www[root@localhost ~]# stat www File: 'www' Size: 34 Blocks: 8 IO Block: 4096 regular fileDevice: fd00h/64768d Inode: 33618826 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)Context: unconfined_u:object_r:admin_home_t:s0Access: 2020-01-02 14:40:50.771405666 +0800Modify: 2019-12-17 23:49:37.367102234 +0800Change: 2019-12-17 23:49:37.367102234 +0800 Birth: -

Notes:

Access: the time the file was accessed;

Modify: the time at which the file was modified;

Change: The last time the i node (attribute information) of the file was modified. Note: When the file is modified, the information of the i node is also modified.

2)-f option, this option only looks at file system status.

[root@localhost ~]# stat -f www File: "www" ID: fd0000000000 Namelen: 255 Type: xfsBlock size: 4096 Fundamental block size: 4096Blocks: Total: 4452864 Free: 4140969 Available: 4140969Inodes: Total: 8910848 Free: 8877166

Notes:

Type: File system type

3)-t option, this option displays information in a concise manner

[root@localhost ~]# stat -t www www 34 8 81ed 0 0 fd00 33618826 1 0 0 1577947250 1576597777 1577954750 0 4096 unconfined_u:object_r:admin_home_t:s0

About the use of stat command in Linux to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Files information commands status systems actions time brevity content properties articles more comments articles nodes good compact usage examples examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi Microsoft Linux MySQL