
.tar
Extract: tar xvf FileName.tar
Create/Package: tar cvf FileName.tar DirName
(Note: tar packages files, it does not compress!)
———————————————
.gz
Extract 1: gunzip FileName.gz
Extract 2: gzip -d FileName.gz
Compress: gzip FileName
.tar.gz and .tgz
Extract: tar zxvf FileName.tar.gz
Compress: tar zcvf FileName.tar.gz DirName
———————————————
.bz2
Extract 1: bzip2 -d FileName.bz2
Extract 2: bunzip2 FileName.bz2
Compress: bzip2 -z FileName
.tar.bz2
Extract: tar jxvf FileName.tar.bz2 or tar –bzip xvf FileName.tar.bz2
Compress: tar jcvf FileName.tar.bz2 DirName
———————————————
.bz
Extract 1: bzip2 -d FileName.bz
Extract 2: bunzip2 FileName.bz
Compress: unknown
.tar.bz
Extract: tar jxvf FileName.tar.bz
Compress: unknown
———————————————
.Z
Extract: uncompress FileName.Z
Compress: compress FileName
.tar.Z
Extract: tar Zxvf FileName.tar.Z
Compress: tar Zcvf FileName.tar.Z DirName
———————————————
.zip
Extract: unzip FileName.zip
Compress: zip FileName.zip DirName
Use -r parameter when compressing a directory, -r for recursive. Example: $ zip -r FileName.zip DirName
———————————————
.rar
Extract: rar x FileName.rar
Compress: rar a FileName.rar DirName
For rar, please download from: http://www.rarsoft.com/download.htm!
After extraction, copy rar_static to the /usr/bin directory (or any other directory in the $PATH environment variable):
[root@www2 tmp]# cp rar_static /usr/bin/rar
———————————————
.lha
Extract: lha -e FileName.lha
Compress: lha -a FileName.lha FileName
For lha, please download from: http://www.infor.kanazawa-it.ac.jp/~ishii/lhaunix/!
>After extraction, copy lha to the /usr/bin directory (or any other directory in the $PATH environment variable):
[root@www2 tmp]# cp lha /usr/bin/
———————————————
.rpm
Extract: rpm2cpio FileName.rpm | cpio -div
———————————————
.deb
Extract: ar p FileName.deb data.tar.gz | tar zxf –
———————————————
.tar .tgz .tar.gz .tar.Z .tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh .lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea
Extract: sEx x FileName.*
Compress: sEx a FileName.* FileName
Note: sEx only calls the relevant programs; it does not have any compression/extraction capability itself!
For sEx, please download from: http://sourceforge.net/projects/sex!
After extraction, copy sEx to the /usr/bin directory (or any other directory in the $PATH environment variable):
[root@www2 tmp]# cp sEx /usr/bin/ Common File Extraction Methods and Commands Under Linux
System · System
1. Files with .a extension:
#tar xv file.a
2. Files with .z extension:
#uncompress file.Z
3. Files with .gz extension:
#gunzip file.gz
4. Files with .bz2 extension:
#bunzip2 file.bz2
5. Files with .tar.Z extension:
#tar xvZf file.tar.Z
or #compress -dc file.tar.Z | tar xvf
6. Files with .tar.gz/.tgz extension:
#tar xvzf file.tar.gz
or gzip -dc file.tar.gz | tar xvf –
7. Files with .tar.bz2 extension:
#tar xvIf file.tar.bz2
or bzip2 -dc file.tar.bz2 | xvf –
8. Files with .cpio.gz/.cgz extension:
#gzip -dc file.cgz | cpio -div
9. Files with .cpio/cpio extension:
#cpio -div file.cpio
or cpio -divc file.cpio
10. Installing .rpm files:
#rpm -i file.rpm
11. Extracting .rpm files:
#rpm2cpio file.rpm | cpio -div
12. Installing .deb files:
#dpkg -i file.deb
13. Extracting .deb files:
#dpkg-deb -fsys-tarfile file.deb | tar xvf – ar p
file.deb data.tar.gz | tar xvzf –
14. Files with .zip extension:
#unzip file.zip
Extracting Winzip-format files under Linux
If you have jdk installed, you can use the jar command; you can also use the unzip command.
Directly extracting .tar.gz files
xxxx.tar.gz files can be extracted in one step using tar with the zxvf parameters, where XXXX is the filename. Example:
$tar zxvf xxxx.tar.gz Extracting (Installation Methods) for Various Compressed Files
File Extension Extraction (Installation Method)
.a ar xv file.a
.Z uncompress file.Z
.gz gunzip file.gz
.bz2 bunzip2 file.bz2
.tar.Z tar xvZf file.tar.Z
compress -dc file.tar.Z | tar xvf –
.tar.gz/.tgz tar xvzf file.tar.gz
gzip -dc file.tar.gz | tar xvf –
.tar.bz2 tar xvIf file.tar.bz2
bzip2 -dc file.tar.bz2 | xvf –
.cpio.gz/.cgz gzip -dc file.cgz | cpio -div
.cpio/cpio cpio -div file.cpio
cpio -divc file.cpio
.rpm/install rpm -i file.rpm
.rpm/extract rpm2cpio file.rpm | cpio -div
.deb/install dpkg -i file.deb
.deb/extract dpkg-deb -fsys-tarfile file.deb | tar xvf –
ar p file.deb data.tar.gz | tar xvzf –
.zip unzip file.zip
bzip2 -d myfile.tar.bz2 | tar xvf
tar xvfz myfile.tar.bz2
x means extract
v means verbose output
f means specify file
z means gz format
gzip
gzip [options] filename-to-compress (or-decompress)
-c Output to stdout and keep the original file.
-d Decompress the compressed file.
-l For each compressed file, display: compressed size, uncompressed size, compression ratio, uncompressed filename.
-r Recursively find and compress (or decompress) all files in the specified directory.
-t Test the integrity of the compressed file.
-v For each file compressed or decompressed, display the filename and compression ratio.
-num- Adjust compression speed with the specified number.
Examples:
Back up all files under /usr including its subdirectories, backup file named usr.tar
tar cvf usr.tar /home
Back up all files under /usr including its subdirectories and compress, backup file named usr.tar.gz
tar czvf usr.tar.gz /usr
Compress a set of files with .tar.gz extension
#tar cvf back.tar /back/
#gzip -q back.tar
or
#tar cvfz back.tar.gz /back/
Extract a file with .tar.gz extension.
#tar zxvf back.tar.gz
#gzip back.tar.gz
#tar xvf back.tar