Linux软硬链接
1、软链接(符号链接):指向原文件文件名,通过原文件间接指向磁盘的存储空间,进行数据读取,删除原文件链接文件不可用
ln -s f1 s1 --- -s 软链接 先写原文件再写链接文件
[root@localhost ~]# ls
anaconda-ks.cfg scripts
[root@localhost ~]#
[root@localhost ~]# ln -s ./scripts/test.sh s.txt
[root@localhost ~]# ll
-rw-------. 1 root root 1564 Jul 31 2020 anaconda-ks.cfg
drwxr-xr-x 2 root root 73 Sep 22 10:57 scripts
lrwxrwxrwx 1 root root 17 Sep 23 09:07 s.txt -> ./scripts/test.sh
[root@localhost ~]#
2、硬链接 :与原文件指向同一块硬盘的存储空间,相当于一个存储空间的两个文件名,删除原文件链接文件仍可用
ln f1 h1 ---硬链接
[root@localhost ~]# ln ./scripts/test.sh h.txt
[root@localhost ~]# ll
-rw-------. 1 root root 1564 Jul 31 2020 anaconda-ks.cfg
-rwxr-xr-x 2 root root 132 Jul 14 22:22 h.txt
drwxr-xr-x 2 root root 73 Sep 22 10:57 scripts
lrwxrwxrwx 1 root root 17 Sep 23 09:07 s.txt -> ./scripts/test.sh
[root@localhost ~]#
3、相对路径:对文件位置的不完整描述,在当前路径下搜索文件
cat f1
4、绝对路径:从/开始表示文件所在位置
cat /mnt/f1
建议创建软链接尽量用绝对路径
ln -s /mnt/f1 s1