Compress in .tgz
291,210
Solution 1
A tar.gz file and a .tgz file are similar.
Compress files using tar:
tar -cvzf <name of tarball>.tgz /path/to/source/folder
for example, I want to create a backup.tgz
or backup.tar.gz
from folder /home/user/project
tar -cvzf backup.tgz /home/user/project
tar -cvzf backup.tar.gz /home/user/project
You can use tar cvzf
instead of tar -cvzf
as well.
Extract .tgz or .tar.gz files using tar
tar -xvzf backup.tgz
tar -xvzf backup.tar.gz
Mnemonic for compression (the order of the flags do not matter)
- C ompress
- Z ee
- F ile
- V erbose
Mnemonic for extraction (the order of the flags do not matter)
- e X tract
- Z ee
- F ile
- V erbose
Solution 2
It's the same. Just rename the file from file.tar.gz
to file.tgz
.
Related videos on Youtube
Author by
RocketMan
Updated on September 18, 2022Comments
-
RocketMan over 1 year
I want to compress files in .tgz. I know how to make tar.gz(with tar and gzip) and some people say it is almost the same, but I need to make a .tgz, how??
-
Lekensteyn over 12 yearsYou've forgotten the command for renaming a file:
mv file.tar.gz file.tgz
. Obvious, but worth mentioning -
Dorian Dore about 9 yearsIs there a flag to have a password when you compress your file?
-
Andres F. almost 7 yearsNitpick: the order of the flags does matter for f: it must be the last flag, otherwise it fails.
-
spencer7593 over 6 yearsFor the flags,
c
is better remembered as create, andz
is remembered as compression, as in thez
from zlib, gzip, zip. A better mnemonic would be C reate Z ipped F ile. -
James about 4 yearsAren't
.tar.gz
file and a.tgz
exactly the same? -
Neurotransmitter almost 4 years@ImmanuelWeihnachten these are just file extensions without any explicit meaning. You give meaning to them. And yes,
.tar.gz
and a.tgz
considered the same.