Thursday, January 9, 2014

File compressions in Linux

1. tar command to make single archive file          
    tar -cvf testcontent.tar testcontent.txt          , tar -cvf  testcontent.tar yourFolder/

2. tar command to extract a tarball
    tar -xvf testcontent.tar

3. tar command to compress a file or folder with GZIP utility  
    tar -cvzf testcontent.tar.gz testcontent.txt    , tar -cvzf testcontent.tgz testcontent.txt

    Note : testcontent.tar.gz and testcontent.tgz are similar    

4. tar command to extract .tar.gz or .tgz file          
    tar -xvf testcontent.tar.gz                  , tar -xvf testcontent.tgz

5. tar command to compress a file or folder with BZ2 utility  
    tar -cvjf testcontent.tar.bz2 testcontent.txt  , tar -cvjf testcontent.tar.bz2 yourFolder/

6. tar command to extract .tar.bz2 file              
    tar -xvf testcontent.tar.gz

7. zip command to compress a file or folder          
    zip -r mybackupfile testfile.txt          , zip -r mybackupfile yourFolder/
 
    Note : Output file will be mybackupfile.zip


8. zip command to uncompress a zip file            
    unzip mybackupfile.zip

No comments:

Post a Comment