Extracting and creating archive files via SSH

Sometimes you would need to extract or create an archive file (i.e to install a script, you would usually download an archive and extract it to continue the installation). The very first step in the process would be to identify the exact archive type by looking at the file extension. The most common archive types are zip (ending with .zip), tar (.tar),  Tar+Gunzip (.tar.gz), Bzip (.bz2) and Rar (.rar).

Each archive type has its own command for compressing/extracting as listed below.

To extract a ZIP file, please use:

unzip archive.zip

To extract a Tar file, please use:

tar -xvf archive.tar

To extract a Tar.Gz file, please use:

tar -zxvf archive.tar.gz

To extract a Rar file, please use:

rar x archive.rar

Each archive type has its own mechanism to create a new archive file. The most commonly used however is the tar.gz format. An example of creating such a file can be seen below:

tar -zcf archive-name.tar.gz foldername/


  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

List files and directories using SSH

In order to list all files and directories using an SSH client, you would need to execute the...

Create/Edit files and folders using SSH cmd line

There are various ways you can create a new file using the SSH command line.The easiest and most...

Move and copy files using SSH

Often you will need to move one or more files/folders or copy them to a different location. You...

Deleting files and folders via SSH

Sometimes you would need to remove a file or a folder from the system. To do so using SSH, you...

Searching for files/text using SSH

In some cases you would need to find the location of a given file or to search for a certain text...