Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use stat command in Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use the stat command in Linux system. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In Linux systems, the stat command is mainly used to display the details of a file or file system.

Syntax stat [file or directory] parameter:-L,-- dereference: follow the symbolic link to parse the original file instead of the symbolic link;-f,-``file``-system: display the file system information instead of the file information;-c mathafe-``format`` = FORMAT: output in the specified format instead of the default format The format control characters available for ``display file information are as follows:``% a: display access rights in octal ``% A: display access permissions in readable form``% b: show the number of blocks occupied ``% B: display the number of bytes occupied by each block``% C:SELinux security context string ``% d: decimal display file device number``% D: hexadecimal display file device number ``% f: hexadecimal display file type``% F: file type. File types under Linux are mainly divided into ordinary files, directories, character device files, block device files, symbolic link files, sockets, etc. ``% g: file owner group ID``% G: file owner group name ``% h: number of file hard links``% i:inode number ``% m: mount point of disk partition where the file resides For example, ``/ data``% n: file name ``% N: file name enclosed in single quotation marks. If it is a soft link, the file name``% o:optimal I`` / O```file ``% s: actual file size is also displayed. Unit byte ``% t:major device ``type``in`` hex, ``for``in`` / block``device special files``% T:minor device ``type`in`` hex, ``for``sil`` / block``in``% u: owner user ID ``% U: owner user name``% w: file creation time, output-indicates that the file creation time is not known, output Unix timestamp 0 means you cannot know ``% x: output the last access time in readable form atime``% X:Unix timestamp output the last access time atime ``% y: output the last modification time mtime``% Y:Unix timestamp output mtime ``% z: output the last state change time ctime``% Z:Unix timestamp output final state change time ctime ``format controllers available for displaying file system information are:``% a: number of free block that can be used by non-super users ``% b: total number of block of file system``% c: total number of file nodes of file system ``% d: number of available file nodes``% f: number of available file block ``% I: hexadecimal file system ID``% l: maximum file name length ``% n: Name ``% s: size of a block Unit byte (``for```faster transfers) ``% S: basic size of a block, unit byte (used to count the number of block)``% t: hexadecimal output file system type ``% T: readable output file system type-``printf`` = FORMAT: output in the specified format instead of the default format. Similar to-- ``format``, but can interpret backslash escape characters, such as the newline character\ n;-t,-- terse: concise mode output, showing only summary information;-- help: displaying help information;-- version: displaying version information. Case demonstration: (1) display file information.

[root@TENCENT64 ~] # stat Changelog File: 'Changelog' Size: 1598 Blocks: 8 IO Block: 4096 regular file Device: fd01h/64769d Inode: 1579435 Links: 1 Access: (0644) Uid: (0 / root) Gid: (0 / root) Access: 2018-11-06 2239 purl 54.110931887 + 0800 Modify: 2018-11-06 22 ghetto 394110931887 + 0800 Change: 2018-11-06 07 14.428548887 + 0800 Birth:-Information interpretation:

File: 'Changelog': file name is Changelog Size: 1598: file size 1598 bytes Blocks: 8: number of blocks occupied by the file IO Block: 4096: regular file: file type (normal file) Device: fd01h/64769d: device number of the file Display in hexadecimal and decimal respectively Inode: 1579435: file node number Links: 1: number of hard links Access: (0644 Maxima RW Murray r -): access rights Uid: owner ID and name Gid: owner user group ID and name Access: last access time Modify: last modified time Change: last state change time Birth -: cannot know the file creation time. Note: the file under Linux does not store the file creation time.

(2) display the information of the file system where the file resides.

[root@TENCENT64 / data/vas_pgg_proj/apps/penguin_game] # stat-f Makefile File: "Makefile" ID: 6f75a4f02634e23e Namelen: 255Type: ext2/ext3 Block size: 4096 Fundamental block size: 4096 Blocks: Total: 43830967 Free: 30155578 Available: 27923259 Inodes: Total: 11162880 Free: 11077199 Information explanation:

File: "Makefile": file name is "Makefile"; ID: 6f75a4f02634e23e: file system ID Namelen: 255: maximum file name length Type: ext2/ext3: file system type name Block size: 4096: block size 4096 bytes Fundamental block size: 4096: basic block size 4096 bytes Blocks: Total: 43830967 Free: 30155578 Available: 27923259: Inodes: Total: 11162880 Free: 11077199

Thank you for reading! This is the end of the article on "how to use stat commands in the Linux system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report