http://linux.vbird.org/linux_basic/0240tarcompress.php
[root@linux ~]# tar -cvf /tmp/etc.tar /etc <==僅打包,不壓縮!
[root@linux ~]# tar -zcvf /tmp/etc.tar.gz /etc <==打包後,以 gzip 壓縮
tar -zxvf /tmp/etc.tar.gz
[root@linux ~]# tar -jcvf /tmp/etc.tar.bz2 /etc <==打包後,以 bzip2 壓縮 tar -cf - filenames | bzip2 >archivefile.tar.bz2
tar -xjf archivefile.tar.bz2
- tar xvzf file-1.0.tar.gz - for a gzip compress tar file (.tgz or .tar.gz)
- tar xvjf file-1.0.tar.bz2 - for a bzip2 compressed tar file (.tbz or .tar.bz2)
- tar xvf file-1.0.tar - for uncompressed tar file (.tar)
- x = eXtract, this indicated an extraction ( c = create to create )
- v = verbose (optional) the files with relative locations will be displayed.
- z = gzip-ped; j = bzip2-zipped
- f = from/to file ... (what is next after the f is the archive file)
List the contents
tar -tvf file.tar
tar -ztvf file.tar.gz
tar -jtvf file.tar.bz2