一、作用
用来在文件之间建立链接
二、选项
- -s 创建软链接
- -b 删除,覆盖以前建立的链接
- -f 强制执行
三、实例
[root@localhost ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[root@localhost ~]# mkdir /dir
[root@localhost ~]# touch /dir/file.txt
[root@localhost ~]# ls
16.sh 17.sh 18.sh 19.sh 20.sh a.doc anaconda-ks.cfg auto auto.tar.gz b.doc c.doc info.sh init.sh mysqld.service user.doc work.zip
[root@localhost ~]# mkdir /file
[root@localhost ~]# ln /dir/file.txt /file/
[root@localhost ~]# ln -s c.doc /file/
[root@localhost /]# cd /file/
[root@localhost file]# ll
总用量 0
lrwxrwxrwx 1 root root 5 6月 17 13:36 c.doc -> c.doc
-rw-r--r-- 2 root root 0 6月 17 13:34 file.txt
```shell
[root@localhost dir]# ln -sb 1.txt dsads
[root@localhost dir]# ll
总用量 0
-rw-r—r— 2 root root 0 6月 17 13:43 1.txt
lrwxrwxrwx 1 root root 5 6月 17 13:46 dsads -> 1.txt
-rw-r—r— 2 root root 0 6月 17 13:43 dsads~
lrwxrwxrwx 1 root root 5 6月 17 13:46 ml -> 1.txt
```shell
[root@localhost dir]# ln -sbf 1.txt dsads
[root@localhost dir]# ll
总用量 0
-rw-r--r-- 1 root root 0 6月 17 13:43 1.txt
lrwxrwxrwx 1 root root 5 6月 17 13:47 dsads -> 1.txt
lrwxrwxrwx 1 root root 5 6月 17 13:46 dsads~ -> 1.txt
lrwxrwxrwx 1 root root 5 6月 17 13:46 ml -> 1.txt