Go Linux System stat Instruction usage

Source: Internet
Author: User
Tags echo command touch command

Original: https://www.cnblogs.com/linux-super-meng/p/3812695.html

Stat Instructions: File/File system details are displayed.

The stat command is primarily used to display detailed information about a file or file system, which has the following syntax:

-F does not display information about the file itself and displays information about the file system where the file resides

-L Display Symbolic links

-T compact mode, displaying only summary information

In fact, the stat command displays the I node information for the file. The Linux file system stores information in blocks, and each file is indexed with the I node in order to find the location of the storage space where the file resides.

  

The so-called I node, which is a data structure for file system management, is a 64-byte long table that contains all the information necessary to describe the file, including the size, type, access permissions, and the owner = = of the file

Querying information for RC.D files

[[Email protected] rc.d]# stat rc0.d///can clearly analyze the information of a file or directory
File: ' rc0.d/'
size:4096 blocks:8 IO block:4096 Directory
device:fd00h/64768d inode:1309217 Links:2
Access: (0755/drwxr-xr-x) Uid: (0/root) Gid: (0/root)
Access:2014-06-26 21:02:26.776082938 +0800
modify:2014-06-12 15:16:57.848087079 +0800
change:2014-06-12 15:16:57.848087079 +0800

[[email protected] rc0.d]# du-sh//All files in this directory are 4K and the same size as above
4.0K.

To inquire about the file system where the Ec.d file is located:

[[email protected] rc.d]# stat-f rc0.d///This display is the same as the current system file system information, because rc.0 is in the current system's file system
File: "Rc0.d/"
id:303116b72802c784 namelen:255 TYPE:EXT2/EXT3
Block size:4096 fundamental block size:4096
blocks:total:7558388 free:5545748 available:5161800
inodes:total:1921360 free:1850717

You can also view your hard disk's information

[Email protected] rc.d]# STAT/DEV/SDA
File: '/dev/sda '
size:0 blocks:0 IO block:4096 Block Special File
device:5h/5d inode:6308 links:1 Device type:8,0
Access: (0660/BRW-RW----) Uid: (0/root) Gid: (6/disk)
Access:2014-06-27 20:57:07.213940088 +0800
Modify:2014-06-27 20:57:05.037938949 +0800
Change:2014-06-27 20:57:05.037938949 +0800

SDA hard disk File system Information

[Email protected] rc.d]# stat-f/DEV/SDA
File: "/DEV/SDA"
id:0 namelen:255 Type:tmpfs
Block size:4096 fundamental block size:4096
blocks:total:61793 free:61734 available:61734
inodes:total:61793 free:61080

Simply introduce the files that the Stat command displays. Additional Information:
-File: Show file name
-Size: Show file size
-Blocks: Total number of data blocks used by the file
-IO Block:io block size
-Regular file: Document type (regular file)
-Device: Unit number
-Inode:inode No.
-Links: Link count
-Access: Permissions for files
-GID, UID: the GID and UID of the file ownership.

Update for 1.atime (Access time)

Update for 2.mtime (modified time)

Here I used the echo command to write a line to the Hello.cpp file, and was surprised to find that more than Mtime was updated, and CTime was updated. What is this about? The reason is very simple, said earlier, CTime in the file size, blocks changes will also be updated, so carefully observe, whether these two information has changed?
Update for 3.ctime (status time)


The status time is updated again after you modify the Hello.cpp file permissions with the chmod directive.
If you do not take these actions to cause the system to update themselves these three times, there is no way to artificially change these three time? The answer is yes, please keep looking down ~

Touch Command
We all know that the touch command is used to create a file, in fact, it uses another, is to modify the file timestamp.
Usage:
-A or –time=atime or –time=access or –time=use only change the access time.
-M or –time=mtime or –time=modify only change the modified time
-D,-T to specify the period of time,?? The time now
Let's give it a try:

By discovering, I just tried to modify the access time of the hello.cpp with the-a option, and the result CTime (state time) changed. Even though I actually changed the atime with touch, the status of the files changed, so CTime updated itself.

Yes, as above, I just changed the file modification time with the-M option, and CTime is still updated. The touch command still modifies the modification time only, and the state time is updated by the system itself. Why is that? Think about it, each time we use the Touch command is actually modified the file inode information, so the status time will update itself.

(GO) linux system stat instruction usage

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.