Back to the command reference

gzip

ArchivesBeginner In simulator In real Linux

Compress files with gzip (replaces the original)

Name: gzip = GNU zip

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

gzip compresses files with DEFLATE into .gz, removing the original (-k keeps it). It handles single files; for directories, tar them first (.tar.gz). Fast and universal, it is the most common format on Linux.

Syntax

gzip [OPTION]... FILE...

Common options

-d / --decompressDecompress (same as gunzip)
-k / --keepKeep the original
-c / --stdoutWrite to standard output and leave the file alone
-9 / --bestBest compression
-1 / --fastFastest (least compression)
-r / --recursiveRecurse into directories
-l / --listShow sizes and the compression ratio
-t / --testCheck that the file is intact
-f / --forceForce (overwrite existing files and so on)
-v / --verboseShow the ratio for each file

Examples

  • $ gzip app.log

    Produces app.log.gz

    Explain
  • $ gzip -k app.log

    Compress but keep the original

    Explain

Related