— 5 root root 4096 Apr 29 22:10 ./
drwxr-xr-x 20 root root 4096 Apr 29 22:10 ../
-rw——- 1 root root 3904 Apr 29 22:10 .bash_history
-rw-r–r– 1 root root 3108 Jul 23 2020 .bashrc
drwx—— 2 root root 4096 Jun 17 2020 .cache/
-rw-r–r– 1 root root 0 Aug 12 2020 .cloud-warnings.skip
drwxr-xr-x 2 root root 4096 Apr 21 14:14 .pip/
-rw-r–r– 1 root root 160 Aug 6 2020 .profile
-rw-r–r– 1 root root 73 Apr 21 14:14 .pydistutils.cfg
lrwxrwxrwx 1 root root 8 Apr 29 22:10 sl_file -> src_file
-rw-r–r– 1 root root 0 Apr 29 22:10 src_file
drwx—— 2 root root 4096 Jun 17 2020 .ssh/
-rw——- 1 root root 11199 Apr 29 15:57 .viminfo

1
2
3
4
5

我们会发现目录下存在`sl_file->src_file`。这就是软链接

创建文件软链接:

ln src_file hl_file

1

root@VM-12-10-ubuntu:# ln src_file hl_file
root@VM-12-10-ubuntu:
# ls
hl_file sl_file src_file
root@VM-12-10-ubuntu:~# ll
total 48
drwx—— 5 root root 4096 Apr 29 22:11 ./
drwxr-xr-x 20 root root 4096 Apr 29 22:11 ../
-rw——- 1 root root 3966 Apr 29 22:11 .bash_history
-rw-r–r– 1 root root 3108 Jul 23 2020 .bashrc
drwx—— 2 root root 4096 Jun 17 2020 .cache/
-rw-r–r– 1 root root 0 Aug 12 2020 .cloud-warnings.skip
-rw-r–r– 2 root root 0 Apr 29 22:10 hl_file
drwxr-xr-x 2 root root 4096 Apr 21 14:14 .pip/
-rw-r–r– 1 root root 160 Aug 6 2020 .profile
-rw-r–r– 1 root root 73 Apr 21 14:14 .pydistutils.cfg
lrwxrwxrwx 1 root root 8 Apr 29 22:10 sl_file -> src_file
-rw-r–r– 2 root root 0 Apr 29 22:10 src_file
drwx—— 2 root root 4096 Jun 17 2020 .ssh/
-rw——- 1 root root 11199 Apr 29 15:57 .viminfo


我们在目录下只会发现存在`hl_file`

我们发现软链接比硬链接多了一个箭头指向原始文件。

使用`ll -i`命令,如下

![](https://lautung-1256670757.cos.ap-guangzhou.myqcloud.com/image_1619705830441.png#alt=image.png)

图中数字`33`等是文件的inode ID。

什么是inode呢?

我们知道文件名,它是由字符串构成的,目的是为了方便人类识别和理解。

而Inode的全称是index node,也就是索引节点。主要是为了很快的检索到文件的内容。

![](https://lautung-1256670757.cos.ap-guangzhou.myqcloud.com/image_1619706202660.png#alt=image.png)