Rocky Linux

How to Install and Use Zip in Rocky Linux 9

Zip files are used to compress and store multiple files so that you can share them conveniently. These zip files are also useful in organizing multiple files and saving the system’s disk space. You can create a password-protected zip file that encrypts sensitive information and secures the files from unauthorized access.

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:

sudo dnf update

After updating the system, run the following command to install the zip and unzip utilities:

sudo dnf install zip unzip

Furthermore, you can check the version of Zip that you previously installed:

zip --version

Zip a File

Zip comes with a ton of options. First, let’s run the following command to check all these options:

zip --help

For example, if you want to zip the DATA folder to the “IMP.zip” file, use the following commands:

cd ~/Documents

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:

Cd ~/Documents

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:

zip -u <zip file name> <content name>

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:

cd ~/Documents

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:

cd ~/Documents

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.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.