Hard links and soft links under Linux

Source: Internet
Author: User

"Hard Link"

A hard link is a link through an index node, too complex to see the operation.

Hard-Link creation

[[email protected] ~]# mkdir-p/test/oldboy/Create a directory oldboy/

[[email protected] ~]# cd/test/oldboy/switch to this directory

[email protected] oldboy]# Touch Oldboyfile #创建一个测试文件

Make a hard link

[[Email protected] oldboy]# ln oldboyfile oldboyfile_hard_link//oldboyfile source file Oldboyfile_hard_ Link Hard link file

To view the Inode node number of a file

[[email protected] oldboy]# Ls-li//ls-li View inode node number for each file

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5B/87/wKiom1UK4g_icujpAADAMjFpoRg135.jpg "title=" 11111111111.png "alt=" Wkiom1uk4g_icujpaadamjfporg135.jpg "/>


Oldboyfile oldboyfile_hard_link Two files have the same inode number, which by default is only one inode node number per file, Here the two same inode numbers indicate that there is a hard link file that is the same as the Inode node number after the file is a hard link file here the oldboyfile_hard_link file is a hard link.





"Soft link"

Types of shortcuts in Windows systems


Creating a soft link

[[email protected] oldboy]# ln-s oldboyfile oldboyfile_soft_link//oldboyfile means file source oldboyfile_soft_link represents a soft link file

To view the Inode node number for the next file

[Email protected] oldboy]# Ls-li

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5B/87/wKiom1UK4juhRtUgAAD2-RZAwXo839.jpg "title=" 2222222222.png "alt=" Wkiom1uk4juhrtugaad2-rzawxo839.jpg "/>

Although soft links and hard links are theoretically the same file but the node number is different, this is the difference between soft links and hard links


Delete the effect of the original file on hard links and soft links

[Email protected] oldboy]# rm-f oldboyfile

[Email protected] oldboy]# Ls-li

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/81/wKioL1UK452jqkonAADHij0jSxM425.jpg "title=" 4444. PNG "alt=" wkiol1uk452jqkonaadhij0jsxm425.jpg "/>

View Hard Links

[email protected] oldboy]# cat Oldboyfile_hard_link

This is a test


View Soft Links

[email protected] oldboy]# cat Oldboyfile_soft_link

Cat:oldboyfile_soft_link:No such file or directory


Delete the original file has no effect on the hard link, has effect on the soft link

Note The ln command is not a hard-link to create a directory, but you can create a soft link


This article is from the "Scribbled Life" blog, so be sure to keep this source http://972010.blog.51cto.com/962010/1622389

Hard links and soft links under Linux

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.