1. View file Properties Ls-lhi
File attributes detailed description
1 . First column: Inode index node number 2. Second column: File type and Permissions 3. Third column: Number of hard links 4. Fourth column: The user to which the file or directory belongs, that is, the owner of the file 5. Fifth column: The group to which the file or directory belongs. 6. Sixth column: The size of the file or directory. 7. 第七、八、九 column: File or directory modification time
2. Inode Summary
The disk is partitioned and formatted as the Ext4 file system generates a certain number of inode and block. The inode is called an index node, which is used to store the file's attribute information and the index of the file content (pointing to the entity block).
A non-empty piece must occupy at least one inode and one block. The Inode node number is the same file, which is the hard-linked file. The inode is unique within a file system (partition). View inode information with ls-i (see the inode for some files) or df-i (see the Inode remaining in the system).
3, block summary
block is used to store the actual data, the disk read information is read in block units, a file may occupy more than one block, each read a block will be consumed once disk I/O, a block remaining space will be wasted, no matter how small. Use Dumpe2fs/dev/sda3 |grep-i "block size" or df-h to see how much disk is being used.
4. File permissions
5. Hard links
ln source file Destination file
Soft Connect: Ln-s source File Destination file
A hard link is created by executing the command "ln source file Destination file", in which multiple files with the same inode number are hard-linked files on the same file system.
Hard links and deletions:
The source files and hard links are deleted, the file can be completely deleted. One of the conditions in which the file is deleted is the number of hard links is 0.
To view the number of hard links for a file: Ls-lhi, stat
6. Soft Link
The soft link file in Linux is actually a special file, the file type is L, can be understood as a text file, this file contains a soft link to another source file location information.
Soft links are created by executing the command "ln-s source file Destination file"; Soft links and source files are different types of files and different files, and their inode is different.
The hard link file is the same as the inode of the source file, and the soft link is different from the source file;
You cannot create a hard link for a catalog, but you can create a soft link
Soft links can cross file system, hard links can not cross file system;
Deleting linked source files has no effect on hard links, soft links will not be available;
Delete the source file and the hard link file at the same time, the whole file can be deleted
7. File deletion
Linux is deleted through the link number control file, only if a file I-count and I-link are 0 files.
I-count the number of calls to the current file (memory reference counter, incremented by process call)
I-link Number of media links (disk reference counters, increased when creating hard links)
8. Small Business case
disk space is full but inconsistent with du-sh results, how to resolve?
The first milestone of ①
# # # #已经删除了, but the space is not released
# # # #已经删除了-----The number of hard links to the file is 0
# # # # #空间没有释放---Someone else is using---process
② a second milestone
# lsof |grep Delete
RSYSLOGD 1250 Root 1w REG 8,3 1888889326 274029/var/log/messages (Deleted)
# # # # #硬链接数为0了, but there's another rsyslog software in use
# # #这个文件没有被彻底删除
③ a third milestone
# #重启对应的软件/Service can be
#/etc/init.d/rsyslog Restart
Shutting down system logger: [OK]
Starting system logger: [OK]
The fourth milestone of ④
Dh-f
1. Try emptying the log file without deleting
2. Cut the log, delete the old file (a few days ago)
No space left on device (insufficient disk space)
Block full, df-h-----du-sh/*---500G disk into 3 300G files
The block is full and the number of hard links is 0 (the log files are deleted by RM) and the process consumption is not zero. Lsof|grep Delete
The Inode is full.
Linux operations, Architecture road-linux file properties