压缩与解压
[root@localhost hzw]# ls
hello
[root@localhost hzw]# gzip hello
[root@localhost hzw]# ls
hello.gz
[root@localhost hzw]# file hello.gz
hello.gz: gzip compressed data, was "hello", from Unix, last modified: Thu Sep 12 23:57:34 2019
[root@localhost hzw]# gzip -d hello.gz
[root@localhost hzw]# ls
hello
[root@localhost hzw]# bzip2 hello
[root@localhost hzw]# ls
hello.bz2
[root@localhost hzw]# file hello.bz2
hello.bz2: bzip2 compressed data, block size = 900k
### bizp2
[root@localhost hzw]# bzip2 -d hello.bz2
[root@localhost hzw]# ls
hello
[root@localhost hzw]# bzip2 hello
[root@localhost hzw]# bzip2 -kd hello.bz2
[root@localhost hzw]# ls
hello hello.bz2
[root@localhost hzw]# xz hello
[root@localhost hzw]# ls
hello.xz
[root@localhost hzw]# xz -d hello.xz
[root@localhost hzw]# ls
hello
[root@localhost hzw]# xz hello
[root@localhost hzw]# ls
hello.xz
[root@localhost hzw]# xz -kd hello.xz
[root@localhost hzw]# ls
hello hello.xz
[root@localhost hzw]# zip hello.zip hello
adding: hello (stored 0%)
[root@localhost hzw]# ls
hello hello.zip
[root@localhost ~]# ls
anaconda-ks.cfg
[root@localhost ~]# touch hello
[root@localhost ~]# ls
anaconda-ks.cfg hello
[root@localhost ~]# zip 123.zip ./*
adding: anaconda-ks.cfg (deflated 36%)
adding: hello (stored 0%)
[root@localhost ~]# ls
123.zip anaconda-ks.cfg hello
[root@localhost ~]# mkdir a
[root@localhost ~]# ls
123.zip a anaconda-ks.cfg hello
[root@localhost ~]# mv 123.zip a
[root@localhost ~]# cd a
[root@localhost a]# unzip 123.zip
Archive: 123.zip
inflating: anaconda-ks.cfg
extracting: hello
[root@localhost a]# ls
123.zip anaconda-ks.cfg hello
-c:创建归档文件
-f file.tar:指定要操作的归档文件
-x:还原归档
-v:显示归档过程
-p:归档时保留权限信息。只有管理员才有权限用此选项
-C:指定还原归档或解压时的目标目录
[root@localhost tmp]# tar tf runtime2.tar.bz2
world/
[root@localhost tmp]# mkdir hello
[root@localhost tmp]# ls
hello ks-script-Wut_Pw yum.log
[root@localhost tmp]# tar cf runtime.tar hello
(创建归档文件runtime 并将目录hello存入runtime)
[root@localhost tmp]# file runtime.tar
runtime.tar: POSIX tar archive (GNU)
[root@localhost tmp]# mv hello world
(将tmp目录下的hello更名为world)
[root@localhost tmp]# ls
ks-script-Wut_Pw runtime.tar world yum.log
[root@localhost tmp]# tar xf runtime.tar (还原归档文件runtime)
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime.tar world yum.log
(有hello和world说明runtime里的hello被成功还原)
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# rm -rf world
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar yum.log
[root@localhost tmp]# tar xf runtime2.tar.bz2
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# tar xf runtime2.tar.bz2 -C /tmp/hello/
[root@localhost tmp]# ls hello
world
[root@localhost tmp]# tar zcf runtime1.tar.gz world
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime.tar world yum.log
[root@localhost tmp]# file runtime1.tar.gz
runtime1.tar.gz: gzip compressed data, from Unix, last modified: Fri Sep 13 03:11:50 2019
[root@localhost tmp]# tar jcf runtime2.tar.bz2 world
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime.tar world yum.log
[root@localhost tmp]# file runtime2.tar.bz2
runtime2.tar.bz2: bzip2 compressed data, block size = 900k
[root@localhost tmp]# tar Jcf runtime3.tar.xz world
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# file runtime3.tar.xz
runtime3.tar.xz: XZ compressed data
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# rm -rf world
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar yum.log
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# rm -rf world/
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar yum.log
[root@localhost tmp]# tar jxf runtime2.tar.bz2
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log
[root@localhost tmp]# rm -rf world
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar yum.log
[root@localhost tmp]# tar Jxf runtime3.tar.xz
[root@localhost tmp]# ls
hello ks-script-Wut_Pw runtime1.tar.gz runtime2.tar.bz2 runtime3.tar.xz runtime.tar world yum.log