Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I use the 7-Zip CLI (7za.exe) on Windows to create .tgz archives, as I use tar zcvf archive.tgz source_files on Linux?

share|improve this question

migrated from Sep 26 '11 at 11:30

This question came from our site for professional and enthusiast programmers.

OT alert: it beats me why anybody would use 7-zip in any circumstances. Why not winzip? – Pete Wilson Sep 26 '11 at 11:18
@PeteWilson It's free. – f.ardelian Sep 26 '11 at 11:21
Thanks to whoever moved the question here. My mistake. – f.ardelian Sep 26 '11 at 11:32
Not the only reason. Supported file formats and features blow winzip out of the water. My reaction is more along the lines of why would anybody not use 7-zip. – mindless.panda Sep 26 '11 at 13:35
up vote 11 down vote accepted

If you'd like to do it in a one-liner:

7za.exe a -ttar -so archive.tar source_files | 7za.exe a -si archive.tgz

I'm not sure why the archive.tar is required in the first part, but it is. It doesn't even need to end in .tar, it just needs an archive name to use.

share|improve this answer

If you're just compressing 1 file into the tarball then 7za a archive.tgz source_file will work.

If you want to add lots of files to the tar then you need to do it in two steps: Create the tar 7za a archive.tar source_files Then compress it 7za a archive.tgz archive.tar

And, optionally, delete the 'temporary' tar del archive.tar

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.