Sometimes you may need to extract or create an archive file on your hosting server. 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:
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 is the tar.gz format. An example of creating such a file can be seen below:
To compress a file into the tar.gz format, please use:
tar -zcf archive-name.tar.gz foldername/