Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How do I create a .tar.gz file using a terminal? Also, is there anything special I have to do/type to include folders in the tar.gz?
Thanks.

A tar.gz filed is actually a tarred file which is gzipped...
Let me explain...What tar does is that it creates one file out of many files/folders. IT DOES NOT COMPRESS.
What gzip does is it compresses a file or folder.
the GNU tar program (available in all distros) has an option -z to pass the file through the gzip algorithm...
So, if you have the following folders you want in your tar.gz file...
foo1 foo2 foo3
you would do something like tar -cvzf myfolders.tar.gz foo1 foo2 foo3
this will create a tar.gz file named 'myfolders.tar.gz' having foo1 foo2 foo3 in it.
If you want better compression, you should use the bzip2 compression instead, using tar -cvjf instead of -cvzf

srry, did not explain the options...
c is for creating an archieve, v is for verbose, z is for passing it through gzip, f is for specifying the name of the tar.gz file to be created.

Type 'tar czf archive.tar.gz folder1 file2 file3 folder4 etc' - nothing else is required, assuming you have gzip and tar installed.

Make sure to add in 'p' with the options to preserve permissions, if that is important to you.
The way I use tar is this:
cd /path/to/dir
tar cCjpf /path/to/dir filename.tar.bz2 *This uses bzip2 compression to compress everything in the directory. This is the command I use when I make backup images of my system.

![]() |
PPP0 / Gnome in RH 8.0
|
Cannot boot after ghostin...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |