軟連接(符號連接):node
一、能夠在不一樣的文件系統中進行,至關於快捷方式vim
二、刪除源文件後,快捷方式將不能連接到源文件ide
[root@localhost ~]# cd /tmpthis
[root@localhost tmp]# du -sb;df -i #du -sb是計算整個/tmp目錄下有多少 bytes的容量spa
5329.it
[root@localhost tmp]# cdclass
[root@localhost ~]# touch rljfile
[root@localhost ~]# ln -s /root/rlj /tmp/rlj.lnk硬件
[root@localhost ~]# cd /tmpim
[root@localhost tmp]# du -sb;df -i #軟連接會佔用inode數
5338.
[root@localhost tmp]# ll /root/rlj ./rlj.lnk
lrwxrwxrwx. 1 root root 9 Oct 6 16:37 ./rlj.lnk -> /root/rlj
-rw-r--r--. 1 root root 0 Oct 6 16:37 /root/rlj
[root@localhost tmp]# cd
[root@localhost ~]# ln -s rlj /etc/rlj.lnk #此處rlj應該跟絕對路徑,不然連接的文件將出現閃爍的狀態
[root@localhost ~]# ll rlj /etc/rlj.lnk
lrwxrwxrwx. 1 root root 3 Oct 6 16:40 /etc/rlj.lnk -> rlj
-rw-r--r--. 1 root root 0 Oct 6 16:37 rlj
[root@localhost ~]# echo "this is a rlj file" >> rlj
[root@localhost ~]# cat rlj
this is a rlj file
[root@localhost ~]# rm -f rlj
[root@localhost ~]# ll rlj
ls: cannot access rlj: No such file or directory
[root@localhost ~]# vim /tmp/rlj.lnk #可看出源檔案被刪除後又從新創建了此檔案
~
~
"rlj.lnk" [New File]
[root@localhost ~]# mkdir rlj
[root@localhost ~]# ln -s /root/rlj /var/ #爲目錄創建軟連接
[root@localhost ~]# ll /var/rlj
lrwxrwxrwx. 1 root root 9 Oct 6 16:43 /var/rlj -> /root/rlj
[root@localhost ~]# rm -fr rlj
[root@localhost ~]# ll /var/rlj
lrwxrwxrwx. 1 root root 9 Oct 6 16:43 /var/rlj -> /root/rlj
硬連接:
一、不能對目錄進行硬件連接
二、不能跨越不一樣的文件系統
[root@localhost ~]# touch ylj
[root@localhost ~]# vim ylj
[root@localhost ~]# ln ylj /tmp
[root@localhost ~]# ln ylj /
[root@localhost ~]# cd /tmp
[root@localhost tmp]# ll -hi ylj /root/ylj /ylj #以人類可讀性方式顯示並給出鏈接的檔案數,還能夠看出它們的inode數相同均爲204670563
204670563 -rw-r--r--. 3 root root 19 Oct 6 15:55 /root/ylj
204670563 -rw-r--r--. 3 root root 19 Oct 6 15:55 ylj
204670563 -rw-r--r--. 3 root root 19 Oct 6 15:55 /ylj
[root@localhost tmp]# vim ylj
[root@localhost tmp]# cat /root/ylj
this is a ylj file
ylj don't support directory.
[root@localhost tmp]# cat /ylj
this is a ylj file
ylj don't support directory.
[root@localhost tmp]# rm -f ylj
[root@localhost tmp]# ll -hi /ylj /root/ylj
204670563 -rw-r--r--. 2 root root 48 Oct 6 15:57 /root/ylj
204670563 -rw-r--r--. 2 root root 48 Oct 6 15:57 /ylj
[root@localhost tmp]# mkdir yl
[root@localhost tmp]# ln yl / #硬連接對目錄不生效
ln: ‘yl’: hard link not allowed for directory