Compress/Decompress files via CLI (Command-Line Interface) | Bluehost Support
Support
  1. bluehost knowledge base

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 original 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. Bluehost 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."