Zip a Folder in Linux
Lot of people get confused and don’t know this simple command. Most of the webmaster uses ftp programs like filezilla or cuteftp or winscp and are not very comfortable with shell but sometimes for taking backups, it becomes very important to use zip to get backup of all files and folders.
If you are looking to zip a folder (with subfolders and many files in it), this is the command for it -
zip -9 -r <zip_file_name.zip> <folder_name>
To zip a single file, you can use this command
zip -9 -r <zip_file_name.zip> <file_name>
The -9 option is for better compression.
there are many variants of zip command like bzip and gunzip but I think zip is fine enough. though I think bzip gives little better compression. If you get an error like command not found then your system may not support zip (which is certainly shocking!) though in that case you can use tar command.
tar -cvzf <tar_file_name.tar> <file_name>
to untar the file, you need to use
tar -xvzf <tar_file_name.tar>
Related posts:
- .r01 File A RAR archive is a utility used for compression and...
- Change Firefox Download Folder This is one of the beginners tip but can trouble...
- Move Wordpress Blog from Subfolder to Root folder If you are looking to move your wordpress blog from...
- No Single.php file in Wordpress Theme Most of the worpdress themes do come up with index.php...
- Unix Sort The Unix sort command is a simple command that allows...
1Prasad on Apr 2, 2009 :
Are you sure the tar command is correct ? the zip command for zipping folder looks fine but I am not sure the tar code is correct
2admin on Apr 2, 2009 :
I am pretty sure I have got the commands right, though to be honest, its been sometime since I have played with linux