74

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??

RocketMan
  • 1,011
  • 2
  • 8
  • 7

2 Answers2

107

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
Seth
  • 57,282
  • 43
  • 144
  • 200
wisemonkey
  • 3,293
  • 8
  • 30
  • 34
13

It's the same. Just rename the file from file.tar.gz to file.tgz.

arrange
  • 14,727
  • 4
  • 42
  • 32
  • 7
    You've forgotten the command for renaming a file: `mv file.tar.gz file.tgz`. Obvious, but worth mentioning – Lekensteyn Nov 29 '11 at 23:08