Analysis of creating hard links and soft links for ln commands in Linux

Source: Internet
Author: User

In the process of using Linux, the most user headache should be the Linux unique command line, and not so many command line has let us complain incessantly, the key each command has a lot of options, of course, this is what we often say that the Linux command line is a very powerful function of a very important reason, It is these options that make each of our commands full of variables, and no longer a monotonous picture. Today, say a more important command in the command: ln (the shorthand for link).

Why does the execution of the same command have a soft and hard result? It's about their nature. A soft link is essentially a desktop shortcut on Windows, and this shortcut contains an absolute path to the executable file from the desktop to the app. Therefore, it is at best a product of icons and paths. In Linux, the even icon is saved, so the linked file does not need to occupy a large amount of space on the hard disk. So what about hard links? In fact, the hard link may be said to be a copy of the source file. It is only in Linux that it is represented and called in a form of a link. In addition to full replication, because of the concept of nodes in the Linux file system, each additional hard link adds 1 to the original node, so when we use the "

Ls-al

command to display a file in the current directory, you will see a number after the permission, which means how many nodes the file has. A soft link does not increase the number of node points. In addition to being fundamentally different, there is a notable point where hard links cannot exist across partitions, and soft links can. Finally, we enclose two kinds of link command representations:

Soft Links:

Ln-s sourcefile DestFile

Hard Links:

ln sourcefile destfile


Analysis of creating hard links and soft links for ln commands in 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.