Home  >  Article  >  Operation and Maintenance  >  How to connect in linux

How to connect in linux

(*-*)浩
(*-*)浩Original
2019-11-07 11:09:173491browse

Linux connections are divided into two types, one is called Hard Link, and the other is called Symbolic Link, which is also Soft Link.

How to connect in linux

By default, the ln command generates a hard link, and the ln -s command generates a soft link.

[Hard connection] Hard connection refers to connecting through index nodes. In the Linux file system, files stored in disk partitions are assigned a number, no matter what type they are, called the Inode Index. (Recommended learning: linux operation and maintenance)

In Linux, multiple file names pointing to the same index node exist. Generally this connection is a hard connection. The function of hard link is to allow a file to have multiple valid path names, so that users can establish hard links to important files to prevent "accidental deletion".

The reason is as mentioned above, because there is more than one connection to the index node corresponding to the directory. Deleting only one connection does not affect the index node itself and other connections. Only when the last connection is deleted, the data blocks of the file and the directory connections will be released. In other words, the condition for the file to be truly deleted is that all hard-linked files related to it are deleted.

There are 2 restrictions on hard links:

It is not allowed to create hard links to directories

Can only be created between files in the same file system Link. That is, a hard link cannot be established between two files on different hard disk partitions. This is because the hard link points to the original file through the node, and the node of the file may be different in different file systems.

[Soft link] Soft link is also called a symbolic link. It is actually a special file, somewhat similar to a Windows shortcut.

This file contains the path name of another file. It can be any file or directory, and can link files in different file systems. Linked files can even link to files that do not exist, which causes a problem generally called "broken link" (or "phenomenon"). Linked

files can even link themselves circularly. Similar to recursion in programming languages.

The above is the detailed content of How to connect in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn