Gzip file unzip linux

How to Unzip/Extract the GZ File in Linux

Zipped files are a handy tool that not only helps in the secure transmission of data but the size of the file is compressed as well. Compressing a file into zipped form makes the transfer much faster. There exist various types of zipped files such as the RAR file, tar.gz, gzip, and so on. GZIP(GNU zip) is an example of the numerous different types of compressed file types. GZIP is more commonly used to compress HTML files which allows the webpages to load at a much faster pace.

This article will provide insight into several methods to extract GZ files in Linux. The content of the post is as follows:

  • Unzip/extract the GZ File Using the gzip Command
  • Unzip/extract the GZ File Using the gunzip Command

Method 1: Unzip/extract the GZ File Using the gzip Command

The first method involves the use of options in the Linux terminal which is the core tool of any Linux operating system. The first step is to navigate to the directory (using the terminal) where the zipped file is located. This is shown in the snippet below:

If you do not want to navigate, simply use the complete file path while running the gzip command shown below:

$ gzip -d /home/itslinuxfoss/Desktop/sample.txt.gz

Once the directory is accessed, simply run the gzip command (the command that is used to compress the files) in the terminal alongside the “-d” option to unzip the GZ file to your system:

To explain the command shown above, the “gzip” command is the standard keyword that is used to compress any file to a GZ file format. The next “-d” indicates that the file should be decompressed. Finally, the “sample.gz” is the name of the file that needs to be extracted.

Method 2: Unzip/extract the GZ File Using the gunzip Command

Instead of utilizing the “gzip” command, the alternate option is the specialized “gunzip” command which does not require the use of any other options in the code. The syntax for the gunzip command is rather straightforward. The code below needs to be executed in the terminal to decompress the file:

Читайте также:  Linux bash increment variable

In this command there are no extra options, just the “gunzip” keyword being utilized alongside the name and full extension of the file which is “sample.gz”.

The difference between these methods is that the “gunzip” method keeps the original zipped file and creates a copy for the extracted GZ file. In the case of method 1, the original file is replaced with the extracted file. This is shown in the snippet below:

As seen above, a copy of the sample file is created when the “gunzip” command is used. These are the two methods through which any GZ file can be extracted on a Linux system.

Conclusion

There are two major ways through which any GZ file can be extracted on a Linux system. The first method makes use of the “gzip” keyword alongside an extra option “-d” to decompress. The second method utilizes the “gunzip” keyword which does not require any extra option and will simply extract and create a copy for the specified file on the system. This article has provided an in-depth guide to unzip/extract the GZ file in Linux.

TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY

Источник

Как распаковать (открыть) файл Gz

Gzip — это популярный алгоритм сжатия, который уменьшает размер файла, сохраняя при этом исходный режим файла, право собственности и временную метку. Этот алгоритм часто используется для сжатия веб-элементов для более быстрой загрузки страницы.

По соглашению, файл, сжатый с помощью gzip, заканчивается на .gz или .z .

В этой статье объясняется, как открывать (или распаковывать) файлы .gz .

Распаковка файла gz

В Linux и macOS вы можете распаковать файл .gz с помощью утилиты gzip . Синтаксис следующий:

Команда восстановит сжатый файл в исходное состояние и удалит файл .gz .

Чтобы сохранить сжатый файл, передайте команде параметр -k :

Еще одна команда , которую вы можете использовать , чтобы распаковать .gz файл является gunzip Эта команда в основном это псевдоним файла с gzip -d .

Чтобы открыть .gz файл с gunzip просто передать имя файла в команде:

Если вы работаете в среде рабочего стола и командная строка вам не по душе, вы можете использовать файловый менеджер. Чтобы открыть (разархивировать) файл .gz , щелкните правой кнопкой мыши файл, который хотите распаковать, и выберите «Извлечь».

Пользователям Windows необходимо установить дополнительное программное обеспечение, например 7zip, чтобы открывать файлы .gz .

Извлечение файла tar.gz

Алгоритм Gzip предназначен для сжатия только одного файла. Файлы с расширением .tar.gz — это архивы .tar, сжатые с помощью gzip.

Чтобы извлечь файл tar.gz , используйте команду tar с параметрами -xf , за которыми следует имя сжатого архива:

Команда автоматически определит тип сжатия и распакует архив в текущий рабочий каталог .

Выводы

Чтобы распаковать файл .gz , используйте команду gunzip после которой укажите имя файла.

Если у вас есть вопросы, оставьте комментарий ниже.

Источник

How To Unzip/Extract Gz File In Linux?

How To Unzip/Extract Gz File In Linux?

Gzip is a popular compression algorithm and tool used to compress files to reduce file sizes? The gzip compression is very popular in Linux and Unix-based operating systems and distributions. The gzip files generally have the *.gz or *.z extension. In this tutorial, we explain how to extract or unzip the gzip files by using different commands like gzip , gunzip and zcat .

Читайте также:  Linux ping with mtu

List gz File Contents

Before unzipping or extracting the gz file we generally list the file contents or files and folders. The gzip command is used to list gz file contents. The -l option is provided like below.

Unzip gz File

The gz file can be unzipped by using the gzip command. The gzip command is provided by popular Linux distributions Ubuntu, Kali, Mint, Fedora, CentOS, and MacOSX, etc. The decompress option is -d to unzip gz files. By default, the gz file is deleted after unzipping it.

Keep Unzipped gz File

By defualt after unzipping the gz file the gz file is deleted automatically. But we can prevent this removal by using the -k option which preserves the gz file after decompression.

Unzip gz File with gunzip Command

The gunzip command can be also used to unzip the gz file. Actually the gunzip is the the gzip command with some decompression options. But it is easier to remember and easy to used as we do not need to provide any option. We just provide the gz file name and the file is unzipped.

Unzip gz File with zcat Command

The zcat is a comprassion command which is created for z compression. But it also supports other compression algorithms like gzip and gz files. We can use the zcat command in order to unzip the gz file. The zcat command

$ zcat blender-2.80.tar.gz > blender.tar

Источник

How to Unzip the gz Files in Linux

How_to_Unzip_the_gz_Files_in_Linux

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’ll show you how to extract or unzip gzip files using commands like gzip, gunzip, and zcat.

Unzip gz file in Linux

In Linux, there are two methods for unzipping your gz file:

  • Compressing and decompressing gz files using the Command-Line Interface
  • Compressing and decompressing gz files using the GUI method (Graphical User Interface)

The detailed description of both methods is stated below:

Method 1: Compressing and Decompressing Files Using a Command Line Interface

Before unzipping the gz file, you have to compress the file using the gzip command.

Compressing files

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.

Use the below-mentioned command to compress a single file:

$ gzip filename

The gzip creates a file named filename.gz and deletes the original.

By default, in a compressed file, gzip command saves the timestamp, ownership, and name of the original file.

Читайте также:  Время в linux формате

Listing the contents of the gz file

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:

$ gzip –l test.txt.gz

Unzip the gz archive

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:

$ gzip –d test.txt.gz

Keep the unzipped gz file

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.

$ gzip –d –k test.txt.gz

Decompress gz files using the gunzip command

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.

$ gunzip test.txt.gz

Decompress gz file using the zcat command

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’s.

$ zcat test.txt.gz

Method 2: Compressing and decompressing files using the GUI Approach

Graphical desktop environments have everything you need if you don’t want to work in a terminal. In Gnome’s Files application, right-click the file that you want to zip and then select the Compress option.

Control-click the directories and/or files you wish to archive and compress, then right-click and choose “Compress.”

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’ll need the necessary software on your Windows or Mac computer to do it.

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.

Although the archive manager provides more alternatives, you’ll most likely want to utilize Extract here or Extract to.

Conclusion

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.

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.

Источник

Оцените статью
Adblock
detector