How to explain hard links and soft links to people brainwashed by Windows

Source: Internet
Author: User

This is a collection of materials prepared to explain soft-link hard links to those who are familiar with windows and have no access to Linux. If there are any errors or unknown information, please note that the materials are scattered and further processing is required. Please kindly advise on the processing methods.

 

Soft links (also called symbolic links) are basically the same as shortcuts in windows. Soft links are also a file, and the content of the file is directed to another file, this is also the shortcut in windows. If you observe it in windows, the shortcuts are all. lnk file, if not displayed by the resource manager. the suffix of lnk. You can use DIR or ls in cmd to display the shortcut files. The soft link in Linux is also a file, and the content of the file points to another file.

 

The basic correspondence between hard links and wondows is fsutil hardlink under NTFS. in addition, there is a SUBST in Windows that maps folders to disks. I think the files under such files are similar to hard links.

 

 

The hard link points to the node inode, and the soft link points to the file path. In terms of File System partitions, a file consists of inode, file content data, and directory items (file names). Creating a hard link is to create a directory item (File Name) for a group of inode and data records ), the relationship between inode and directory items is that each directory item points to this inode, and the reference count in inode is + 1. If no directory item is deleted, the count is-1, if the count is reduced to 0, the file can be completely erased. A soft link itself is a file. The content of the file guides the file system to another file path. The soft link does not affect the inode reference count of the target file, you can even set up a soft link to point to the soft link file itself. If the target path of the soft link has been deleted, the existence of the soft link file is not affected, but the link is broken. It is equivalent to the shortcut for Windows to lose the target file.

I guess if a program opens a file through a soft link, the operating system will actually record that it opened two files in the resources used by the program, they are soft-link files and genuine target files. If you want to be knowledgeable, give me some advice.

In Linux, unlink can be used to delete files without using RM. In fact, unlink is more original.

 

Why do I need soft links when I have a hard link?

(This is similar to why the SUBST command is used in Windows to map the disk or junction ing directory, and there is also a shortcut .)

Hard links and soft links have different limitations. Hard links cannot be used across file systems because they point to the same inode. This is only possible in a file system partition. Without this restriction, soft links can be uploaded across file systems, or even files on the network.

Because hard links are inode-related, you cannot create hard links for folder uploading. However, you can create soft links.

Creating a hard link for a file is similar to creating an alias for this file, these two names are similar, not completely equivalent, because they cannot tell who is the first original file name and who is the alias after the two names. These two or more names are exactly the same.

 

 

What is the relationship between creating a hard link and copying a copy?

Creating a hard link does not create a new file on the disk, but the same file has two or more file names. Operating on any file name is to operate on the same file. The copy is indeed copying this file to one side on the disk. Since then, the two files are the same at the beginning, and then the change to any one has nothing to do with the other.

 

Resource:

[Excellent] What about hard connection and soft link? -Chinaunix.net http://www.chinaunix.net/jh/24/150986.html

Reading Notes: How to Create soft links and hard links in Windows (like Linux ln) | mosquito ~ Paradise http://www.luowei620.cn /? P = 232

How to Create soft links and hard links in Windows | tower Jing: Thanksgiving http://www.taoer.com/2010/06/11/windows-create-symbolic-link-method/

In Linux Shell, what is the difference between Unlink and RM commands? -Chinaunix.net http://bbs.chinaunix.net/thread-2080409-1-1.html

Fengyun Zhi» [Linux] hard link and soft link (symbolic link) Difference http://witmax.cn/linux-links.html

 

Related Article

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.