Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a zip file on linux?

zip -h is confusing! I just want to know how to make a .zip from a directory. kthxbi

like image 250
Dan Avatar asked Jun 25 '14 21:06

Dan


People also ask

How zip a file in Linux with example?

Syntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.

How do I create a zip folder in Terminal?

If you open a terminal console in the parent directory, or used the cd command to navigate there from the command line, you should then be able to run the command on the folder. The syntax is ' zip -r <zip file name> <directory name> '. The '-r' option tells zip to include files/folders in sub-directories.

Is zip available in Linux?

Zip files can be easily extracted in Windows, macOS, and Linux using the utilities available for all operating systems.

How do I create a zip file?

Select “Compressed (zipped) folder”. To place multiple files into a zip folder, select all of the files while hitting the Ctrl button. Then, right-click on one of the files, move your cursor over the “Send to” option and select “Compressed (zipped) folder”.


1 Answers

zip -r archive.zip dir_to_zip

from man zip

-r  
   --recurse-paths
          Travel the directory structure recursively; for example:

                 zip -r foo.zip foo

          or more concisely

                 zip -r foo foo

In  this  case, all  the  files and directories in foo are saved in a zip archive
named foo.zip,including files with names starting with ".", since  the  recursion
does not use the shell's file-name substitution mechanism...

Even if it functions well I would like to propose you 7z(http://www.7-zip.org/).

  7za a directory.7z  directory

It has a better compression and it is opensource, GNU LGPL license, freely available for windows,linux,BSD...

BTW it creates/opens 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM,
and open unpack only: ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, RAR, RPM, SquashFS, UDF, VHD, WIM, XAR and Z.

[They should pay me for advertisement :-)]

like image 142
Hastur Avatar answered Oct 01 '22 09:10

Hastur