Home > Article > Operation and Maintenance > How to decompress gz format files in linux
In Linux, you can use the gunzip command or the "gzip" command to decompress gz format files. The gunzip command is used to decompress files compressed by gzip, that is, decompress files with the extension ".gz", the syntax is "gunzip [options] file..."; for decompressing files compressed by gzip, you can also use gzip itself , that is, "gzip -d compressed package".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The gunzip command in Linux can be used to decompress .gz compressed files. In fact, gunzip is a hard connection of gzip, so whether it is compression or decompression, it can be completed through the gzip command alone.
Linux gunzip command: decompress files or directories
gunzip is a widely used decompression command, which is used to decompress files compressed by gzip file (extension .gz).
To decompress files compressed by gzip, you can also use gzip itself, that is, gzip -d
compressed package.
The basic format of the gunzip command is:
gunzip [options] file...
Parameters | Description |
---|---|
options | Parameters used by the gunzip command. |
file | The name of the file to be decompressed. |
Commonly used parameters of gunzip command
Parameter | Description |
---|---|
-a, --ascii | Use ASCII text mode. |
-c, --stdout, --to-stdout | Output the decompressed file to the standard output device. |
-f, --force | Forcibly decompress the compressed file, regardless of whether the file name or hard link exists and whether the file is a symbolic link. |
-l, --list | List related information of compressed files. |
-L, --license | Display version and copyright information. |
-n, --no-name | When compressing a file, the original file name and timestamp will not be saved. |
-N, --name | When compressing a file, save the original file name and timestamp. |
-q, --quiet | Do not display warning messages. |
-r, --recursive | Recursive processing, all files and subdirectories in the specified directory will be processed together. |
-t, --test | Test whether the compressed file is correct. |
-v, --verbose | Display the instruction execution process. |
Example 1】Decompress the file directly.
[root@localhost ~]# gunzip install.log.gz
Of course, "gunzip -r" will still only decompress the files in the directory, but not unpack them. To decompress the ".gz" format, you can also use the "gzip -d" command, for example:
[root@localhost ~]# gzip -d anaconda-ks.cfg.gz
[Example 2] To decompress the contents of the directory, you need to use the "-r" option. For example:
[root@localhost ~]# gunzip -r test/
Note that if we are compressing a plain text file, you can directly use the zcat command to view the contents of the text file without decompressing it. For example:
[root@localhost ~]# zcat anaconda-ks.cfg.gz
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to decompress gz format files in linux. For more information, please follow other related articles on the PHP Chinese website!