[root@localhost ~]# ln 1.txt 1_heard.txt
[root@localhost ~]# ln -s 1.txt 1_sorft.txt
[root@localhost ~]# ls -l
总用量 32
drwxr-xr-x. 3 root root 45 10月 26 16:11 111
-rw-r--r--. 1 root root 0 10月 26 15:54 111.12.txt
-rw-r--r--. 2 root root 391 10月 30 15:10 1_heard.txt
lrwxrwxrwx. 1 root root 5 10月 30 15:06 1_sorft.txt -> 1.txt
[root@localhost ~]# ls -i
33584735 111 33575033 1_sorft.txt 33575034 2.txt 33574987 anaconda-ks.cfg
33584737 111.12.txt 33575035 1.txt 33584734 3.txt 33575006 anaconda-ks.cfg.1
33575035 1_heard.txt 33584733 1.txt~ 33584736 3.txt~ 33575036 windows.txt
[root@localhost ~]# rm 1.txt
rm:是否删除普通文件 "1.txt"?y
[root@localhost ~]# ls -l
总用量 28
drwxr-xr-x. 3 root root 45 10月 26 16:11 111
-rw-r--r--. 1 root root 0 10月 26 15:54 111.12.txt
-rw-r--r--. 1 root root 391 10月 30 15:10 1_heard.txt
lrwxrwxrwx. 1 root root 5 10月 30 15:06 1_sorft.txt -> 1.txt
[root@localhost ~]# ls -i 1_heard.txt
33575035 1_heard.txt
目录不能做硬链接
不能跨文件系统(跨分区),因为不同的文件系统有不同的inode,不同的table目录体系。
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 18G 1.1G 17G 6% /
devtmpfs 483M 0 483M 0% /dev
tmpfs 493M 0 493M 0% /dev/shm
tmpfs 493M 6.7M 486M 2% /run
tmpfs 493M 0 493M 0% /sys/fs/cgroup
/dev/sda1 197M 109M 88M 56% /boot
tmpfs 99M 0 99M 0% /run/user/0
[root@localhost ~]# ls -i /boot/
71 config-3.10.0-514.el7.x86_64
67 grub
131136 grub2
76 initramfs-0-rescue-513f8b3950084e768a99df3a6cd3d9e6.img
75 initramfs-3.10.0-514.el7.x86_64.img
189445 initramfs-3.10.0-514.el7.x86_64kdump.img
74 initrd-plymouth.img
72 symvers-3.10.0-514.el7.x86_64.gz
70 System.map-3.10.0-514.el7.x86_64
77 vmlinuz-0-rescue-513f8b3950084e768a99df3a6cd3d9e6
73 vmlinuz-3.10.0-514.el7.x86_64
[root@localhost ~]# ln /boot/config-3.10.0-514.el7.x86_64 /tmp/conifg.1
ln: 无法创建硬链接"/tmp/conifg.1" => "/boot/config-3.10.0-514.el7.x86_64": 无效的跨设备连接