硬連接:當系統要讀取一個文件時,會先讀inode信息,而後再根據inode中的信息到塊區域將數據取出來。而硬連接是直接再創建一個inode連接到文件放置的塊區域。即創建硬連接時該文件內容沒有變化,只是增長了一個指向這個文件的inode,並不會額外佔用磁盤空間。node
硬連接不支持對目錄作連接,只支持對文件作連接windows
[root@localhost ~]# ln 1.txt 1_heard.txt
[root@localhost ~]# ln -s 1.txt 1_sorft.txt
[root@localhost ~]# ls -l 總用量 32 drwxr-xr-x. 3 root root 45 10月 26 16:11 111 -rw-r--r--. 1 root root 0 10月 26 15:54 111.12.txt -rw-r--r--. 2 root root 391 10月 30 15:10 1_heard.txt lrwxrwxrwx. 1 root root 5 10月 30 15:06 1_sorft.txt -> 1.txt [root@localhost ~]# ls -i 33584735 111 33575033 1_sorft.txt 33575034 2.txt 33574987 anaconda-ks.cfg 33584737 111.12.txt 33575035 1.txt 33584734 3.txt 33575006 anaconda-ks.cfg.1 33575035 1_heard.txt 33584733 1.txt~ 33584736 3.txt~ 33575036 windows.txt
[root@localhost ~]# rm 1.txt rm:是否刪除普通文件 "1.txt"?y [root@localhost ~]# ls -l 總用量 28 drwxr-xr-x. 3 root root 45 10月 26 16:11 111 -rw-r--r--. 1 root root 0 10月 26 15:54 111.12.txt -rw-r--r--. 1 root root 391 10月 30 15:10 1_heard.txt lrwxrwxrwx. 1 root root 5 10月 30 15:06 1_sorft.txt -> 1.txt
[root@localhost ~]# ls -i 1_heard.txt 33575035 1_heard.txt
[root@localhost ~]# ln 111 hf11 在硬連接指向目錄的時候,會提示錯誤 ln: "111": 不容許將硬連接指向目錄
[root@localhost ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 18G 1.1G 17G 6% / devtmpfs 483M 0 483M 0% /dev tmpfs 493M 0 493M 0% /dev/shm tmpfs 493M 6.7M 486M 2% /run tmpfs 493M 0 493M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 99M 0 99M 0% /run/user/0 [root@localhost ~]# ls -i /boot/ 71 config-3.10.0-514.el7.x86_64 67 grub 131136 grub2 76 initramfs-0-rescue-513f8b3950084e768a99df3a6cd3d9e6.img 75 initramfs-3.10.0-514.el7.x86_64.img 189445 initramfs-3.10.0-514.el7.x86_64kdump.img 74 initrd-plymouth.img 72 symvers-3.10.0-514.el7.x86_64.gz 70 System.map-3.10.0-514.el7.x86_64 77 vmlinuz-0-rescue-513f8b3950084e768a99df3a6cd3d9e6 73 vmlinuz-3.10.0-514.el7.x86_64 [root@localhost ~]# ln /boot/config-3.10.0-514.el7.x86_64 /tmp/conifg.1 ln: 沒法建立硬連接"/tmp/conifg.1" => "/boot/config-3.10.0-514.el7.x86_64": 無效的跨設備鏈接