{"id":16942,"date":"2022-04-26T09:35:15","date_gmt":"2022-04-26T09:35:15","guid":{"rendered":"https:\/\/linuxways.net\/?p=16942"},"modified":"2022-04-26T09:35:15","modified_gmt":"2022-04-26T09:35:15","slug":"how-to-unzip-the-gz-files-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-unzip-the-gz-files-in-linux\/","title":{"rendered":"How to Unzip the gz Files in Linux"},"content":{"rendered":"<p>Gzip is a widely used compression technique and tool for reducing the size of data. In Linux and Unix-based operating distributions, gzip compression is widely popular. The extension of gzip files is usually *.gz or *.z. In this article, we&#8217;ll show you how to extract or unzip gzip files using commands like gzip, gunzip, and zcat.<\/p>\n<h2>Unzip gz file in Linux<\/h2>\n<p>In Linux, there are two methods for unzipping your gz file:<\/p>\n<ul>\n<li>Compressing and decompressing gz files using the Command-Line Interface<\/li>\n<li>Compressing and decompressing gz files using the GUI method (Graphical User Interface)<\/li>\n<\/ul>\n<p>The detailed description of both methods is stated below:<\/p>\n<h2>Method 1: Compressing and Decompressing Files Using a Command Line Interface<\/h2>\n<p>Before unzipping the gz file, you have to compress the file using the gzip command.<\/p>\n<h3>Compressing files<\/h3>\n<p>Gzip is a widely used compression method that preserves the original file mode, ownership, and date while compressing a file. Gzip also refers to the.gz file format, as well as the gzip tool for compressing and decompressing files.<\/p>\n<p>Use the below-mentioned command to compress a single file:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ gzip filename<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The gzip creates a file named filename.gz and deletes the original.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"379\" class=\"wp-image-16943\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-308.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-308.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-308-300x155.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<p>By default, in a compressed file, gzip command saves the timestamp, ownership, and name of the original file.<\/p>\n<h3>Listing the contents of the gz file<\/h3>\n<p>We usually list the file contents, or files and directories, before unzipping or extracting the gz file. To view the list of contents of a gz file, you can use the gzip command. The -l option is available, as seen below:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ gzip \u2013l test.txt.gz<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"58\" class=\"wp-image-16944\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-309.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-309.png 601w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-309-300x29.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/p>\n<h3>Unzip the gz archive<\/h3>\n<p>To unzip the gz file, you can use the gzip command. Popular Linux distributions such as Ubuntu, Kali, Mint, Fedora, CentOS, and MacOSX, among others, have the gzip command. To unzip gz files, use the -d decompress option. After unzipping, the gz file is erased by default:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ gzip \u2013d test.txt.gz<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"388\" height=\"82\" class=\"wp-image-16945\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-310.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-310.png 388w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-310-300x63.png 300w\" sizes=\"auto, (max-width: 388px) 100vw, 388px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"382\" class=\"wp-image-16946\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-311.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-311.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-311-300x157.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<h3>Keep the unzipped gz file<\/h3>\n<p>By default, when unzipping a gz file, the gz file is automatically erased. However, we can avoid this by specifying the -k option, which keeps the gz file after decompression.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ gzip \u2013d \u2013k test.txt.gz<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"402\" height=\"78\" class=\"wp-image-16947\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-312.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-312.png 402w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-312-300x58.png 300w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"403\" class=\"wp-image-16948\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-313.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-313.png 731w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-313-300x165.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<h2>Decompress gz files using the gunzip command<\/h2>\n<p>The gz file can also be unzipped using the gunzip command. Gunzip is the gzip command with various decompression parameters added. However, because we do not need to supply any options, they are easier to know and utilize. The file is unzipped after we enter the gz file name.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ gunzip test.txt.gz<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"379\" height=\"81\" class=\"wp-image-16949\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-314.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-314.png 379w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-314-300x64.png 300w\" sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"382\" class=\"wp-image-16950\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-315.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-315.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-315-300x157.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<h2>Decompress gz file using the zcat command<\/h2>\n<p>The zcat command is a compression command designed for z compression. Other compression techniques, such as gzip and gz files, are also supported. To unzip the gz file, we can use the zcat command. The zcat command is a command that allows you to see what&#8217;s.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ zcat test.txt.gz<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"379\" height=\"95\" class=\"wp-image-16951\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-316.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-316.png 379w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-316-300x75.png 300w\" sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><\/p>\n<h2>Method 2: Compressing and decompressing files using the GUI Approach<\/h2>\n<p>Graphical desktop environments have everything you need if you don&#8217;t want to work in a terminal. In Gnome&#8217;s Files application, right-click the file that you want to zip and then select the Compress option.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"544\" class=\"wp-image-16952\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-317.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-317.png 730w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-317-300x224.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/p>\n<p>Control-click the directories and\/or files you wish to archive and compress, then right-click and choose &#8220;Compress.&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"207\" class=\"wp-image-16953\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-318.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-318.png 439w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-318-300x141.png 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/p>\n<p>The file manager will prompt you to select a format. If you choose .zip, the zipped file will be straightforward to open on any operating system. You can also make advantage of .tar.xz or .7z, but you&#8217;ll need the necessary software on your Windows or Mac computer to do it.<\/p>\n<p>Right-click the zipped file in Files again if you need to open it. You can select one of options provided in the drop-down menu. These options are: Open with Archive Manager, Extract Here, and Extract To.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"803\" height=\"565\" class=\"wp-image-16954\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-319.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-319.png 803w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-319-300x211.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-319-768x540.png 768w\" sizes=\"auto, (max-width: 803px) 100vw, 803px\" \/><\/p>\n<p>Although the archive manager provides more alternatives, you&#8217;ll most likely want to utilize Extract here or Extract to.<\/p>\n<h2>Conclusion<\/h2>\n<p>This article will provide a fundamental understanding of gz files, their compression, and their decompression methods. This article also covers the two distinct methods for unzipping your gz file under Linux. These methods include command line and graphical user interface (GUI) approaches.<\/p>","protected":false},"excerpt":{"rendered":"<p>Gzip is a widely used compression technique and tool for reducing the size of data. In Linux and Unix-based operating distributions, gzip compression is widely popular. The extension&hellip;<\/p>","protected":false},"author":1,"featured_media":17013,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,891,5,83,165,2],"tags":[35,125],"class_list":["post-16942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-manjaro","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-linux","tag-unzip-files"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=16942"}],"version-history":[{"count":1,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16942\/revisions"}],"predecessor-version":[{"id":17012,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16942\/revisions\/17012"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/17013"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=16942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=16942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=16942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}