If you are using assistive technology and are unable to read any part of the HostMonster website, or otherwise have difficulties using the HostMonster website, please call 866-573-HOST and our customer service team will assist you.
Skip to main content

HostMonster Web Hosting Help

Compress Decompress Files via CLI

Compress/Decompress files via CLI (Command-Line Interface)

The following commands will allow you to compress your files and directories into a compressed file such as .zip, .tar, .gz, .bz2, etc. This will also allow you to decompress the contents back into their origenal state. If you would prefer to use a GUI (web-based) interface to compress or decompress, You can also do this through cPanel's file manager.

You can also extract and compress files via SSH:

To extract .zip files the command would be as follows:

[email protected] ~ $ unzip archive.zip

To compress:
[email protected] ~ $ zip file.ext


To extract .bz2 files:
[email protected] ~ $ bunzip2 archive.bz2

To compress:
[email protected] ~ $ bzip2 file.ext


To extract .gz files:
[email protected] ~ $ gzip -d archive.gz

To compress:
[email protected] ~ $ gzip file.ext


To extract .tar files:
[email protected] ~ $ tar -xvf archive.tar

To compress:
[email protected] ~ $ tar -cvf archive.tar file1.ext file2.ext directory/


To extract .tar.bz2 files:
[email protected] ~ $ tar -xvjf archive.tar.bz2

To compress:
[email protected] ~ $ tar -cvjf file.tar.bz2 file1.ext file2.ext directory/


To extract .tar.gz files:
[email protected] ~ $ tar -xvzf archive.tar.gz

To compress:
[email protected] ~ $ tar -cvzf file.tar.gz file1.ext file2.ext directory/

Please note that these are the most basic forms of the commands, and have many options that are possible. HostMonster does not provide technical support for using these commands, however to learn more about each command you can type [email protected] ~ $ man <command> Where <command> is the command you would like to learn more about, such as "tar" or "gzip."

Knowledgebase Article 101,876 views bookmark tags:


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

This article will explain how to utilize GZip through the file manager.
Knowledgebase Article 177,467 views tags: archive compress compression decompress file gzip management zip

This article will instruct you how to export a database from the command line (SSH).
Knowledgebase Article 808,887 views tags: database mysql ssh

This article will instruct you how to import a database from the command line (SSH).
Knowledgebase Article 720,407 views tags: database mysql ssh

Related Help Content

Script executed with a cron job requires a specific php.ini file to be used.
Knowledgebase Article 186,850 views tags: command cron cronjob crontab custom line optimizer php zend

Is SSH/Shell access enabled by default?
Knowledgebase Article 782,699 views tags: bash command line secure shell ssh

How to edit several individual pages to replace a string of text e.g. update the phone number on the footer of every page on your site.
Knowledgebase Article 131,364 views tags: command find replace ssh

There are many ways that you can transfer files and folder to and from your hosting account. We highly recommend using an FTP (File Transfer Protocol) program to quickly upload and download files. We
Getting Started Article 278,295 views tags: file files filezilla manager setup

I received an email that my account was migrating; when I log in, my interface looks different. Why did this change? This article will cover some commonly asked questions about the new experience.
Knowledgebase Article 56,565 views tags: account control interface login migration panel rock ui

This article will walk you through extracting compressed files using the File Manager.
Knowledgebase Article 191,490 views tags: cpanel filemanager

How to restore individual files or folders with the Site Backup &amp; Restore tool
Knowledgebase Article 331,375 views tags: backup files folders restore site

I get this with some of my php files: Fatal error: Unable to read X bytes in /home/user/public_html/myfile.php on line Y
Knowledgebase Article 161,642 views tags: fatal php read unable

This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here