一、作用

用来在文件之间建立链接

二、选项

  • -s 创建软链接
  • -b 删除,覆盖以前建立的链接
  • -f 强制执行

    三、实例

    1. [root@localhost ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
    1. [root@localhost ~]# mkdir /dir
    2. [root@localhost ~]# touch /dir/file.txt
    3. [root@localhost ~]# ls
    4. 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
    5. [root@localhost ~]# mkdir /file
    6. [root@localhost ~]# ln /dir/file.txt /file/
    7. [root@localhost ~]# ln -s c.doc /file/
    8. [root@localhost /]# cd /file/
    9. [root@localhost file]# ll
    10. 总用量 0
    11. lrwxrwxrwx 1 root root 5 6 17 13:36 c.doc -> c.doc
    12. -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