Windows shortcuts, symbolic links, soft links and hard links

Source: Internet
Author: User

In my previous impression, the ln command under Linux looked like a shortcut under Windows, but after touching the Mklink command under Windows, it found that the links under windows were powerful
The ln command under Linux

Linux under the LN command is still very powerful, you can create soft links and hard links, using the following methods:

Ln-s Source Dist # Establish a soft connection
LN Source Dist # Establish a hard connection

About the soft chain and hard chain underneath Linux, you can read this article: Understanding the hard links and soft links of Linux.
links under Windows

Under Windows 7, under the NTFS file System, if the shortcut is also a link, there are shortcuts, symbolic links, soft links and hard links in four ways.
Shortcut

Shortcuts should be familiar, have points to local files and point to Web URLs, are not affected by partitions, and so on, using the absolute path of the system, and double-clicking the shortcut also jumps to the environment where it points to the file to do something.

Shortcuts are normal files, only the suffix uses the LNK and URL two to refer to shortcuts to local files and networks, and the two suffixes are not displayed in normal situations, they can be displayed in command-line mode, and they are opened using some text editors, You can see that part of it points to the path to the file.
The Mklink command under Windows

Open the command line, direct input mklink can see the output Mklink Help information

Create a symbolic link.

Mklink [[d] | [/h] | [/j]] Link Target

/d creates a table of contents symbolic links. Default to File
Symbolic links.
/h Create hard links instead of symbolic links.
/j Create a directory join.
LINK Specifies the new symbolic link name.
TARGET specifies the path to the new link reference
(relative or absolute).

Can see, the function is still quite many, probably has the following several link ways

Mklink Link Target # Creates a symbolic link to a file
MKLINK/D Link Target # Create a symbolic link to a folder
mklink/j Link Target # Create a soft link to a folder (join)
mklink/h Link Target # Creates a hard link to a file

Symbolic Links

Symbolic links support files and folders, and shortcuts are the difference is that the shortcut will jump back to its own environment, and the symbolic link will not jump back, but use the created environment, such as the creation of a link with the symbolic links and shortcuts to a file, open the link file, the symbolic link to display the filename is Link, and the shortcut shows a. When a symbolic link points to a file update, the original file is also updated. Also, the symbolic links created under Windows are equivalent to the symbolic links (soft links) below Linux.

Soft links

Soft links are just links to supporting folders, and does not support file links, and the difference between symbolic links is the symbolic link at the time of creation can use relative path and absolute path, after the creation of success is the corresponding relative path and absolute path, the absolute path in the original file (folder) does not move the case can be, and the relative path is relative to the path of two files, so the relative position of two files will not be linked to errors, and soft links whether in the creation of the use of a relative or absolute path, after the creation of all converted to absolute path. The other difference is that the symbolic link attribute is similar to a shortcut, and the soft link type is a type that has no difference to the file, as shown below

Hard Links

Similarly, like Linux, under Windows, hard links are not supporting folders (directories), which is related to the file system, hard links and soft links are the difference between a hard link is a file, and from the point of the file is at the same level, two files point to the same physical path, So delete any one, no effect on the other, and one file update, the other will also hate the update. Because of this, hard links can only be created in the same partition.

A few distinctions are like the following schematic

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.