Linux gzip Command
--
Linux Tutorial Linux Introduction Linux Installation Linux Cloud Server Install Linux via WSL Linux System Boot Process Linux System Directory Structure Linux Forgot Password Solution Linux Remote Login Linux File Basic Attributes Linux File and Directory Management Linux User and User Group Management Linux Disk Management Linux vi/vim Linux yum Command Linux apt Command Shell Tutorial Shell Variables Shell Passing Arguments Shell Arrays Shell Operators Shell echo Command Shell printf Command Shell test Command Shell Flow Control Shell Functions Shell Input/Output Redirection Shell File Inclusion Linux Command Complete List Nginx Installation and Configuration MySQL Installation and Configuration Linux Quiz Nginx Installation and Configuration Deep Dive Software Scripting Languages Network Design and Development Computer Science Scripting Web Services Web Service Programming Languages Programming Development Tools The Linux Options Parameters: Compress a File This command will compress Keep the Original File If you want to keep the original file after compression, you can use the This command will keep the original Decompress a File To decompress a or This will decompress Recursively Compress a Directory You can use the This command will compress all files in the Display Compressed File Information Use the This command will display information such as the file's original size, compressed size, compression ratio, etc. Test a Compressed File Use the If the file is intact and undamaged, this command will have no output; otherwise, it will prompt an error.
Linux Tutorial
Shell Tutorial
Linux Reference Manual
Linux gzip Command
gzip command is used to compress files.gzip is a widely used compression program. After a file is compressed by it, its name will have an additional .gz extension.gzip uses the DEFLATE compression algorithm, which is usually faster than bzip2 but has a slightly lower compression ratio.Syntax
gzip [file...]
file...: The files to be compressed. gzip will compress the specified files, generate a compressed file with a .gz suffix, and delete the original files.
-d: Decompress .gz files. Equivalent to using the gunzip command.-k: Keep the original file, do not delete it.-r: Recursively compress all files in the directory.-v: Display detailed compression or decompression process.-l: Display detailed information about the compressed file, such as compression ratio, original size, etc.-1 to -9: Specify compression ratio. -1 is the fastest compression with the lowest compression ratio; -9 is the slowest compression with the highest compression ratio. The default is -6.-t: Test the integrity of the compressed file.Examples
gzip example.txtexample.txt to example.txt.gz and delete the original file example.txt.-k option:gzip -k example.txtexample.txt file and generate example.txt.gz..gz file, you can use the -d option or use gunzip directly:gzip -d example.txt.gzgunzip example.txt.gzexample.txt.gz back to the original example.txt file.-r option to recursively compress an entire directory:gzip -r directory/directory directory and preserve the directory structure.-l option to view detailed information about a .gz file:gzip -l example.txt.gz-t option to test the integrity of a compressed file:gzip -t example.txt.gzgzip is mainly used to compress single files. If you need to compress multiple files or an entire directory, it's common to first archive them with tar, then compress with gzip. For example:tar -cvzf archive.tar.gz directory/
YouTip