tar normal operation

September 19th, 2006 mysurface Posted in Archive, tar | Hits: 40117 | 8 Comments »

I am here to show you examples of how to use tar to zip and unzip two types of files ( tar.bz2, tar.gz)

Remember certain option defined, c for create, z for extract and t for test. v verbose, and f is file. There are 2 common archive people are interested in, bz2 and tar.gz (tgz). bz2 is more compress than tar.gz, but tar.gz is faster for creating and extracting.
To create a bz2 archive, if given list of files, use option j to indicate bz2

tar cjvf filename.tar.bz2 myfile1 myfile2 myfile3

To create a bz2 archive from a folder, if folder must be included in the archive, that means will be extracted with the folder

tar cjvf filename.tar.bz2 foldername/*

To create bz2 archive from a folder but the folder is not included in the tar file.

cd foldername; tar cjvf ../filename.tar.bz2

To test the tar file to see the content of the tar file, use t option.

tar tjvf filename.tar.bz2

To extract the tar file user x option.

tar  xjvf filename.tar.bz2

For tar.gz, use back the same command option but change everything from j to z, let say to create the tar.gz file from folder.

tar czvf filename.tar.gz foldername/*

For more information, check with man

8 Responses to “tar normal operation”

  1. Thanks for solution from your solution i solved a big problem

  2. Thanks, This the only post after 3 weeks of looking that explained exactly what the letters after tar denoted. thanks again.

  3. [...] For more information or more advance options, check out tar normal operation. [...]

  4. [...] relational article : tar normal operation Here’s A Few More Related Posts [...]

  5. Can neone tel me how to use
    tar -a nd tar -r commands wid eg….plz

  6. hellos,

    I have a doubt if any can sowl

    tar -jcvf sks.tar.bz2 *

    OP? —% compressed is less than

    bzip2 sks.tar


    if u not having solution mail me with subject code tar 23
    i will provide best solution for ur que…


  7. Thanks!
    I was quick looking 4 tar + bzip2 compression parameters and Google look @ You.

  8. Not exactly comprehensive. The commands here are very basic and easily found elsewhere. How about including some more advanced usage like appending or removing files from an archive.


Leave a Reply