Get the App
SLTechnology News&Howtos  ›  Servers  › 

There are two different categories of file links in Linux. Symbolic links (also known as soft links) hard links

Shulou Source: shulou.com Published: 2022-06-02 23:03:43 10月04日 Update

There are two different categories of file links in Linux.

Symbolic links (also known as soft links)

Hard link

1, the size of the soft link file is different from the source file, the soft link file stores the soft link to the source file pointing relationship, so it is good to understand their different size, can be understood as a pointer.

2. The Inode number, size and last modification time of the hard link file are exactly the same, which can be understood as cp-p copied a source file and retained the attributes of the source file.

A hard link creates a separate file, and referencing the hard link file is the same as referencing the source file:

1. How to create hard links

Method 1: cp-l source file hard link file

Method 2: use ln (meaning link) to hard link the ln source file

By default, the ln command creates a hard-linked file

3. The difference between modifying the file, modifying the source file and the last modification time of the hard link file synchronously, while the last modification time of the soft link file remains the same. It is also fully explained here that the soft link stores only the location and information of the source file, while the hard link and the source file are the same file.

4. The difference between deleting files: delete hard-linked source files, hard-linked files are still available. Delete the source file of the soft connection file, the soft connection is not available

In linux system, an Inode number can correspond to multiple file names, the source file of the hard link file is deleted, only the mapping from the index node to the source file of the hard link file is deleted, the mapping from the index node to the hard link file still exists, and the index hard link file is still available.

Delete the source file of the soft connection file, because the soft connection stores the location and information of the source file, view the soft connection file, the source file has been deleted, so the soft connection is not available.

Tags: Links files source files different indexes nodes size time storage location information just methods also known as symbols categories same commands multiple attributes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi OPPO Reno Shulou Tech Info macOS