Just Host 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:

user@server ~ $ unzip archive.zip

To compress:
user@server ~ $ zip file.ext


To extract .bz2 files:
user@server ~ $ bunzip2 archive.bz2

To compress:
user@server ~ $ bzip2 file.ext


To extract .gz files:
user@server ~ $ gzip -d archive.gz

To compress:
user@server ~ $ gzip file.ext


To extract .tar files:
user@server ~ $ tar -xvf archive.tar

To compress:
user@server ~ $ tar -cvf archive.tar file1.ext file2.ext directory/


To extract .tar.bz2 files:
user@server ~ $ tar -xvjf archive.tar.bz2

To compress:
user@server ~ $ tar -cvjf file.tar.bz2 file1.ext file2.ext directory/


To extract .tar.gz files:
user@server ~ $ tar -xvzf archive.tar.gz

To compress:
user@server ~ $ 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. Just Host does not provide technical support for using these commands, however to learn more about each command you can type user@server ~ $ man <command> Where <command> is the command you would like to learn more about, such as "tar" or "gzip."

Knowledgebase Article 56,463 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 instruct you how to import a database from the command line (SSH).
Knowledgebase Article 587,675 views tags: database mysql ssh

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

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

Related Help Content

Is SSH/Shell access enabled by default?
Knowledgebase Article 560,532 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 79,442 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 207,521 views tags: file files filezilla manager setup

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

This article will explain how to utilize GZip through the file manager.
Knowledgebase Article 77,726 views tags:

How to restore individual files or folders with the Site Backup & Restore tool
Knowledgebase Article 197,847 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 113,385 views tags: fatal php read unable

How to Transfer hosted files from old host to Justhost.com via ssh. Your old host must have SSH access to perform this move. Using SSH to transfer files to Just Host
Knowledgebase Article 149,075 views tags: file host site transfer transferring