


What is the difference between soft link and hard link
What is a hard link?
Hard link (hard link): A is a hard link to B (A and B are both file names), then the inode node number in A’s directory entry is the same as the inode number in B’s directory entry The node numbers are the same, that is, one inode node corresponds to two different file names, and the two file names point to the same file. A and B are completely equal to the file system.
(Recommended tutorial: linux tutorial)
If you delete one of them, it will have no effect on the other. Every time a file name is added, the number of links on the inode node increases by one. Every time a corresponding file name is deleted, the number of links on the inode node decreases by one until it reaches 0, and the inode node and the corresponding data block are recycled.
Note: Files and file names are different things. rm A deletes only the file name A, and the data block (file) corresponding to A will only be deleted when the number of inode node links is reduced to 0. System recycling.
What is a soft connection?
Soft link is a commonly used command in Linux. Its function is to establish a synchronous link for a certain file in another location.
(Video tutorial recommendation: linux video tutorial)
The specific usage is: ln -s source file target file.
When we need to use the same file in different directories, we do not need to put a file that must be the same in every required directory. We only need to use the ln command to link in other directories. (link) is fine, there is no need to repeatedly occupy disk space.
Difference:
1. Mount point
Only hard links can be created between files on the same storage media. , hard links cannot be created between files under different mount points. In the latter case, soft links can be used; (distinguish between different mount points and different directories on the same mount point)
2. Directory
Soft link is equivalent to a shortcut in win. That is, if a soft link to a directory is just a shortcut to a directory to a specified location, the operating system will directly find the file in the real directory when looking for this shortcut. But hard links are equivalent to mirroring. After creating a hard link to a directory, the operating system needs to make a hard link (copy a copy) of all the files in this directory, so that when the operating system accesses this link It needs to be traversed continuously, which greatly increases the complexity, and it is easy to enter an infinite loop.
Hard links cannot be created for directories due to the design of the file system. Directories in the Linux file system hide two special directories, the current directory and the parent directory. In fact, they are two hard links. If the system creates a hard link to the directory, a directory loop will occur.
The above is the detailed content of What is the difference between soft link and hard link. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Linux soft links and hard links: Interpretation of principles and characteristics In Linux systems, soft links and hard links are common concepts in file systems. They allow us to manage files and directories more flexibly. In this article, we will delve into the principles and characteristics of soft links and hard links to help readers better understand their differences and uses. 1. The concepts of soft links and hard links. Soft link (SymbolicLink), also known as symbolic link, is a special type of file, similar to shortcuts in Windows systems.

How to create soft links in Ubuntu? Let’s take a look at the detailed tutorial below. 1. First, we create a text file. Next, we will create a soft link to this file, as shown in the figure below. 2. Then we use the Vim editor in Ubuntu to write some content to the text file, as shown in the figure below. 3. Next, use the ln command to create a soft link, as shown in the figure below, which means creating a soft link to the 1.txt text on 1-softlink.txt. 4. List the contents of the current folder, and we can see the newly created soft link. It is already in the folder, as shown in the figure below 5. Next we copy the content of the soft link to a txt text. You will see this txt text under the current folder. 6. This

How to use the os.Link function in golang to create a hard link to a file. In the operating system, a hard link refers to a file pointed to by multiple file names. When a file has multiple file names, they all point to the same i node (inode), that is, they share the same data block. In Golang, we can use the os.Link function to create a hard link to a file. This article explains how to use this function and provides specific code examples. First, we need to understand some relevant background knowledge. Hard link is

Soft links and hard links in Linux are two common link methods. They have some differences in use. This article will explore in depth the characteristics and differences of these two links. 1. Soft link A soft link (symbolic link), also known as a symbolic link, is a link pointing to a file or directory, similar to a shortcut under Windows systems. A soft link is actually a special file that contains the path information of the original file. When we open a soft link, we are actually accessing the linked object. Create a soft link:

The difference between soft links and hard links in Linux: 1. Soft links exist in the form of paths, and hard links exist in the form of file copies, but do not occupy actual space; 2. Soft links can cross file systems, but hard links cannot; 3. A soft link can link to a file name that does not exist, and a hard link can only be created in the same file system. 4. A soft link can link to a directory, but a hard link does not allow you to create a link to a directory.

How to understand the meaning of the number of hard links in LINUX? Today we will introduce it in detail. 1. Open the LINUX operating system and use UBUNTU. 2. Find the terminal window on the left taskbar and open it. 3. Change to the desktop directory, and then view the specific information of the files and directories. Pay attention to this column of numbers. 4. For example, new.txt has only one hard link, which is the absolute path. 5. The new directory has 4 hard link directories. You can first use CD to transfer to this directory. 6. If you are under this directory, you can also use cd to return to the original directory. 7. In order to clearly understand more hard links, use tree to view. 8. Because there are other directories under the same directory, go to the new directory in other directories.

This article will explain in detail about establishing a hard connection in PHP. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. What is a hard link? A hard link is a special file system pointer that points to another file. It is different from a symbolic link, which points to the file path, while a hard link points to the file itself. This means that the hard link shares the same inode as the original file, which is a structure stored in the file system that represents the file's metadata. Therefore, the hard link has the same name, size, and ownership as the original file. Creating hard links in PHP You can use the link() function to create hard links in PHP. This function requires two parameters

Soft links and hard links in the Linux operating system are common concepts in file systems, and they play an important role in file management and data storage. There are some differences in the use and characteristics of soft links and hard links. This article will compare and analyze the similarities and differences between these two link methods in detail. 1. Soft link (symboliclink) Soft link, also known as symbolic link, is a special file type that creates a symbolic link pointing to another file. A soft link is actually a shortcut to a file path, similar to Wi-Fi
