Like the USB format commands, I sometimes forget the Zip file/folder commands so here it is to remind me.
First install Zip if not already there.
$ sudo yum -y install zip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Webmin: webmin.mirror.somersettechsolutions.co.uk
* base: mirror.bytemark.co.uk
* epel: mirror.bytemark.co.uk
* extras: mirror.bytemark.co.uk
* updates: mirror.bytemark.co.uk
Setting up Install Process
Package zip-3.0-1.el6.i686 already installed and latest version
The syntax to zip up a folder is
$ zip -r <zip_package_name.zip> <folder_to_be_zipped>
$ zip -9 -r <zip_package_name.zip> <folder_to_be_zipped>
$ zip <zip_file_name.zip> <file_to_be_zipped>
$ zip -9 <zip_file_name.zip> <file_to_be_zipped>
-9 is to invoke the maximum compression value, you can leave it off for the default compression.
So as an example, to zip up an xvid .avi file should the need arise.
$ zip -r factory.zip factory.avi (avi files wont compress)
adding: factory.avi (deflated 1%)
So we have a look inside with Xarchiver, there it is.
To zip up a test folder containing various compressible files and using default and maximum compression.
$ zip -r test1.zip test_folder
$ zip -9 -r test2.zip test_folder
Although it often does not seem that the compression makes all that much difference, those are the usual commands.
To unzip the folder or file just
$ unzip <zip_file/folder_name>
Zip folders in Linux are usable cross platform.
$ zip -h for more options and flags.
That's it, simple zipping and unzipping.
Labels: Centos 6, RHEL, zip file, zip folder