- 软硬连接命令比较
1 create a hard link,
ln file link
2 create a symbolic link where “item” is either a file or a directory
ln -s item link
- 硬链接例子
/var/root/document # ls -liF |
total 4 |
276 drwxr-xr-x 2 root root 40 Nov 27 22:49 dir1/ |
277 drwxr-xr-x 2 root root 40 Nov 27 22:49 dir2/ |
275 -rw-r--r-- 1 root root 4 Nov 27 22:49 fun.txt |
/var/root/document # ln fun fun-hard |
/var/root/document # ln fun dir1/fun-hard |
/var/root/document # ln fun dir2/fun-hard |
/var/root/document # ls -li |
total 8 |
276 drwxr-xr-x 2 root root 60 Nov 27 22:51 dir1 |
277 drwxr-xr-x 2 root root 60 Nov 27 22:52 dir2 |
275 -rw-r--r-- 4 root root 4 Nov 27 22:49 fun |
275 -rw-r--r-- 4 root root 4 Nov 27 22:49 fun-hard |
/var/root/document # ls -li dir1/ dir2/ |
dir1/: |
total 4 |
275 -rw-r--r-- 4 root root 4 Nov 27 22:49 fun-hard |
dir2/: |
total 4 |
275 -rw-r--r-- 4 root root 4 Nov 27 22:49 fun-hard |
- 软连接例子
- 软硬连接显示比较
硬链接与普通文件无区别
软连接带符号指向源文件
- 实质
1软连接相当于win OS的快捷方式
2硬链接相当于文件内容一样但是inode各不相同
而且改一个硬链接文件所有硬链接文件都同时更新.
When we create hard links, we are actually creating additional name parts that all
refer to the same data part. The system assigns a chain of disk blocks to what is called an
inode, which is then associated with the name part. Each hard link therefore refers to a
specific inode containing the file's contents.
3 是硬链接数目
第一列是inode,硬连接的文件inode相同
- 参考资料:
The Linux® Command Line
William E. Shotts, Jr.
A LinuxCommand.
P43--44