Exploring stat - Linux Commands
What is stat command?
The stat command in Linux is used to display detaailed information about a file or a file system. It provides various options to customize the output.
stat [option] example.txtOutputs:
File: example.txt Size: 11 Blocks: 8 IO Block: 4096 regular fileDevice: 8dh/141d Inode: 16122795 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2024-03-04 02:46:31.029094886 +0000Modify: 2024-03-04 02:46:31.029094886 +0000Change: 2024-03-04 02:46:31.029094886 +0000- File: example.txt
- This line displays the name of the file for which the information is being presented.
- Size: 4096
- The
Sizefield shows the size of the file in bytes. In this example, the file is 4096 bytes (4 KB) in size.
- The
- Blocks: 8
- The
Blocksfield indicates the actual disk allocation for the file in 512-byte blocks. Here, the file is allocated 8 blocks on the disk.
- The
- IO Block: 4096
- The
IO Blockfield specifies the block size used for input and output operations. In this case, it’s 4096 bytes.
- The
- regular file
- This line indicates that the file is a regular file. If it is directory, it would show
directoryinstead.
- This line indicates that the file is a regular file. If it is directory, it would show
- Device: 801h/2049d
- The
Devicefield shows the device identifier where the file is located. “801h” is the hexadecimal representation, and “2049d” is the decimal representation.
- The
- Inode: 123456
- The
Inodefield displays the inode number associated with the file. An inode is a unique identifier for the file in the file system.
- The
- Links: 1
- The
Linksfield represents the number of hard links to the file. In this case, there is only one link to the file.
- The
- Access: (0644/-rw-r—r—)
- The
Accessfield shows the access permissions of the file in both numeric and symbolic formats. Here, the file has read and write permissions for the owner and read-only permissions for the group and others.
- The
- Uid: (1000/username)
- The
Uidfield indicates the user ID (numeric and username) of the file owner.
- The
- Gid: (1000/groupname)
- The
Gidfield indicates the group ID (numeric and groupname) of the file’s group.
- The
- Access:
- The
Accessfield shows the last access time of the file.
- The
- Modify:
- The
Modifyfield displays the last modification time of the file.
- The
- Change:
- The
Changefield shows the last status change time of the file.
- The
- Birth: -
- The
Birthfield may not be available or relevant on all file systems. It represents the creation time of the file, but not all file systems support this information.
- The
If you want to learn more about the stat command and its options directly in the terminal, you can use the man command for the manual.
man statThank you
Thank you for your time and for reading this!