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

Windows compact /c equivalent in Linux

Compresses individual files using gzip or xz to reduce their stored size.

Windows compact /c
Linux equivalents
Debian/Ubuntu same command
gzip file.log
Fedora same command
gzip file.log
Arch same command
gzip file.log

Overview

What this command does

Compresses individual files using gzip or xz to reduce their stored size.

Migration tip: Windows compact uses transparent NTFS compression. gzip and xz instead create compressed files such as file.log.gz or file.log.xz.

Practical tasks

Common use cases

Compress individual files

Compresses individual files using gzip or xz to reduce their stored size.

gzip file.log

Compress to file.log.gz

gzip -k file.log

Keep the original file

xz -9 file.log

Use stronger xz compression

Ready to run

Copyable Linux commands

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

gzip file.log
gzip -k file.log
xz -9 file.log

Walkthrough

Examples with explanations

gzip file.log # compress a file with gzip
gzip -k file.log # compress while keeping the original
xz -9 file.log # compress with maximum xz compression

Reference

Common options and variations

Command or optionUse
gzip file.logCompress to file.log.gz
gzip -k file.logKeep the original file
xz -9 file.logUse stronger xz 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 gzip file.log Same command on this distribution.
Fedora same command gzip file.log Same command on this distribution.
Arch same command gzip file.log Same command on this distribution.

Important

What to watch out for

gzip and xz normally replace the source file. Use -k when you need to keep the original.

Keep learning

Related File Management commands