.
  • untar (decompress) a tgz or tbz file in linux

    We already know how to tar all the files under a directory into a tgz file.  This posts use simple examples to show how to untar a tgz or tar.bz2 file . 

    untar a .tar file

    x: tells tar to extract the files.

    v:  list all of the files one by one in the archive. The “v” stands for “verbose.”

    f:  tells tar that a file name is followed.

    untar a .tgz or tar.gz file

    If the file extension is .tgz or tar.gz,

    [Read More...]
  • tar all the files under a directory on linux

    We often need to tar all the files under a directory into a zip file.  This post gives two examples to show how to tar all the contents under a directory into a tgz file. 

    Suppose we have directory structures like

    By running the following command, we can tar all the files of my_folder into the tgz file.

    However, you will find that you actually include the my_folder in the zip file. The structure of the tgz file will looks like this.

    What if you want the file structures like this:

    Two methods tar all the files under a directory into a tgz  file

    You can use the following command to include only the files under my_folder to the zip file:

    Using the -C option to tar all the files under a directory into a tgz file

    You can also using the -C option to include all the files under your directory into a zip file:

    The -C my_folder tells tar to change the current directory to my_folder,

    [Read More...]