Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between soft links and hard links in Linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what is the difference between soft links and hard links in Linux, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

What is a soft link

Symbolic link Symbolic Link (symlink), also known as soft link Soft Link, is a special file that points to another file or directory on the Linux system.

This is similar to the shortcut in the Windows system, where the path of the original file is recorded in the linked file, not the contents of the original file.

Symbolic links are commonly used to link library files, as well as log files and directories shared on the network file system Network File System (NFS).

What is a hard link

A hard link is a mirrored copy of the original file. After you create a hard link, if you delete the original file, the linked file will not be affected, because the original file and the linked file are mirror copies of each other.

Why create a linked file instead of copying the file directly?

The importance of hard links becomes apparent when you need to save the same file in multiple different locations and keep it up-to-date.

If you simply copy the file to another location, the file in another location will only save the contents of the file at the moment of the copy, and will not be continuously updated with the original file.

When using hard links, the file contents of each mirrored copy are updated at the same time.

The difference between soft links and hard links

The following table lists the differences between soft links and hard links.

# soft links hard links 1 soft links similar to shortcuts in Windows systems hard links are a mirror copy of the original file 2 soft links also known as symbolic links hard links do not have aliases 3 any file in the link has changed Will be synchronized to other files in the connection like soft links 4 soft links can be created across file systems not across file systems 5 soft links can point to files or directories hard links can only point to files 6 inode and file permissions between the linked file and the original file are not identical the inode and file permissions of the linked file and the original file are exactly the same 7 the linked file records only the path of the original file Do not record the contents of the original file link file records the contents of the original file 8 if the original file is removed, the soft link will be invalidated because it points to a file that does not exist. This is called a "pending link hanging link". Even if the original file is removed, the linked file is not affected. 9 create soft links through ln-s command create hard links 10 soft link files have a special tag in the file permissions of soft link files l hard link files do not have special tags 11 through the find /-type l command can find soft link files through the find /-samefile command can find hard link files 12 through the symlinks command can find invalid soft links hard links do not have failure Links. What's the difference between soft links and hard links in Linux? that's it. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report