Friday 4 May 2012

Simple Backup & Compression in Linux


Compression reduces file to a fraction of its original size so the file can more efficiently store or transmit.

gzip -c test.txt > test.txt.gz #compress
gunzip test.txt.gz                #decompress
zcat test.txt.gz                    #view
less test.txt.gz                     #view pagewise

bzi2 -c test.txt > test.txt.bz2 #compress
bunzip2 test.txt.bz2              #decompress
bzcat test.txt.bz2                  #view
less test.txt.bz2                     #view pagewise

zip test.txt.zip test.txt #compress
unzip test.txt             #decompress

Backup 

#backup
tar -cvf filename.tar testfile

#backup with zip
tar -czvf filename.tar.gz testfile

#backup with gzip
tar -cjvf filename.tar.bz2 testfile

#uncompress tarfile
tar -xvf filename.tar

#uncompress .bz tarfile
tar -xjvf filename.tar.bz2

#uncompress .gz tarfile
tar -xzvf filename.tar.gz

c -create
v -verbose
x -extrat
f -filename
z -compress the tar file with gzip
j -compress the tar file with bzip2

#more
lzma
rar
7zip
lbzip2
xz
lrzip
PeaZip
arj

No comments:

Post a Comment