Linux软硬连接

  曾经对软硬连接一直搞不明白,关键是怕操作错误。

硬链接不能跨区实现连接,硬链接是对原始文件的镜像,同一个inode,软连接是快捷方式,inode保存的是快捷方式的。原始文件删除,导致软连接文件无效。

01、硬链接

 02、软连接

对目录的链接

[root@dzswj-test tmp]#ll
total 16
drwxr-xr-x 3 root  root  4096 Jul 12 14:44 gitdev
drwxr-xr-x 2 resin resin 4096 Aug 10 10:59 hsperfdata_resin
drwx------ 2 gdm   gdm   4096 Oct  4 14:41 orbit-gdm
drwx------ 2 gdm   gdm   4096 Oct  4 14:42 pulse-D9BRMMarTPJX
[root@dzswj-test tmp]#
[root@dzswj-test tmp]#
[root@dzswj-test tmp]#ln -sv /usr/local/bin  .    //软连接,方原始路径需写绝对路径
`./bin' -> `/usr/local/bin'
[root@dzswj-test tmp]#ll
total 16
lrwxrwxrwx 1 root  root    14 Oct  4 18:15 bin -> /usr/local/bin   //清晰看到链接指向
drwxr-xr-x 3 root  root  4096 Jul 12 14:44 gitdev
drwxr-xr-x 2 resin resin 4096 Aug 10 10:59 hsperfdata_resin
drwx------ 2 gdm   gdm   4096 Oct  4 14:41 orbit-gdm
drwx------ 2 gdm   gdm   4096 Oct  4 14:42 pulse-D9BRMMarTPJX
[root@dzswj-test tmp]#ll bin/  bin目录下的文件
total 29048
-rwxr-xr-x. 1 root root  266821 Apr 15  2016 memcached
-rwxr-xr-x  1 root root 1234088 Aug 15  2016 rar
-rwxr-xr-x  1 root root 5587865 May 16  2016 redis-benchmark
-rwxr-xr-x  1 root root   22185 May 16  2016 redis-check-aof
-rwxr-xr-x  1 root root 7823836 May 16  2016 redis-check-rdb
-rwxr-xr-x  1 root root 5714129 May 16  2016 redis-cli
lrwxrwxrwx  1 root root      12 May 16  2016 redis-sentinel -> redis-server
-rwxr-xr-x  1 root root 7823836 May 16  2016 redis-server
-rwxr-xr-x  1 root root    8807 May 26  2016 tclsh8.5
-rwxr-xr-x  1 root root 1234088 Aug 15  2016 unrar
posted @ 2018-10-04 18:23  mvpbang  阅读(689)  评论(0编辑  收藏  举报