Home > Linux > Zip a Folder in Linux

Zip a Folder in Linux

I keep forgetting the command to zip a folder in Linux . And I have even got all files in the folder got zipped individually when I typed the command wrongly, which looked funny to me. The correct command, to remind myself:

zip -9 -r file name .zip  folder name

To zip a single file:

zip -9

Use “-9″ for best compression. The compressed file works fine with Windows XP compression tool.

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>
Categories: Linux Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.