- Joined
- Feb 19, 2013
- Messages
- 358
- Points
- 28
In some cases, the file managers in your web hosting control panel have certain limitations in extracting files. Or maybe you are using VPS without a management tool. Therefore, the best way to decompress is to use a connection over SSH to execute commands related to packaging and decompression. Common compressed files will be in .tar format; .tar.gz and .zip, each command will have its own command to extract or compress the file.
How to extract files using SSH
First, you will need to move to the directory where the existing package is located. For example, if the archive file is located in the public_html/your_folder, the following command will move you to this directory:
Extract the .tar.gz file
The following command will help you extract the content of a .tar.gz file:
How to extract the .tar file
The following command will help you extract a .tar file:
How to extract .zip
This command will help you extract the .zip file:
Create archive files via SSH
Now that you know how to extract archive files, we will continue to learn how to compress multiple files into one desired format.
How to create a .tar.gz file
The following command will help you to compile several compressed files into a .tar.gz file:
If you want to compress a directory, use the following command:
How to create a .tar file
The .tar file structure is similar to the following:
If you want to create a folder archive, just type the name of the directory instead of listing the whole file:
How to create a .zip file
This file type is also easier to create, the command structure as follows:
Compress directories use the same syntax as such:
Summary
By following simple instructions above, you already knew how to extract files and create a .tar.gz archive file; .tar; .zip using SSH.
Good luck!
How to extract files using SSH
First, you will need to move to the directory where the existing package is located. For example, if the archive file is located in the public_html/your_folder, the following command will move you to this directory:
Code:
cd public_html/your_folder
The following command will help you extract the content of a .tar.gz file:
Code:
tar -zxvf ArchiveName.tar.gz
The following command will help you extract a .tar file:
Code:
tar -xvf ArchiveName.tar
This command will help you extract the .zip file:
Code:
unzip ArchiveName.zip
Now that you know how to extract archive files, we will continue to learn how to compress multiple files into one desired format.
How to create a .tar.gz file
The following command will help you to compile several compressed files into a .tar.gz file:
Code:
tar -zcf NewArchive.tar.gz yourfile1.php yourfile2.php yourfile3.txt
Code:
tar -zcf NewArchive.tar.gz DirectoryName
The .tar file structure is similar to the following:
Code:
tar -zcf archive-filename.txt
Code:
tar -zcf archive-name.tar.gz DirectoryName
This file type is also easier to create, the command structure as follows:
Code:
zip archive-name.zip filename1.php filename2.php filename3.php
Code:
zip archive-name -r DirectoryName
By following simple instructions above, you already knew how to extract files and create a .tar.gz archive file; .tar; .zip using SSH.
Good luck!
Last edited: