``` [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 ```
在/lib64/目录中软连接文件最多 [root@hf-01 ~]# ls -l /lib64/
软连接就像是windows中的快捷方式,能够很大程度的节省磁盘空间node
好比要找一个文件,必需要在/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