How to Extract a .gz File or directory in Linux using command prompt / terminal / shell / bash
Extract GZ archive file in Linux TerminalTo extract the GZ archive to the current directory, use below command.$ gunzip archive.gz .gz files are compressed with gzip compression algorithm. To extract .gz files we use gunzip command is used in Linux.if the operation is successful, nothing is shown an...
Extract GZ archive file in Linux Terminal
To extract the GZ archive to the current directory, use below command.
$ gunzip archive.gz
.gz files are compressed with gzip compression algorithm. To extract .gz files we use gunzip command is used in Linux.
if the operation is successful, nothing is shown and linux command prompt is given back to the user
Extract GZ file and see verbose output
if you want to see what happens during the unzip operation , you can user the -v parameter with the command.
# gunzip -v file_name.gz
-v stands for verbose, which shows a log of actions happening while the archive is decompressed.
Also note, after decompressing using gubzip , the GZ extention is removed from the file. so , your compressed archive is no longer available but the extracted file.
Extract GZ file keep both orginal file and new
if you want to keep the archive as well, please use the -k parameter with the command as below.
# gunzip -k file_name.gz
View information about a GZ archive file
To view information about the compressive GZ gzip file, you can use the gunzip command like below, it does not uncompress the archive but give you vital information about the archive.
gunzip -l file_name.gz
Compress a file to a GZIP archive with GZ extension
Sometimes it is required to compress a file to save space, transfer safely or for other reasons. In Linux , you can use gzip command to compress a file. e.g.
gzip file_name.txt
Compress a directory using gzip
On Linux, gzip is unable to compress a folder, it used to compress a single file only. To compress a folder, you should use tar + gzip, which is tar -z.
tar -zcvf outputFileName.tar.gz folderToCompress
Related Articles
Email Authentication: The Critical Foundation of Modern Business Communication
Complete guide to email authentication protocols. Learn SPF, DKIM, DMARC & BIMI configuration, adoption stats, business impact, and 2025 compliance requirements.
Whats DevOps and How to Learn DevOps
PHP Get path in an Laravel application
Laravel framework provides several useful helper methods to get various paths required to access some commonly used directories/folders.app_path() - Laravel app_path helperbase_path() - Laravel helperconfig_path() - Laravel helperdatabase_path() - Laravel helpermix() - Laravel helperpublic_path(...
Magento 2 add a user via command line cli
Create Magento 2 admin users using command line. Quick CLI commands for adding users, setting roles, and managing administrator access.