Linux file properties
In Linux, for each file has the corresponding attributes, in the root user home directory of Linux in the new file A.txt as an example, enter a few characters in the A.txt
- Use command Ls-ild a.txt to view file permissions, etc.
[Email protected] ~]# Ls-ild a.txt
1057689-rw-r--r--. 1 root root 8 Apr 9 19:42 a.txt
Description
First column: 1057689 inode number of the file
1th bit of the second column:-file type, common file types include
D: Folder
-: Normal file
L: Links (Windows-like shortcuts)
B: block device files (e.g. hard drives, optical drives, etc.)
P: Pipeline File
C: Character device files (e.g. serial devices such as cats)
S: Set of interface files/data interface files (e.g. a Mysql.sock file is generated when starting a MySQL server)
Second column 第2-10位: rw-r--r--file user, user group, other user other (others is the user except root (root has the highest privilege), the file owner, the file belongs to the user group all users) right
The third column:. Point indicates that the file is protected by SELinux and the selinux mechanism is turned on to indicate
Fourth column: 1 1 indicates the number of inode connections, that is, the number of hard links
Fifth column: root-owned users
Sixth column: root-owned user group
Seventh column: 8 file size, default in bytes
Eighth column: APR 9 19:42 Last modified (created)
Nineth column: A.txt file absolute path and name
- Use the command stat a.txt to view file detail properties
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:8 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:42:13.300081234 +0800
modify:2018-04-09 19:42:13.300081234 +0800
change:2018-04-09 19:42:13.361073559 +0800
Description
File: ' a.txt ' file name
Size:8 File Size
Total number of data blocks used by the Blocks:8 file
Io block:4096 io block size
Regular file type: General file
device:802h/2050d Device number
inode:1057689 inode Number
Links:1 Number of links
Access: Permissions for (0644/-rw-r--r--) files
UID: (0/root) GID: (0/root) file ownership of GID and UID
access:2018-04-09 19:42:13.300081234 +0800 Access time
modify:2018-04-09 19:42:13.300081234 +0800 Modification Time
change:2018-04-09 19:42:13.361073559 +0800 State modification Time
3, about these three kinds of time description
1> access times (access time abbreviated to ATIME)
2> Modified (Modify time abbreviated to Mtime)
3> State modification Time (change times abbreviated to CTime)
Atime: (Access Time), which shows when the data in the file was last accessed, such as the system
Process is used directly or indirectly through some commands and scripts. (Execute some executable file or script)
Mtime: (modifytime) modified the file content Mtime changed. The modified time, which shows the last time the contents of the file were modified, such as when editing with VI, will be changed. (i.e. the contents of block)
CTime: (changetime) modified the file attributes CTime changed. State modification, Time displays the attributes, that is, the permissions of the file, the owner, the group to which it belongs, and the time when the number of links has changed. Of course, when content changes, it changes (i.e. when the inode content changes and the block content changes)
Updates for Atime
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:8 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:42:13.300081234 +0800
modify:2018-04-09 19:42:13.300081234 +0800
change:2018-04-09 19:42:13.361073559 +0800
[email protected] ~]# cat A.txt
Abcdefg
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:8 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0744/-rwxr--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:49:36.626081357 +0800
modify:2018-04-09 19:42:13.300081234 +0800
change:2018-04-09 19:42:13.361073559 +0800
Mtime Update (Append the contents of the file, while modifying the content, the size of the file also changed, so its ctime also changed)
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:8 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0744/-rwxr--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:49:36.626081357 +0800
modify:2018-04-09 19:42:13.300081234 +0800
change:2018-04-09 19:48:48.649078595 +0800
[Email protected] ~]# echo "Hello World" >>a.txt
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:20 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0744/-rwxr--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:49:36.626081357 +0800
modify:2018-04-09 19:57:45.272068288 +0800
change:2018-04-09 19:57:45.272068288 +0800
Updates for CTime
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:8 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:42:13.300081234 +0800
modify:2018-04-09 19:42:13.300081234 +0800
change:2018-04-09 19:42:13.361073559 +0800
[Email protected] ~]# chmod u+x a.txt
[Email protected] ~]# stat a.txt
File: ' A.txt '
Size:8 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1057689 links:1
Access: (0744/-rwxr--r--) Uid: (0/root) Gid: (0/root)
access:2018-04-09 19:42:13.300081234 +0800
modify:2018-04-09 19:42:13.300081234 +0800
change:2018-04-09 19:48:48.649078595 +0800
Bo Master original articles, reproduced please be sure to indicate the source
Linux Learning 12-linux file properties