gzip
file managementLinux/Unix
The gzip command is one of the most frequently used commands in Linux/Unix-like operating systems. gzip Compress or decompress files
Quick Reference
Command Name:
gzip
Category:
file management
Platform:
Linux/Unix
Basic Usage:
gzip [options] [arguments]
Common Use Cases
Syntax
gzip [options] [files...]
Options
Option | Description |
---|---|
-c, --stdout |
Write output on standard output; keep original files unchanged |
-d, --decompress |
Decompress files (same as gunzip) |
-f, --force |
Force compression or decompression even if file has multiple links or output file already exists |
-h, --help |
Display help information and exit |
-k, --keep |
Keep (don't delete) input files during compression or decompression |
-l, --list |
List compressed file contents |
-n, --no-name |
Do not save or restore the original name and timestamp |
-N, --name |
Save or restore the original name and timestamp |
-q, --quiet |
Suppress all warnings |
-r, --recursive |
Travel the directory structure recursively |
-t, --test |
Test compressed file integrity |
-v, --verbose |
Display the name and percentage reduction for each file |
-1, --fast |
Compress faster (less compression) |
-9, --best |
Compress better (best compression, slowest) |
Examples
How to Use These Examples
The examples below show common ways to use the gzip
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
gzip file.txt