Zip and Unzip Commands in Linux

On Windows, to compress a files which has .zip extension that we use 7Zip to do that. For Linux, we will use zip and unzip for compressing and extracting a .zip file.
Today, I bring you to Ubuntu operating system for trying to use zip & unzip. By default, they are ready installed in. In which case these are missing from your system, you can easily install them by opening your terminal then:

$ sudo apt isntall zip uzip -y

How to create a Zip file with the zip command

To create a Zip file you do not need to add .zip extension, you just do the command:

$ zip test_zip file1.txt file2.txt



If you want to zip a folder, you should use `r` option as below:

$ zip test_zip -r test_zip/


Add a file to existed zip file:

$ zip test_zip -u file3.txt


Delete a file from zip file:

$ zip test_zip -d file3.txt


Set password to protect your zip file:

$ zip test_zip -e -r test_zip/



In case, you forgot set a password to your Zip file then you can use `zipcloak` command by following:

$ zipcloak test_zip



Note: If you do not want zip command writes log to console, please use -q option.

Unzip a Zip file with the unzip command

If you want to extract a Zip file to current directory:

$ unzip test_zip


or you can extract to a target directory:

$ unzip test_zip -d /path/to/target/directory



Using these commands can help you quickly zip a Zip file and unzip it. To read more useful options, you should use man zip or man unzip.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s