Linux Soft connect hard link operation and explanation

Source: Internet
Author: User

1.Linux hard links and soft connections

ln command, create a connection

command parameters:

Necessary parameters:

-B Delete, overwrite previously established link

-D allows super users to make hard links to directories

-F Force Execution

-I interactive mode, file presence prompts the user whether to overwrite

-S soft link (symbolic link)

-V displays detailed processing procedures



There are two types of Linux links, one called hard links, and the other called Symbolic links (symbolic link). By default , the ln command produces a hard link.


"Hard Connect"
A hard connection is a connection that is made through an index node. In a Linux file system, files saved in a disk partition, regardless of type, are assigned a number, called the index node number (inode index) ll-i to view the Inode node. In Linux, multiple file names point to the same index node that exists. In general, this connection is a hard connection. The purpose of a hard connection is to allow a file to have multiple valid pathname (equivalent to a person having multiple names), deleting only one connection does not affect the index node itself and other connections, only if the last connection is deleted, the file's data block and directory connection will be released. That is, the condition that the file is actually deleted is that all the hard connection files associated with it are deleted. (Note: Hard links cannot be created across partitions)

Experiment: [[email protected] ~]# Ln/etc/yum.con (2) Blue mark for created hard links

-rw-r--r--. 1 root root 0 Jul 05:47 2016-07-30.txt

-RW-------. 1 root root 1389 Jul 15:35 anaconda-ks.cfg

Drwxr-xr-x. 2 root root 6 Jul 20:30 Desktop

Drwxr-xr-x. 2 root root 6 Jul 20:30 Documents

Drwxr-xr-x. 2 root root 6 Jul 20:30 Downloads

Drwxr-xr-x. 2 root root 6 Jul 20:30 Music

Drwxr-xr-x. 2 root root 6 Jul 20:30 Pictures

Drwxr-xr-x. 2 root root 6 Jul 20:30 public

Drwxr-xr-x. 2 root root 6 Jul 20:30 Templates

-rw-r--r--. 1 root root 0 Jul 05:47 TestDir

-rw-r--r--. 1 root root 0 Jul 09:08 tr

Drwxr-xr-x. 2 root root 6 Jul 20:30 Videos

-rw-r--r--. 2 root root 970 Dec 3 yum.conf (2)

So let's compare the yum.conf and etc/yum.conf in the home directory.

135577869-rw-r--r--. 2 root root 970 Dec 3 yum.conf (2) (yum.conf under Home directory)

135577869-rw-r--r--. 2 root root 970 Dec 3 2015/etc/yum.conf

As can be seen from the above results, the hard connection file F2 the same as the Inode node of the original file F1, all 135577869, however, the inode node of the symbolic connection file is different.


"Soft link":

link

link

link link

link link

5. After the source file is deleted, the soft link file is flashing under the CentOS system, prompting the source file no longer exists, after rebuilding the source file, the soft link is not flashing prompt, indicating that the link file system has been successfully found;


Experiment; 1. [Email protected] ~]# ln-s/testdir/l/l1.link

output results [[email protected] ~]# ls

2016-07-30.txt Desktop Downloads Music public Videos

Anaconda-ks.cfg Documents l1.link Pictures Templates

Delete the original file;

[email protected] ~]# LL

Total 4

-rw-r--r--. 1 root root 0 Jul 05:47 2016-07-30.txt

-RW-------. 1 root root 1389 Jul 15:35 anaconda-ks.cfg

Drwxr-xr-x. 2 root root 6 Jul 20:30 Desktop

Drwxr-xr-x. 2 root root 6 Jul 20:30 Documents

Drwxr-xr-x. 2 root root 6 Jul 20:30 Downloads

lrwxrwxrwx. 1 root root 1 12:14 L1. Link --/testdir/l/

Drwxr-xr-x. 2 root root 6 Jul 20:30 Music

Drwxr-xr-x. 2 root root 6 Jul 20:30 Pictures

rebuilding the original file

[email protected] ~]# LL

Total 4

-rw-r--r--. 1 root root 0 Jul 05:47 2016-07-30.txt

-RW-------. 1 root root 1389 Jul 15:35 anaconda-ks.cfg

Drwxr-xr-x. 2 root root 6 Jul 20:30 Desktop

Drwxr-xr-x. 2 root root 6 Jul 20:30 Documents

Drwxr-xr-x. 2 root root 6 Jul 20:30 Downloads

lrwxrwxrwx. 1 root root 1 12:14 l1.link - /testdir/l/

Drwxr-xr-x. 2 root root 6 Jul 20:30 Music

Drwxr-xr-x. 2 root root 6 Jul 20:30 Pictures

























Linux Soft connect hard link operation and explanation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.