🖥️gzip
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the gzip command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗██╗██████╗
# ██╔════╝ ╚══███╔╝██║██╔══██╗
# ██║ ███╗ ███╔╝ ██║██████╔╝
# ██║ ██║ ███╔╝ ██║██╔═══╝
# ╚██████╔╝███████╗██║██║
# ╚═════╝ ╚══════╝╚═╝╚═╝
# To create a *.gz compressed file
gzip test.txt
# To create a *.gz compressed file to a specific location using -c option (standard out)
gzip -c test.txt > test_custom.txt.gz
# To uncompress a *.gz file
gzip -d test.txt.gz
# Display compression ratio of the compressed file using gzip -l
gzip -l *.gz
# Recursively compress all the files under a specified directory
gzip -r documents_directory
# To create a *.gz compressed file and keep the original
gzip < test.txt > test.txt.gz
gunzip
# decompresses. gunzip is the same as gzip -d.
# Show the process in a tree format, search for gzip and show 8 lines of pre-match context to see its "family". The [] around the g in gzip is a regex trick to avoid matching the grep process itself.
ps auxwf | grep -B8 "[g]zip"
# Create a compressed tar file that rsync will transfer efficiently
GZIP='--rsyncable' tar cvzf bobsbackup.tar.gz /home/bob
# Explanation: rsync works by comparing files on the local and remote machine and only sending those parts of the file that have changed. The normal way compression works, it results in everything after the modification changing, meaning lots of data ends up going over the network when you try to rsync compressed files.
# The --rsyncable option to gzip changes the compression scheme so that modifications to the input file only affect the part of the file where they're located. This allows rsync to work its magic. In this one-liner, the z option to tar calls gzip, which recognizes and uses any options specified in the GZIP environment variable.
# Limitations: Using the --rsyncable option results in a slightly larger compressed file. Not all versions of gzip include this feature - use the --help option to see if it's available on your system.
#==============================##==============================#
# CMD GZIP #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command gzip in a clear format. This allows users to quickly access the needed information for gzip without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for gzip are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.