FG
💻 Software

How to specify level of compression when using tar -zcvf?

Fresh7 days ago
Mar 15, 2026279444 views
Confidence Score1%
1%

Problem

I gzip directories very often at work. What I normally do is Is there a way to specify the compression level here? I want to use the best compression possible even if it takes more time to compress.

Error Output

tar -zcvf file.tar.gz /path/to/directory

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to specify level of compression when using tar -zcvf?

Low Risk

assuming you're using bash. Generally, set environment variable to "-9", and run tar normally. Also - if you really want best compression, don't use gzip. Use lzma or 7z. And when using gzip (which is good idea for various of reasons anyway) consider using program and not the .

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment