Use of soft links
(1) Soft links can be cross-partitioned, you can also create soft links to the directory
(2) When a partition is not sufficient, you can create a soft link under the partition that is linked to a large partition, which
To avoid full disk writes
(3) Sometimes a file is used multiple times, and must be in multiple directories, we can create a soft link to the file
The soft connection is equivalent to the shortcut under Windows, has the function of saving space, can cross partition, the file, the directory can make the soft connect
, make a soft connection to pay attention to the absolute path, or error prone.
Du-sh fliename1 filename2 comparison two file size
Ln-s do a soft connection
such as: The/root under 1.txt Soft connect to/tmp under the name of 2.txt
#ln-S/root/1.txt/tmp/2.txt
#ls-L/tmp/2.txt
lrwxrwxrwx 1 root root 11 December 04:36/tmp/2.txt-/root/1.txt
Example: #ln-S/root/111/tmp/222
#ls-L/tmp/222
lrwxrwxrwx 1 root root 10 December 05:01/tmp/222-/root/111/
Linux allows multiple files to correspond to one inode does not allow multiple inode to correspond to one file
Hard link essence is to do a double, while pointing to an inode, the directory can not do hard links, can not cross the partition.
The difference description of soft link hard link
(1) Soft link is equivalent to a shortcut under Windows, when the source file is deleted then the soft link fails
(2) Hard links cannot span partitions
(3) Hard links do not work in the directory
(4) deleting hard-linked source files is not affected
Make a hard link:
Do hard links after Ln without +/-s
Such as:
#ln/root/1.txt/tmp/2.txt
#ls-li/root/1.txt/tmp/2.txt
391871-rw-r--r--2 root root 12777 December 05:17/root/1.txt
391871-rw-r--r--2 root root 12777 December 05:17/tmp/2.txt
# Du-sh/root/1.txt;du-sh/tmp/2.txt
16k/root/1.txt
16k/tmp/2.txt
All sizes are 16k,inode, 391871.
You can also use #ls-lih to view
#ls-ihl/root/1.txt/tmp/2.txt
391871-rw-r--r--2 root root 13K December 05:17/root/1.txt
391871-rw-r--r--2 root root 13K December 05:17/tmp/2.txt
Linux soft Connect and hard link _note