← All commands
Topic hub File Management
Windows Linux File Management Archives & Compression

Windows Compress-Archive equivalent in Linux

Compresses files or folders into a standard ZIP archive.

Windows Compress-Archive
Linux equivalents
Debian/Ubuntu same command
zip -r archive.zip folder/
Fedora same command
zip -r archive.zip folder/
Arch same command
zip -r archive.zip folder/

Overview

What this command does

Compresses files or folders into a standard ZIP archive.

Migration tip: The Linux zip utility is the closest match to PowerShell Compress-Archive. Use -r when the source contains directories.

Practical tasks

Common use cases

Create a ZIP archive

Compresses files or folders into a standard ZIP archive.

zip archive.zip file.txt

Compress one file

zip -r project.zip project/

Compress a directory recursively

zip -9 -r backup.zip Documents/

Use maximum ZIP compression

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

zip archive.zip file.txt
zip -r project.zip project/
zip -9 -r backup.zip Documents/

Walkthrough

Examples with explanations

zip archive.zip file.txt # create an archive containing one file
zip -r project.zip project/ # archive a complete directory
zip -9 -r backup.zip Documents/ # use maximum compression

Reference

Common options and variations

Command or optionUse
zip archive.zip file.txtCompress one file
zip -r project.zip project/Compress a directory recursively
zip -9 -r backup.zip Documents/Use maximum ZIP compression

Distro differences

Debian/Ubuntu vs Fedora vs Arch

This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command zip -r archive.zip folder/ Same command on this distribution.
Fedora same command zip -r archive.zip folder/ Same command on this distribution.
Arch same command zip -r archive.zip folder/ Same command on this distribution.

Important

What to watch out for

Existing archive entries may be updated rather than replaced. Delete the old archive first when you need a completely fresh result.

Keep learning

Related File Management commands