Linux:How To Use Zip And Unzip command

What is Zip command? zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2.etc.  and so if you want to list , or extract files form a zip file, unzip comand will be used. so what is unzip? unzip will list, test, or extract files from a ZIP archive, commonly found on MS-DOS systems.  The default behavior (with no options) is to extract into the current directory (and subdirectories below it) all files  from  the  specified  ZIP  archive. In this post, you’ll see how to install zip/unzip utility in linux/unix operating system, how to compress file into a zip archive, how to extract files from a zip archive file.

How To Install Zip and Unzip In Linux

You can install the zip/unzip tools in redhat/centos/fedora linux using the yum command, issue the following command:

To install zip:

yum install zip

To install unzip:

yum install unzip

For ubuntu/debian linux, issue the following command to install zip and unzip:

apt-get install zip

apt-get install unzip

How to use zip command to compress file or directory to archive file

If you want to archive all files under the current directory, use the following command:

zip archivename.zip file1 file2 file3. ...

This command will compress all of files under the current direcotory to a archive file named as archivename.zip.

Extract archive file into a target directory

unzip command will be used to extract a archive file and you can use “-d” option to specifiy the target directory, which will store all files extract from archive file.

Assuming unzip a archive file named as: afile.zip, extract to /root directory, issue the following command:

#unzip -d /root  afile.zip

You can switch to root directory to check if all file was extracted from archive file.

done….

You might also like:

Sidebar



back to top