方法一:
[root@localhost switch]# tar -zcvf conf.tar.gz *
[root@localhost switch]# tar -zxvf conf.tar.gz
方法二:
[root@localhost switch]# tar -cvf conf.tar *
[root@localhost switch]# gzip conf.tar
[root@localhost switch]# ls -l *gz
-rw-r--r-- 1 root root 109619 3月 10 20:58 conf.tar.gz
[root@localhost switch]# gunzip conf.tar.gz
[root@localhost switch]# ls
conf.tar
[root@localhost switch]# tar -xvf conf.tar
tar.zip文件压缩与解压
方法一:
[root@localhost switch]# zip conf.tar.zip *.conf
[root@localhost switch]# ls -l *.zip
-rw-r--r-- 1 root root 117183 3月 10 21:00 conf.tar.zip
[root@localhost switch]# unzip conf.tar.zip
方法二:
[root@localhost switch]# tar -cvf conf.tar *
[root@localhost switch]# zip conf.tar.zip conf.tar
adding: conf.tar (deflated 75%)
[root@localhost switch]# ls -l
-rw-r--r-- 1 root root 109655 3月 10 21:14 conf.tar.zip
[root@localhost switch]# unzip conf.tar.zip
Archive: conf.tar.zip
inflating: conf.tar
[root@localhost switch]# ls
conf.tar conf.tar.zip
[root@localhost switch]# tar -xvf conf.tar
tar.bz2文件压缩与解压
方法一:
[root@localhost switch]# tar -cvf conf.tar *
[root@localhost switch]# bzip2 conf.tar
-rw-r--r-- 1 root root 62611 3月 10 21:03 conf.tar.bz2
[root@localhost switch]# bunzip2 conf.tar.bz2
[root@localhost switch]# ls
conf.tar
[root@localhost switch]# tar -xvf conf.tar
方法二:
[root@localhost switch]# tar -cjf conf.tar.bz2 *
[root@localhost switch]# ls -l *.bz2
-rw-r--r-- 1 root root 62611 3月 10 21:05 conf.tar.bz2
[root@localhost switch]# tar -xjf conf.tar.bz2
tar.z文件压缩与解压
[root@localhost switch]# tar -czf conf.tar.z *.conf
[root@localhost switch]# ls -l *.z
-rw-r--r-- 1 root root 109525 3月 10 21:18 conf.tar.z
[root@localhost switch]# tar -xzf conf.tar.z
tar.tar文件压缩与解压
[root@localhost switch]# tar -zcvf conf.tar.tar *.conf
[root@localhost switch]# ls -l
-rw-r--r-- 1 root root 109525 3月 10 21:25 conf.tar.tar
[root@localhost switch]# mv conf.tar.tar conf.tar.gz
[root@localhost switch]# ls
conf.tar.gz
[root@localhost switch]# gunzip conf.tar.gz
[root@localhost switch]# ls
conf.tar
[root@localhost switch]# tar -xvf conf.tar