zip
# apt-get install zip
# apt-get install unzip
OR
$ sudo apt-get install zip unzip
If you are Red Hat Linux/Fedora/CentOS Linux user then you can use the yum command to install zip and unzip program as follows:
# yum install zip
# yum install unzip
zip is a compression and file packaging utility for Linux and Unix (including FreeBSD, Solaris etc).
unzip will list, test, or extract files from a ZIP archive files.
ziping files/directories examples
Creates the archive data.zip and puts all the files in the current directory in it in compressed form, type:
$ zip data *
Note: No need to add .zip extension or suffix as it is added automatically by zip command.
Use the ls command to verify new zip file:
$ ls
To zip up an entire directory (including all subdirectories), type the following command:
$ zip -r data *
unziping files/directories examples
To use unzip to extract all files of the archive pics.zip into the current directory & subdirectories:
$ unzip pics.zip
You can also test pics.zip, printing only a summary message indicating whether the archive is OK or not:
$ unzip -tq pics.zip
To extract the file called cv.doc from pics.zip:
$ unzip pics.zip cv.doc
To extract all files into the /tmp directory:
$ unzip pics.zip -d /tmp
To list all files from pics.zip:
$ unzip -l pics.zip
TAR
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
-c: Create an archive.
-z: Compress the archive with gzip.
-v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f: Allows you to specify the filename of the archive.
UNTAR
tar -zxvf data.tar.gz
-z : Uncompress the resulting archive with gzip command.
-x : Extract to disk from the archive.
-v : Produce verbose output i.e. show progress and file names while extracting files.
-f data.tar.gz : Read the archive from the specified file called data.tar.gz.
Disable copy files in mac with tar
COPYFILE_DISABLE=1 tar -cf 2.tar file*