Linux System Learning ln (soft connections and hard links)

Source: Internet
Author: User

Simple to understand, Soft connect : Create a soft Connection file is a shortcut to the source file, delete the created soft connection file, the source file is unaffected, the connection disappears.

Hard link : Two conjoined files, modify one of the files, the other file will also change, delete one of the files, the other file has no effect, but the connection disappears.

Deepen understanding through experimentation
[Email protected]]$ Touch F1 #创建一个测试文件f1
[Email protected]]$ LN F1 F2 #创建f1的一个硬连接文件f2
[Email protected]]$ ln-s F1 F3 #创建f1的一个符号连接文件f3
[[Email protected]]$ ls-li #-I parameter displays inode node information for a file
Total 0
9797648-rw-r--r--2 Oracle Oinstall 0 APR 08:11 F1
9797648-rw-r--r--2 Oracle Oinstall 0 APR 08:11 F2
9797649 lrwxrwxrwx 1 Oracle oinstall 2 APR 08:11 f3-f1

As can be seen from the above results, the hard connection file F2 the same as the Inode node of the original file F1, all 9797648, however, the inode node of the symbolic connection file is different.

[Email protected]]$ echo "I am F1 file" >>f1
[Email protected]]$ Cat F1
I am F1 file
[Email protected]]$ cat F2
I am F1 file
[Email protected]]$ cat F3
I am F1 file
[Email protected]]$ rm-f F1
[Email protected]]$ cat F2
I am F1 file
[Email protected]]$ cat F3
Cat:f3:No such file or directory

Deepen understanding through experimentation
[Email protected]]$ Touch F1 #创建一个测试文件f1
[Email protected]]$ LN F1 F2 #创建f1的一个硬连接文件f2
[Email protected]]$ ln-s F1 F3 #创建f1的一个符号连接文件f3
[[Email protected]]$ ls-li #-I parameter displays inode node information for a file
Total 0
9797648-rw-r--r--2 Oracle Oinstall 0 APR 08:11 F1
9797648-rw-r--r--2 Oracle Oinstall 0 APR 08:11 F2
9797649 lrwxrwxrwx 1 Oracle oinstall 2 APR 08:11 f3-f1

As can be seen from the above results, the hard connection file F2 the same as the Inode node of the original file F1, all 9797648, however, the inode node of the symbolic connection file is different.

[Email protected]]$ echo "I am F1 file" >>f1
[Email protected]]$ Cat F1
I am F1 file
[Email protected]]$ cat F2
I am F1 file
[Email protected]]$ cat F3
I am F1 file
[Email protected]]$ rm-f F1
[Email protected]]$ cat F2
I am F1 file
[Email protected]]$ cat F3
Cat:f3:No such file or directory

Linux System Learning ln (soft connections and hard links)

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.