-
To compress
zip -r <archive_name.zip> <folder/files_to_compress>
-
Compress without
MACOSX
or.Filename
and .ds store files, use the-X
option in the command sozip -r -X <archive_name.zip> <folder/files_to_compress>
-
To extract
unzip <archive_name.zip>
NOTE: If you come from a Windows background, you may be familiar with the zip and rar formats. These are archives of multiple files compressed together.
In Unix and Unix-like systems (like Ubuntu), archiving and compression are separate.
tar
puts multiple files into a single (tar) file.
gzip
compresses one file (only).
-
To compress
tar -zcvf <archive_name.tar.gz> <folder/files_to_compress>
-
To extract
tar -zxvf <archive_name.tar.gz>
-
To extract
tar -zxvf <archive_name.tar.gz> -C </Path/To/Extract>
-
c = Create
-
x = Extract
-
v = Verbose mode
-
p = Preserving files and directory permissions.
-
z = This will tell tar that compress the files further to reduce the size of tar file.
-
f = It allows tar to get file name.
-
C = Extract in different directory.
-
To compress
tar -jcvf <archive_name.tar.bz2> <folder_to_compress>
-
To extract
tar -jxvf <archive_name.tar.bz2>
-
To compress
gzip <folder_to_compress>
-
To extract
gunzip <archivename.gz> gzip -d <archivename.gz>