This article describes two ways to compress files:
- Using cPanel.
- Using the command line.
Table of Contents
- About file compression
- Method #1: Use cPanel
- Method #2: Use the command line
About file compression
Compressing files enables you to store files using less disk space. For example, if you have some files that you rarely use, it may be worth compressing them so they take up less space. Alternatively, if you need to transfer files to or from your hosting account, it is often easier (and faster) to compress multiple files into one compressed file and transfer that file instead.
There are many types of compressed files: ZIP, RAR, tar, gzip, and more. The following procedures demonstrate how to create some of these types of files.
Method #1: Use cPanel
To compress files using cPanel, follow these steps:
- Log in to cPanel.
- Open the File Manager:
- If you are using the Jupiter theme, on the Tools page, in the Files section, click File Manager:
- If you are using the Paper Lantern theme, in the FILES section of the cPanel home page, click File Manager:
- In the left sidebar, click the folder that contains the files you want to compress.
- To select multiple files:
- Hold the Shift key and click to add a group of items to the currently selected items.
- Hold the Ctrl key and click to add one item to the currently selected items.
- After you have selected all of the files you want to compress, on the top menu bar, click Compress:
- In the Compress dialog box, under Compression Type, select the type of compression to use.
Zip Archive files are easily decompressed in Microsoft Windows. Other compression types may require additional applications to use in Windows.
- In the text box, type the name of the compressed archive file.
- Click Compress File(s).
- When compression is complete, the Compression Results dialog box appears.
- Click Close.
To decompress a compressed file, right-click the file in File Manager, and then click Extract.
Method #2: Use the command line
There are many ways to compress files from the command line. The following procedure outlines a few of them:
- Log in to your account using SSH or by cPanel > Terminal.
- At the command prompt, type one of the following commands:
- To create a ZIP file that contains all of the files in the current directory, type the following command:
- To also include any subdirectories and their files, use the -r option. For example:
- To decompress the .zip file, use the unzip command. For example:
- To create a tar file that contains all of the files in the current directory as well as any subdirectories, type the following command:
To decompress a .tar file, use the x option instead of the c option. For example:
- To create a compressed gzip file, type the following command. Replace test.txt with the name of the file you want to compress. This command replaces the existing file with the compressed file (for example, test.txt becomes test.txt.gz):
- To compress all files in the current directory and all files in any subdirectories, use the -r option. For example:
- To decompress a .gz file, use the gunzip command. For example: