Soft link File
The so-called soft link is the storage path. The longer the path, the larger the file. Soft links can save space and eliminate the duplication.
How do i make a soft link?
Ln-s source file Soft link file
Not only can soft link file, also can soft link directory.
Use the path as far as possible, the following red description does not exist, because the relative path is used. After using the absolute path, there is no problem.
Examples of actual work scenarios:
Df-h Viewing disk partitions
Assuming that one of the disks is ready to be used, and that the process is writing data continuously, it can cause problems with the disk being full.
Workaround:
Put the written file under another partition that has enough space. But the premise is that you can't get the path to this file.
Suppose there is a file under boot Bill.log is already very big, but still writing, how to operate?
1, first copy the/boot/bill.log to another directory Cp/boot/bill.log/bill.log
2. Delete the original log file Rm/boot/bill.log
3. Do a soft link ln-s/bill.log/boot/bill.log
This means replacing the soft link with a file, placing the file in a different location, and continuing to work with a soft link, but the content goes to another location.
Hard link file
Inode ls-i Display Inode number
This column indicates how many files use the same inode number
Hard Links:
A file is created, and the other file is the same as its inode number, and the two are hard links to each other.
Soft links can not be deleted, once deleted will be unable to link the situation. However, hard links are not affected. Because each other is a hard link and each other is the existence of real deal, after the deletion of one, the same inode number of the file is one less. Or in this sense, the inode is the place where the data is actually stored, and the other points to the inode are skins. Delete a hard link is also just a little bit less skin, pointing to the Inode file is one less.
No more hard links will be more space, because the inode itself occupies space. So how many hard links have no effect on storage space.
You cannot make hard links to directories. Hard links can only be made to files, but not across partitions.
Linux 20180413 Soft Links Hard Links