Come chat with us and we will get back to you as soon as possible!
Contact SupportHolyHosting
Holy Team

Compressing and decompressing files simplifies many complex tasks, such as file transfer! You will learn how to use unzip with Linux commands to improve your workflow on a VPS hosting environment.
Zip is a popular compression function that is portable and easy to use. You can even decompress files created on Linux in Windows!
Unzip is a utility that is not installed by default on most Linux distributions, but it can be easily installed. You can pair .tar.gz file compression by creating zip or .gz archives using the gzip command in Linux.
What Is Zip Used For?
How to Install Unzip
How to Use Zip and Unzip in Linux
What Is Zip Used For?
Here are some scenarios where you might choose to use zip files:
When you frequently work between Windows and Unix-based systems. It not only compresses files but is also a file packaging utility. It works across multiple operating systems.
To save bandwidth. If you have limited or restricted bandwidth, you can use zip between two servers for file transfer.
Transfer files quickly. The zip utility reduces file size, thereby reducing transfer time.
Upload or download directories at a faster speed.
Save disk space.
Decompress password-protected .zip files.
Enjoy a good compression ratio.
Remember, before taking advantage of Unzip on Linux, you will need to access your virtual private server via SSH.
How to Install Unzip
Now that we know what zip is used for, let's go over how to install unzip on your VPS running
Linux depending on the operating system you are using.
How to Install Unzip on Debian and Ubuntu Systems
Installing unzip is easy! With Ubuntu and Debian, use the following command to install unzip:
```
sudo apt install unzip
```
Sit back and wait a minute until the installation finishes.
To create zip files, you will also need to install zip. You can do this with the following command:
```
sudo apt-get install zip
```
How to Install Unzip on Linux CentOS and Fedora
This is also simple and can be done with the following command:
```
sudo yum install unzip
```
Once the installation is complete, you can verify the path with the following command:
```
which unzip
```
After running the address on the command line, you should get output that looks like this:
```
/usr/bin/unzip
```
You can also confirm that everything is installed correctly using the following command. It will give a detailed output with the unzip utility details.
```
unzip -v
```
How to Use Zip and Unzip in Linux
Now that we know how to install the utility, we can start learning the basic uses of it:
How to Create Zip Files in Linux
The basic syntax for creating a .zip file is:
```
zip opciones archivo_zip lista_de_archivos
```
To test this, we created two files: ExampleFile.txt and ExampleFile1.txt. We will compress them into sampleZipFile.zip with the following command:
```
zip sampleZipFile.zip ExampleFile.txt ExampleFile1.txt
```
How to Use Linux to Decompress a File
The unzip command can be used without options. This will decompress all files in the current directory. An example is the following:
```
unzip sampleZipFile.zip
```
By default, it will decompress in the current folder as long as you have read-write access.
How to Delete a File from a .zip File
Once a .zip file is created, you can delete or remove files from it. So, if you want to delete ExampleFile.txt from the sampleZipFile.zip existing file, you can use the following command:
```
zip -d sampleZipFile.zip ExampleFile.txt
```
After running this command, you can decompress the .zip file using:
```
unzip sampleZipFile.zip
```
Here you will see that ExampleFile.txt has been removed and cannot be seen in the extraction.
How to Update Zip Files
Once a .zip file is created, you can add a new file to an existing .zip file. Suppose you need to add a new file ExampleFile2.txt to the already existing sampleZipFile.zip file. You can do this with the following command:
```
zip -u sampleZipFile.zip ExampleFile2.txt
```
Now, if you extract sampleZipFile.zip, you will find the new file ExampleFile2.txt added.
How to Move a File to a Zip
You can easily move specific files to a .zip file. This means that after adding the files, they will be deleted from their original directories. This is done by adding the -m option. An example of this command is:
```
zip -m sampleZipFile.zip ExampleFile2.txt
```
How to Use Zip Recursively in Linux
The -r option is used to compress files recursively. This option will compress all files present inside a folder. An example of this command is the following:
```
zip -r sampleZipFile.zip MyDirectory
```
In the example, MyDirectory is a directory that has multiple files and subdirectories to compress.
How to Exclude Files in a Zip
When creating a .zip file, you can exclude unwanted files. This is done using the -x option. Below is an example:
```
zip -x sampleZipFile.zip ExampleFile.txt
```
Here, ExampleFile.txt will not be added to sampleZipFile.zip.
How to Decompress to a Different Directory
In case you do not want to decompress in the current directory, but want to specify a directory location, you can also do that. Use the -d option to provide a directory path. An example is shown below:
```
unzip sampleZipFile.zip -d /usr/sampleZip/ExampleDir
```
How to Use Unzip in Linux with Multiple Zip Files
If you want to decompress multiple existing zip files within your current working directory, you can use a command like the following:
```
unzip '*.zip'
```
This command will decompress all individual zip files.
How to Suppress Output When Using Unzip in Linux
By default, when we use the unzip command, it prints the list of all the files being extracted. A summary is printed
of the extraction process. In case you want to suppress these messages, you can use the -q option. The command would be as shown below:
```
unzip -q sampleZipFile.zip
```
How to Exclude Files When Using Unzip in Linux
In case you want to extract all files except one, you can use a command similar to the one shown below:
```
unzip sampleZipFile.zip -x excludedFile.txt
```
Here the command will decompress all files except excludedFile.txt.
You can also prevent specific file types from being extracted. An example of this is the following:
```
unzip sampleZipFile.zip -x "*.png/*"
```
The command above will exclude all .png files from being extracted.
How to Use Unzip in Linux with Password-Protected Files
A password-protected .zip file can be decompressed using the -P option. An example of this command is the following:
```
unzip -P Contraseña sampleZipFile.zip
```
In the command above, Password will be the password for the .zip file.
How to Overwrite Zip Files
When you decompress the same file again in the same location where the file was extracted, by default you will see a message asking if you want to overwrite the current file, overwrite all files, or skip the extraction. This can be a bit tedious if you have many files.
The options would be as shown below:
[y]es, [n]o, [A]ll, [N]one, [r]ename
You can overwrite these files using the -o options. An example of this is the following:
```
unzip -o sampleZipFile.zip
```
You should exercise caution when running this command, as it will completely overwrite existing copies. Any changes made to the previous copy will be overwritten.
How to Use Unzip in Linux Without Overwriting Files
If you decompressed a file and made some changes, but accidentally deleted some files, you can use this approach to restore them! Use the -n option to skip extraction in case a file already exists. The command is as follows:
```
unzip -n sampleZipFile.zip
```
How to List the Contents of a Zip in Linux
The -l option will list all files inside the .zip file along with the timestamp and other basic details. An example of this command is:
```
unzip -l sampleZipFile.zip
```
Conclusion
That's it, you have been introduced to all the essential functions of the zip and unzip utilities in Linux. Start improving your file management right now!
Come chat with us and we will get back to you as soon as possible!
Contact SupportAll the information has been carefully documented and made available in our most recent YouTube tutorial. You can watch it below.
The SkinRestorer plugin can be very useful if you are looking to use your server in non-premium mode. In this case, when configuring it as "online-mode:f
The PHP.ini file is a configuration file that contains your web server's PHP settings. Although it comes preconfigured, you may need to change the default PHP