```
[root@hf-01 ~]# ls -l /bin 这个/bin,就是一个软链接文件,真正是在/usr/bin/下
lrwxrwxrwx. 1 root root 7 8月 21 05:03 /bin -> usr/bin
[root@hf-01 ~]# /bin/ls
11.txt 123 234 2.txt 33.txt anaconda-ks.cfg.1 ha.txt hf
[root@hf-01 ~]# /usr/bin/ls 会发现和/bin/ls是一个软链接文件
11.txt 123 234 2.txt 33.txt anaconda-ks.cfg.1 ha.txt hf
```
软链接其实就是在一个文件本身存了另一个文件目录的路径。链接文件的大小适合路径是有关系的,路径越长,那这个软链接文件越大
软链接就像是windows中的快捷方式,可以很大程度的节省磁盘空间
比如要找一个文件,必须要在/tmp/123/12/1.txt,而本身这个1.txt文件放到了/root/123/这个目录下
而这个程序必须要在/tmp/12/目录下找到1.txt文件
方法一:可以拷贝一份到该目录下,但若是文件更改后,就会继续要拷贝,所以很麻烦。
方法二:给/root/123/1.txt做一个软链接
[root@hf-01 ~]# ls
11.txt 123 234 2.txt 33.txt anaconda-ks.cfg.1 ha.txt hf
[root@hf-01 ~]# cd /tmp/
[root@hf-01 tmp]# ls
aminglinux amning mysql.sock user1 yum.log yunwei
[root@hf-01 tmp]# ln -s /tmp/yum.log /root/123/yum.log
[root@hf-01 tmp]# ls -l /root/123/ 这样就形成了一个软链接文件
总用量 0
lrwxrwxrwx. 1 root root 12 10月 30 05:44 yum.log -> /tmp/yum.log
[root@hf-01 tmp]# ln -s /tmp/amning/ /root/amning111
[root@hf-01 tmp]# ls -l !$
ls -l /root/amning111
lrwxrwxrwx. 1 root root 12 10月 30 05:51 /root/amning111 -> /tmp/amning/
[root@hf-01 tmp]# ls -l
总用量 4
-rw-r--r--. 1 root root 0 10月 30 06:09 aa.log
srwxrwxrwx. 1 mysql mysql 0 10月 30 04:49 mysql.sock
drwxrwxrwx. 2 user1 user1 6 10月 27 09:07 user1
[root@hf-01 tmp]# ln -s aa.log ss.log
[root@hf-01 tmp]# ls -l
总用量 4
-rw-r--r--. 1 root root 0 10月 30 06:09 aa.log
srwxrwxrwx. 1 mysql mysql 0 10月 30 04:49 mysql.sock
lrwxrwxrwx. 1 root root 6 10月 30 06:13 ss.log -> aa.log
[root@hf-01 ~]# cd /tmp/
[root@hf-01 tmp]# ls -l
总用量 4
drwxr-xr-x. 4 user1 hanfeng 53 10月 30 06:01 aminglinux
lrwxrwxrwx. 1 root root 6 10月 30 06:13 ss.log -> aa.log
[root@hf-01 tmp]# mv ss.log aminglinux/
[root@hf-01 tmp]# cd aminglinux
[root@hf-01 aminglinux]# ls -l
总用量 0
drwxr-xr-x. 4 user1 hanfeng 31 10月 25 06:55 aming2
lrwxrwxrwx. 1 root root 6 10月 30 06:13 ss.log -> aa.log
这里会发现aa.log在飘红闪烁,这是因为这个文件不存在
[root@hf-01 ~]# df -h 查看磁盘分区情况
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 18G 2.4G 16G 14% /
devtmpfs 489M 0 489M 0% /dev
tmpfs 494M 0 494M 0% /dev/shm
tmpfs 494M 6.7M 487M 2% /run
tmpfs 494M 0 494M 0% /sys/fs/cgroup
/dev/sda1 197M 75M 123M 38% /boot