How to Make ZIP Files on Linux Through a Terminal
The ZIP format in a file is known as an archive file. The purpose is to store various files together. Besides ZIP, there are also RAR, TAR, GZ, and many more. It’s just that most people are more familiar with this ZIP format.
Creating ZIP files on Linux can be done quickly through the terminal. Not only making it but extracting it can also be fast by typing in commands. And this article will show the tutorial.
Install ZIP and UNZIP on Linux
The installation process is very easy and can be done through the Terminal. Please use the following command according to OS which is used now.
Ubuntu and Debian
sudo apt-get install zip unzip -y
CentOS, Fedora and Redhat
sudo yum install unzip zip -y
SUSE
zypper install zip unzip -y
It only takes a few seconds, packages ZIP and UNZIP have been successfully installed and ready to use. Now you can start to try to archive several files or folders into one.
Creating ZIP Files on Linux
For example, here I want to compress two files named example1.txt and example2.txt . Here are the instructions:
zip result.zip example1.txt example2.txt
So later a file named is produced. Zip which is the second example of the file name above.
Filing All Files in a Folder
If the example above is only for archiving files, there is a little extra if you want to archive the folder and the data in it. Namely, only need to add a command or attribute – r .
For example, here, I want to archive a folder called htdocs and all the contents in it. Here are the instructions:
zip -r result.zip HTDOCS
Creating ZIP Files with a Password
Only a few more attributes are needed to be able to add a password to the ZIP file that will be created, here is an example command.
zip -p Password result.zip example.txt
Text Password above is just an example, please change it according to the password you want used.
Also read: How to Create a TAR.GZ File on Windows
Extract ZIP Files on Linux
Actually this is as easy as making it. To extract or extract ZIP files, you can use the UNZIP command as below:
unzip the .zip file
For the example above, you will extract a file named file.zip. And all the data in it will be removed in the directory that you use right now.
Extract In Specified Directories
Add the attribute – d to the command to start setting the directory where the results will be extracted from the ZIP file. For example, here I want to release it to the directory / home / user /.
unzip file.zip -d / home / user /
Using UNZIP with a Password
Sometimes a privacy file has to write a password to be extracted. And the procedure is the same as the process of making it, where you only need to add the attribute – p to write the password
unzip -p Password.zip file
Conclusion
Until here, of course, you already know about making ZIP files and also extract them. The command is effortless. Even doing it from the Terminal is no less fast than GUI.
The process for creating or extracting ZIP files will display on the screen. Make sure you wait until the process stops / finishes so that the archive will not corrupt. If you have questions about the tutorial above, you are welcome to comment below.
Hopefully useful and good luck.
0 Response to "How to Make ZIP Files on Linux Through a Terminal"
Post a Comment