(008) of the Linux command ln

Source: Internet
Author: User

Fundamentals of the ten-year OPS series-Linux

Zeng Lin

Contact: [Email protected]

Website: www.jplatformx.com

Copyright: Please do not reprint the article without permission

First, Introduction

The ln command can be used to create a hard link or a symbolic link. There are two ways to use it:

ln File link

Used to create hard links, while

ln-s Item link

used to create symbolic links, where the item can be a file or a directory.

Second, hard link

Hard links are the way that UNIX was originally used to create links to locate the location of a file, while symbolic links were more advanced. By default, each file has a hard link that names the file. When a hard link is created, an additional directory entry is created for the file. There are two important limitations to hard links.

    • Hard links cannot reference files outside of their own file system. In other words, a link cannot refer to a file that is not on the same disk partition as the link.
    • Hard links cannot reference directories.

Hard links are no different from the file itself. Unlike the list of directories that contain symbolic links, the list of directories that contain hard links does not have a specific link indication. When a hard link is deleted, only the link is deleted, but the contents of the file itself remain (that is, the space is not released) unless all the links to the file have been deleted.

Third, Symbolic link (soft link)

Symbolic links are created to overcome the limitations of hard links. Symbolic links work by creating a special type of file that contains a pointer to a file or directory referenced by the file. In this regard, symbolic links are very similar to shortcuts under Windows systems, but symbolic links (soft links) are older than Windows shortcuts for many years.

The file that the symbolic link points to is almost indistinguishable from the symbolic link itself. For example, by writing something into a symbolic link, these things are also written into the referenced file. When you delete a symbolic link, you delete the symbolic link without deleting the file itself. If you delete a file before the symbolic link, the link still exists, but it no longer points to any files. At this point, the link becomes a bad link.

(008) of the Linux command ln

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.