Although some operating systems like Windows and macOS have the simple option to unzip the files, it is a challenge in Linux. Operating systems like Rocky Linux 9 require specific CLI tools to unzip and zip the files. This tutorial has the complete ways to install and use Zip in Rocky Linux 9.
How to Install and Use Zip in Rocky Linux 9
Before moving further, let’s first install Zip in the system. First, run the following command to update the system:
After updating the system, run the following command to install the zip and unzip utilities:
Furthermore, you can check the version of Zip that you previously installed:
Zip a File
Zip comes with a ton of options. First, let’s run the following command to check all these options:
For example, if you want to zip the DATA folder to the “IMP.zip” file, use the following commands:
ls
zip -r IMP.zip DATA
In the previous command, we recursively used the -r option to compress the files of the particular directory.
Password-Protected Zip File
A password-protected zip file comes in handy to maintain confidentiality, privacy, and data integrity. Hence, if you want to create a password-protected zip file, use the -p option. For example, let’s use the following command to create a password-protected zip of the DATA directory:
ls
zip -r -P 12345 IMP.zip DATA
In the previous command, 12345 is the password and “IMP.zip” is the password-protected zip file that includes the DATA directory.
Add the Contents to an Existing Zip File
If you already have a zip file and you want to add more content, you can use the -u option for it:
Unzip a File
Unzipping a file from the terminal is simple because all you have to do is use “unzip” before the name of the zip file:
ls
unzip IMP.zip
Password-Protected File
If you receive the password-protected zip file, run the following command to unzip it in the Rocky Linux 9:
ls
unzip -P 12345 IMP.zip
Conclusion
Unzipping and zipping a file in Rocky Linux 9 can be easy only if you follow all the provided approaches that we explained. The zip and unzip utilities are already available for Rocky Linux 9, so all you need to do is install them in your system. We described all the basic ways to try installing and using the zip utility in Rocky Linux 9 without getting a single error. Moreover, we recommend that you use the additional options correctly because wrong commands can lead to errors.