#链接文件 硬链接: ln SRC LINKFILE ①硬链接不能跨分区
[root@VM_168_102_centos tmp]# mount
/dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/xvdb1 on /tmp/xvdb1 type ext4 (rw)
/dev/xvdb2 on /tmp/xvdb2 type ext4 (rw)
[root@VM_168_102_centos tmp]# ln /tmp/xvdb1/test /tmp/xvdb2/newtest
ln: creating hard link `/tmp/xvdb2/newtest' => `/tmp/xvdb1/test': Invalid cross-device link
②不能对目录创建硬链接
[root@VM_168_102_centos tmp]# ln /tmp/wanghan /tmp/new_wanghan
ln: `/tmp/wanghan': hard link not allowed for directory
③硬链接会改变文件被链接的次数
[root@VM_168_102_centos tmp]# ls -l t*
-rw-r--r-- 1 root root 153 Aug 22 11:48 test.sh
[root@VM_168_102_centos tmp]# ln /tmp/test.sh /tmp/new_test.sh
[root@VM_168_102_centos tmp]# ls -l t*
-rw-r--r-- 2 root root 153 Aug 22 11:48 test.sh
④硬链接与原文件指向同一个inode
[root@VM_168_102_centos tmp]# ls -li
458763 -rw-r--r-- 2 root root 153 Aug 22 11:48 new_test.sh
458763 -rw-r--r-- 2 root root 153 Aug 22 11:48 test.sh
#软链接又称符号链接:ln –s SCR LINKFILE ①符号链接可以跨分区
[root@VM_168_102_centos tmp]# mount
/dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/xvdb1 on /tmp/xvdb1 type ext4 (rw)
/dev/xvdb2 on /tmp/xvdb2 type ext4 (rw)
[root@VM_168_102_centos tmp]# ln -s /tmp/xvdb1/test /tmp/xvdb2/new_test
[root@VM_168_102_centos tmp]# ls -l /tmp/xvdb2
total 16
drwx------ 2 root root 16384 Aug 22 16:37 lost+found
lrwxrwxrwx 1 root root 15 Aug 22 16:55 new_test -> /tmp/xvdb1/test
[root@VM_168_102_centos ~]# tar -cf yum.conf.tar yum.conf
[root@VM_168_102_centos ~]# ls -l
total 16
-rw-r--r-- 1 root root 969 Aug 22 17:21 yum.conf
-rw-r--r-- 1 root root 10240 Aug 22 17:45 yum.conf.tar
-x:展开归档
[root@VM_168_102_centos ~]# ls
yum.conf.tar
[root@VM_168_102_centos ~]# tar -xf yum.conf.tar
[root@VM_168_102_centos ~]# ls
yum.conf yum.conf.tar
-t:不展开直接查看被归档文件
[root@VM_168_102_centos ~]# tar -tf yum.conf.tar
yum.conf
压缩文件并进行归档: 调用gzip工具 -z:gzip 压缩归档
[root@VM_168_102_centos ~]# tar -zcf yum.conf.gz.tar yum.conf
[root@VM_168_102_centos ~]# ls -l
total 8
-rw-r--r-- 1 root root 969 Aug 22 17:21 yum.conf
-rw-r--r-- 1 root root 708 Aug 22 17:53 yum.conf.gz.tar
解压归档
[root@VM_168_102_centos ~]# ls
yum.conf.gz.tar
[root@VM_168_102_centos ~]# tar -zxf yum.conf.gz.tar
[root@VM_168_102_centos ~]# ls
yum.conf yum.conf.gz.tar
调用bzip2工具 -j:bzip2 压缩归档
[root@VM_168_102_centos ~]# tar -jcf yum.conf.bz2.tar yum.conf
[root@VM_168_102_centos ~]# ls
yum.conf yum.conf.bz2.tar
解压归档
[root@VM_168_102_centos ~]# ls
yum.conf.bz2.tar
[root@VM_168_102_centos ~]# tar -jxf yum.conf.bz2.tar
[root@VM_168_102_centos ~]# ls
yum.conf yum.conf.bz2.tar
调用xz工具 -J:xz 压缩归档
[root@VM_168_102_centos ~]# tar -Jcf yum.conf.xz.tar yum.conf
[root@VM_168_102_centos ~]# ls
yum.conf yum.conf.xz.tar
解压归档
[root@VM_168_102_centos ~]# tar -Jcf yum.conf.xz.tar yum.conf
[root@VM_168_102_centos ~]# ls
yum.conf yum.conf.xz.tar
三种压缩归档
-rw-r--r-- 1 root root 969 Aug 22 17:21 yum.conf
-rw-r--r-- 1 root root 744 Aug 22 18:02 yum.conf.bz2
-rw-r--r-- 1 root root 708 Aug 22 18:02 yum.conf.gz.tar
-rw-r--r-- 1 root root 792 Aug 22 18:01 yum.conf.xz.tar