Quick Start: Here we’l present quick start examples explained.
Create linux tar gz (Gzip) archive
tar -czvf myarchive.tgz mydirectory/
We use the -t option to create an linux tar archive
-c, –create create a new archive
Note that .tgz is the same thing as .tar.gz
Create linux simple tar archive (withouth compresion)
tar -cvf myarchive.tar mydirectory/
Extracting linux tar archive:
Extract linux tar gz (Gzip) archive
tar -xzvf mystuff.tgz
Extract linux simple tar archive
tar -xvf mystuff.tar
We use -x to extract the files form the tar archive
-x, –extract, –get extract files from an archive
And now let us shortly explain this command
Usage: tar [OPTION]… [FILE]…
Let us check the option used in this example
-c, –create create a new archive
-z, –gzip, –ungzip filter the archive through gzip
-v, –verbose verbosely list files processed
-f, –file=ARCHIVE use archive file or device ARCHIVE
Testing / viewing your archive
tar -tvf myarchive.tar
tar -tzvf myarchive.tgz
Here we used the – t opton
-t, –list list the contents of an archive
————————————————-
Go ahead, try out these commands and stay tuned; we will come up with more doccumentation on linux tar command
Tags: Linux, Linux Commands, tar, tar.gz
July 17, 2008 at 2:16 am |
Thanks for the great help keep the good work
August 13, 2008 at 12:38 pm |
Thanks, as newbe it surprises me that you cant extract to a defined location.
Copy the tarball to the root of the location first.
September 12, 2008 at 7:10 am |
Thanks for the great help keep the good work
October 11, 2008 at 4:29 pm |
[...] http://linuxbasiccommands.wordpress.com/2008/04/04/linux-tar-command/ [...]
January 6, 2009 at 8:54 am |
You can extract to a defined location using:
tar xvf yourstuff.tar -C your/path/here
April 21, 2009 at 10:15 pm |
[...] above! You can extend this further by using cronjobs to run this command on a set schedule, compressing the files into a single archive file, and [...]