How to Unzip file .tar.gz on hosting?

Mujkanovic

Well-known member
Collaborate
Registered
Joined
Apr 24, 2016
Messages
424
Points
18
After backup my website on cpanel, i got this file type, filename.tar.gz . How to unzip this file in SSH? I can not use Unzip command in ssh to unzip .gz file.
 

Kaz Wolfe

Well-known member
Registered
Joined
Jul 7, 2016
Messages
604
Points
28
To extract a tar.gz file, you need to use this command with extra parameters --extract (-x) option and specify the archive file name after the f option:

Code:
tar -xf filename.tar.gz
 

fiz

Well-known member
Hosting Provider
Registered
Joined
Aug 6, 2020
Messages
116
Points
16
After backup my website on cpanel, i got this file type, filename.tar.gz . How to unzip this file in SSH? I can not use Unzip command in ssh to unzip .gz file.
You are supposed to use this file to restore your backup through WHM. If you are on shared hosting then you can ask your provider to restore it for you. If you want to extract something manually then you can run the following command to extract files from the archive.

Bash:
tar -zxvf file_name.tar.gz
In case you want to extract it to a specific directory use the following:
Code:
tar -C /home/backups/ -zxvf file_name.tar.gz
You can replace /home/backups/ with your desired path.
 

Mujkanovic

Well-known member
Collaborate
Registered
Joined
Apr 24, 2016
Messages
424
Points
18
Why commands have -xf and-zxvf, which case should I use one of them?
I tried to unzip a .tar.gz file and it only consumed some seconds to unzip 3 GB data, it is more faster than unzip command :LOL:
 

fiz

Well-known member
Hosting Provider
Registered
Joined
Aug 6, 2020
Messages
116
Points
16
fiz
Please a look at this article for tar options.
 

createcraig

New member
Registered
Joined
Nov 24, 2020
Messages
4
Points
1
@Mujkanovic, these are flags in tar. You can type man tar in Linux shell to see the commands.

The -x flag for the tar command means extract
The -z command means to gzip. Normal .tar files you don't need this, but with .tar.gz you need to use gzip to unzip.
The -v command means to do it verbosely, so it shows you what is being unzipped.
The -f command means force, so do not ask you "Are you sure you want to do this?"
 

Sathya narayana

New member
Registered
Joined
Nov 25, 2020
Messages
3
Points
1
Hi there,
We will cover the compression and extraction method of popular archive formats, including .tar.gz, .tar, .zip, and .rar.

.tar.gz Files
  1. You can use the command below to compress several files into a .tar.gz archive:tar -czvf archive-name.tar.gz your-file.text your-file.php your-file.html
    If you intend to compress an entire directory, use the following method.
    Don’t forget to replace “archive-name” and “your-file” with your actual file names and directories. Also, you are not limited to file formats that are used in this example.
    tar -czvf archive-name.tar.gz /Directory-Name
  2. To extract a .tar.gz archive, enter:tar -zxvf archive-name.tar.gz
.tar Files
  1. The syntax for creating .tar archives is as follows:tar -zcf archive-name.tar your-file.php your-file.php your-file.html
    Enter the following line to move the whole directory to a .tar file:
    tar -zcf archive-name.tar.gz /directory-name
  2. You can extract the previous archive by typing this command:tar -xvf archive-name.tar
.zip Files
  1. For .zip files, we’ll be using the zip command instead of tar. Here’s how you create an archive in this format:zip archive-name.zip your-file.php your-file.php your-file.php
    In order to compress a directory, use this syntax:
    zip -r archive-name.zip /directory-name
  2. This command is used for .zip file decompression:unzip archive-name.zip
.rar Files
  1. The command for RAR compression is rar, as shown below:rar a archive-name.rar your-file.txt your-file.php your-file.html
    To put an entire folder into one .rar archive, you should use this syntax.
    rar a archive-name.rar /directory-name
  2. This is how you extract the .rar archive.unrar x archive-name.rar
 

budgetvm

New member
Registered
Joined
Jul 24, 2020
Messages
10
Points
1
After backup my website on cpanel, i got this file type, filename.tar.gz . How to unzip this file in SSH? I can not use Unzip command in ssh to unzip .gz file.
tar -xvzf filename.tar.gz should extract your backup files. All your website files will be under the folder homedir
 

sam@12

Member
Registered
Joined
Jun 8, 2021
Messages
62
Points
6
Hello,

Following is the extract command with explanation.

tar -zxvf file_name.tar.gz

The -x flag for the tar command means extract
The -z command means to gzip. Normal .tar files you don't need this, but with .tar.gz you need to use gzip to unzip.
The -v command means to do it verbosely, so it shows you what is being unzipped.
The -f command means force, so do not ask you "Are you sure you want to do this?"
 
Newer Threads
Recommended Threads
Similar Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top