Linux 打包/压缩/解压命令集合

package / compress and decompress

4.5.1. tar — The GNU version of the tar archiving utility
tar examples

tar

tar -cvf foo.tar foo/
       tar contents of folder foo in foo.tar

tar -xvf foo.tar
       extract foo.tar
			
gunzip
tar -zcvf foo.tar foo/
       tar contents of folder foo in foo.tar.gz
			
tar -xvzf foo.tar.gz
       extract gzipped foo.tar.gz
			
b2zip

b2zip

tar -jcvf foo.tar.bz2 foo/
       tar contents of folder foo in foo.tar.bz2

tar -jxvf foo.tar.bz2
       extract b2zip foo.tar.bz2
			
compress

compress/uncompress

tar -Zcvf foo.tar.Z foo/
       tar contents of folder foo in foo.tar.Z

tar -Zxvf foo.tar.Z
       extract compress foo.tar.Z
      		
.xz 文件
			
tar -Jxf file.pkg.tar.xz
			
			
-t, --list

-t, --list list the contents of an archive

列出tar包中的文件

tar tvf neo.tar.gz
			
# mkdir -p /www/test.com/www.test.com/
# echo helloworld > /www/test.com/www.test.com/test.txt
# tar zcvf www.test.com.tar.gz /www/test.com/www.test.com/

# tar ztvf www.test.com.tar.gz
drwxr-xr-x root/root         0 2013-08-08 15:24 www/test.com/www.test.com/
-rw-r--r-- root/root        11 2013-08-08 15:24 www/test.com/www.test.com/test.txt

# tar zxvf www.test.com.tar.gz
www/test.com/www.test.com/
www/test.com/www.test.com/test.txt

# find www
www
www/test.com
www/test.com/www.test.com
www/test.com/www.test.com/test.txt
			
tar: Removing leading `/’ from member names

-P, --absolute-names don't strip leading `/'s from file names

$ tar -czvPf neo.tar.gz /home/neo/
$ tar -xzvPf 

你可能感兴趣的:(运维手札,linux,windows,网络)