Linux Advanced Commands (three): link command, can say the way to create a soft link, can say the way to create hard links

Link command


learning target

  • Able to say way to create a soft link
  • Able to say way to create hard links

Introduction 1. Link command

Links command is to create a file link, the link file is divided into:

  • Soft links
  • Hard links
command Explanation
LN -s Create a soft link
ln Create a hard link

2. Soft Links

Similar to the shortcuts in Windows , when a source file directory level deeper, we want to facilitate the use of it can create a soft link to the source file.

Soft links renderings:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Precautions:

  • If the soft link and source files are not in the same directory as the source file using the absolute path, you can not use relative paths.
  • Delete the source file is a soft link failure
  • You can create a soft link to the directory

3. soft links Summary

  • The role of soft links is to facilitate quick access to files, such as: a complex next to the file path to create a soft link, since you can quickly access complete the operation by soft links.
  • Format command to create a soft link: ln -s source file path (using an absolute path) soft links

4. hard link

Similar to an alias of the source file , which means that the two names pointing to the same data file.

[Pictures of foreign chains dumping fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-9w41jnSm-1583934465768) (imgs /% E7% A1% AC% E9% 93% BE% E6% 8E% A5-1.png)]

Hard link renderings:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Precautions:

  • Create a hard link using relative and absolute paths can be
  • Delete files, hard links can also access the data.
  • Create a hard link, hard link count plus 1, delete the source files or hard links, hard links will be reduced by 1.
  • Create soft links, hard links will not add 1
  • You can not create hard links to directories

Hard link count:

The number used by the file name is the number of hard links to the file data, like reference count

5. hard links Summary

  • Hard link role is to create a hard link to important documents, to prevent data files from accidental deletion.
  • Delete files, soft link failure, but still can use hard links.
  • Create a hard link command format: ln source file path hard links
Published 698 original articles · won praise 929 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_35456045/article/details/104806744
Recommended