How to Use Unix Zip Command

In this tutorial we will show you how to use the unix zip command. Over here, we will also encrypt the zip files through the terminal application only.
The zip command compresses the file while encrypting it. You can even unzip the file later on by entering its command.
To understand how to use the unix zip commands better, follow the tutorial below.


Step 1 – Open the directory

First of all, let’s move to the desktop and list the contents of the directory. Over here, you can see one file being displayed here.

List the directory contents

Step 2 – Zip your file and enter password

Now let’s zip the file. For that, let’s type the command
“zip –e 1.zip 1” and hit enter. This command actually means you are zipping the file while encrypting it, assigning the new name as 1.zip and providing the source file name which, in our case, is one.
Now you would be required to type the password twice, hitting enter each time.
With that done, you would get a message that your file has been stored.

Enter zip command and type in password

Step 3 – Unzip the file

For uncompressing a zip file, you can use the unzip command. For that, simply write “unzip”, space, and the name of the file which in this case is “1.zip”
Since the file is encrypted, you will be required to type in the password.

Enter the unzip command

Step 4 – Type “R” to rename file

With that done, you will be asked if you would like to replace or rename the file. This is because in our case, the exact same file is already present on the desktop, that’s why it prompted us with this particular request. Over here, let’s rename the file being unzipped. For that, type “r” and hit enter. This is the file that we had previously zipped using the unix zip command.

Press “R” to rename file

Step 5 – Rename the unzipped file

With that done, you will be required to type the name of the new file.
The file will now be extracted. Now let’s list the contents of the directory and there you can see the new file which has been extracted.
And that’s it, through these unix zip commands given above you can compress a folder while encrypting it.

Rename the file