linux-soft connections, hard links

Source: Internet
Author: User


In Linux, everything is file. Each file has an inode number that matches it, and each inode can match multiple files.

and links have soft links, hard links of the points. A soft link is like a shortcut to Windows, and a hard link is like an alias (two files are identical, even the inode number is the same).

Soft links

1. Create a soft connection

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/89/32/wKioL1gMEq-AZwqWAAAV7D_Q36s838.png-wh_500x0-wm_3 -wmp_4-s_2298808055.png "title=" Create file 1.png "alt=" Wkiol1gmeq-azwqwaaav7d_q36s838.png-wh_50 "/>

2. link files using ln-s source files

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/89/35/wKiom1gME1qxHMtIAAA2T-pd250497.png "title=" Create a soft connection. png "alt=" Wkiom1gme1qxhmtiaaa2t-pd250497.png "/>

3. View source files and soft connection files (source files are the same as soft connection content)

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/89/35/wKiom1gME7XSqaoeAAAhFEIh7OA990.png "title=" View soft connect. png "alt=" Wkiom1gme7xsqaoeaaahfeih7oa990.png "/> 4. Append data to the source file and see if the soft connection is also synchronized

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/32/wKioL1gMFDegqi75AAAkVanj7ts127.png "title=" Soft connect append data. png "alt=" Wkiol1gmfdegqi75aaakvanj7ts127.png "/>

5. View the inode number of two files (two inode numbers are different)

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/35/wKiom1gMFVbSwHk9AAAhlBcTJVU345.png "title=" View the inode number. png "alt=" Wkiom1gmfvbswhk9aaahlbctjvu345.png "/>

6. Delete the source file to see if the soft connect file is still present (the soft link file still exists but is not accessible)

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/89/32/wKioL1gMFMjR2wG1AAA-8OnqYhg841.png "title=" Delete the source file. png "alt=" Wkiol1gmfmjr2wg1aaa-8onqyhg841.png "/>

Hard Links

1. Creating source files and hard-linked files

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/35/wKiom1gMFifRvnm4AAAnxG_nxFk506.png "title=" Create a hard link. png "alt=" Wkiom1gmfifrvnm4aaanxg_nxfk506.png "/>

2. View Append source file contents and see if Hard links are synchronized (both sides will synchronize the data)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/32/wKioL1gMFpORSw17AABTIa6VpoQ678.png "title=" Append hard-link content. png "alt=" Wkiol1gmfporsw17aabtia6vpoq678.png "/>

3. View Inode number

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/32/wKioL1gMFuCBCesoAAAeTbT9vFM597.png "title=" View hard links inode.png "alt=" Wkiol1gmfucbcesoaaaetbt9vfm597.png "/>

4. Delete the source file to see if the hard-link file still has normal access (hard-link file or normal access)

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/35/wKiom1gMF1-CuQ-TAAAtBmj9sCM371.png "title=" Delete source file due to link. png "alt=" Wkiom1gmf1-cuq-taaatbmj9scm371.png "/>

Also note that hard links cannot be created across partitions (because each partition has a separate inode number, each partition cannot be confused)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/32/wKioL1gMGAvTKZMiAAB_hQ9up4s312.png "title=" Hard links also cannot span partitions. png "alt=" Wkiol1gmgavtkzmiaab_hq9up4s312.png "/>


This article from "evoices" blog, declined reprint!

linux-soft connections, 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.