linux創建鏈接文件_Linux教程
linux下鏈接有兩種方式,硬鏈接和軟鏈接,創建鏈接也有兩種方式。.
通常我們可以用ln命令創建硬鏈接,如果你想要創建軟鏈接,你需要加-s參數。
其實我們也可以用cp命令創建鏈接文件
-l參數為aa.txt創建硬鏈接bb.txt,可以用ll -i查看文件的inode.
1234 [xiaofan@linuxboy ~]$ cp -l aa.txt bb.txt [xiaofan@linuxboy ~]$ ll -i aa.txt bb.txt 787611 -rw-rw-r--. 2 xiaofan xiaofan 0 May 28 23:20 aa.txt 787611 -rw-rw-r--. 2 xiaofan xiaofan 0 May 28 23:20 bb.txt
-s參數可以為aa.txt創建軟鏈接cc.txt.
1234 [xiaofan@linuxboy ~]$ cp -s aa.txt cc.txt [xiaofan@linuxboy ~]$ ll -i aa.txt cc.txt 787611 -rw-rw-r--. 2 xiaofan xiaofan 0 May 28 23:20 aa.txt 787607 lrwxrwxrwx. 1 xiaofan xiaofan 6 May 28 23:23 cc.txt -> aa.txt
最后,關于創建硬鏈接,你得注意兩個限制
1.不允許給目錄創建硬鏈接;
2.不能在不同掛載點之間創建硬鏈接。比如我的/sda1,/sda2分別掛在根(/)和(/home)u目錄下,你就不能給根目錄下的文件創建硬鏈接到(/home)目錄下。
相關Linux教程:
- 相關鏈接:
- 教程說明:
Linux教程-linux創建鏈接文件
。