7-Zip icon
Windows · Free
7-Zip 26.00
↓ Free Download

7-zip Command Line

The 7-zip command line interface lets you compress, extract, and manage archives directly from the terminal without touching the GUI—faster for automation, batch jobs, and scripting. Version 26.00 gives you complete control over the 7z compression format and dozens of other archive types through straightforward command syntax.

Getting Started with 7-Zip Command Line Basics

After you install 7-Zip on Windows, the executable lands at `C:\Program Files\7-Zip\7z.exe` by default. You can add this folder to your system PATH to call it from any terminal window. The core syntax is simple: `7z [command] [archive] [files]`.

The main commands are `a` (add/compress), `x` (extract with folder structure), `e` (extract flat), `l` (list contents), `d` (delete from archive), and `t` (test integrity). Each does exactly one job without bloat.

Essential Command Line Operations

Compression and Archive Creation

To create a `.7z` file from a folder: `7z a backup.7z C:\MyFiles\`. This compresses everything inside using maximum dictionary size by default. Need faster compression? Add the `-mx1` flag for speed or `-mx9` for maximum ratio. Password protection works with `-pYourPassword` appended to the command.

The 7z compression format excels here—you'll see 30-40% better ratios than standard ZIP on most data types. If you need a self-extracting archive (`.exe` file that extracts itself), use `7z a -sfx archive.exe folder/` instead.

Extracting Archives Efficiently

Extract with full directory structure: `7z x archive.7z -oC:\Output\`. The `-o` flag sets the output path. Use lowercase `x` to preserve folders; uppercase `E` flattens everything into one directory. For testing an archive before extraction, run `7z t archive.7z` to verify all files without unpacking.

You can extract specific files by adding their names: `7z x archive.7z document.txt image.jpg`. This saves time on massive archives where you only need a few items.

Advanced Flags Worth Using

File splitting matters for large backups. `7z a -v100m archive.7z folder/` creates 100MB segments—useful for cloud uploads or USB drives. Unicode support is built in; filenames with special characters extract correctly by default.

AES-256 encryption is the default cipher when you set a password. Benchmark testing your compression settings? Run `7z b` to stress-test your system and compare ratio vs. speed tradeoffs across different algorithms.

Pro Tip: Combine batch compression with a simple script. Save this as `backup.bat`: `for /d %%f in (D:\Projects\*) do 7z a -mx9 "D:\Backups\%%f.7z" "D:\Projects\%%f"`. Run it once and it archives every folder into separate 7z files—no manual work needed.

Comparison with Other Free Archivers

Feature7-ZipBandizipIZArc
Command lineYesLimitedYes
7z supportNativeNoYes
AES-256 encryptionYesYesYes
File splittingYesNoYes
Context menuYesYesYes

While Bandizip offers simplicity for regular users, the terminal approach here gives power users and automation scripts direct archive control. Bandizip skips command line entirely—dealbreaker for server work or scheduled tasks.

Real-World Scenarios

Developers use this for CI/CD pipelines. System admins compress server logs nightly with scheduled batch files. The 7-zip command line approach beats GUI tools because it's scriptable, repeatable, and requires zero human interaction.

For Mac and Linux users, 7-Zip is available on Linux through package managers, though the command line remains your primary interface on those platforms.

Why Terminal Compression Matters

Speed is one reason. Batching 50 folders takes seconds via script instead of 20 minutes clicking dialogs. Repeatability is another—same command, same results every time. The free zip software alternative (Windows' built-in compression) lacks encryption, proper 7z compression format support, and batch capabilities entirely.

Mastering 7-zip command line transforms how you handle archives. Once you learn three core commands and a handful of flags, you're faster and more flexible than any GUI approach.