tar zip files code example

Example 1: linux tar zip folder

tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

Example 2: how to zip with tar command

tar -czvf archive.tar.gz stuff

Example 3: how to unzip Tar file

## Untar files in Current Directory ##
tar -xvf filename.tar.gz

## Untar files in specified Directory ##
tar -xvf filename.tar.gz -C /path_name_for_unzip/

-x : extract
-C : specified directory
-v : Verbosely show the .tar file progress.
-f : filename of archive file

Example 4: how to zip with tar command

tar -czvf archive.tar.gz /usr/local/something