Linux下 软连接的用法 原创 Linux平台 2021年12月2日 15:47 夏至未至 1431 当前内容 1963 字,在路上,马上到,马上到 ## 目录 [TOC] ## 命令 ### 创建 ln -s 源文件/目录 目标文件/目录 ### 删除 删除目标文件或目录,并不影响源文件或目录 rm -rf 目标文件/目录 ## 文件 ### 建立文件软连接 如下为源文件 [root@node2 lib64]# ll ... -rwxr-xr-x. 1 root root 470376 8月 9 2019 libssl.so.1.0.2k ... [root@node2 lib64]# 为其建立软连接 [root@node2 lib64]# ln -s libssl.so.1.0.2k libssl.so.11 [root@node2 lib64]# ll ... -rwxr-xr-x. 1 root root 470376 8月 9 2019 libssl.so.1.0.2k lrwxrwxrwx. 1 root root 16 12月 2 15:16 libssl.so.11 -> libssl.so.1.0.2k ... [root@node2 lib64]# ### 删除文件软连接 [root@node2 lib64]# rm -rf libssl.so.11 [root@node2 lib64]# ll ... -rwxr-xr-x. 1 root root 470376 8月 9 2019 libssl.so.1.0.2k ... [root@node2 lib64]# ## 目录 ### 建立目录软连接 建立测试源目录 test1 [root@node2 xxx]# mkdir test1 [root@node2 xxx]# ll 总用量 0 drwxr-xr-x. 2 root root 6 12月 2 15:22 test1 [root@node2 xxx]# 链接到目标目录test2 [root@node2 xxx]# ln -s test1 test2 [root@node2 xxx]# ll 总用量 0 drwxr-xr-x. 2 root root 6 12月 2 15:22 test1 lrwxrwxrwx. 1 root root 5 12月 2 15:22 test2 -> test1 [root@node2 test1]# 在test1下创建文件,由于链接关系,test2下同样有该文件 [root@node2 xxx]# cd test1/ [root@node2 test1]# ll 总用量 0 [root@node2 xxx]# [root@node2 xxx]# touch hello [root@node2 xxx]# [root@node2 xxx]# ll 总用量 0 -rw-r--r--. 1 root root 0 12月 2 15:23 hello [root@node2 xxx]# [root@node2 xxx]# cd test2/ [root@node2 test2]# ll 总用量 0 -rw-r--r--. 1 root root 0 12月 2 15:23 hello [root@node2 test2]# ### 删除目录软连接 删除目标目录,不会影响源目录 [root@node2 xxx]# rm -rf test2 [root@node2 xxx]# ll 总用量 0 drwxr-xr-x. 2 root root 19 12月 2 15:23 test1 [root@node2 xxx]# [root@node2 xxx]# cd test1/ [root@node2 test1]# ll 总用量 0 -rw-r--r--. 1 root root 0 12月 2 15:23 hello [root@node2 test1]# 本文标题: Linux下 软连接的用法 本文作者: 夏至未至 发布时间: 2021年12月2日 15:47 最近更新: 2021年12月2日 15:47 原文链接: 许可协议: 署名-非商业性-禁止演绎 4.0 国际(CC BY-NC-ND 4.0) 请按协议转载并保留原文链接及作者 Linux(24) 软连接(1) 上一个 mysqlbinlog工具提取binlog日志中sql数据 下一个 CentOS8 配置静态IP 当前文章评论暂未开放,请移步至留言处留言。