Skip to content

How to Zip and Unzip a file in Linux?

As simple a task it is, zipping and unzipping a file in Linux can be a completely different task. Unlike windows, you don’t really get a clickable interface to simply zip/unzip a file. Instead, you have to take the terminal way.

Now, this not to say that you can’t zip/unzip files in Linux as easily as you can in Windows. In fact, most modern Linux distributions come with some sort of zip/unzip file reader preinstalled. However, when you don’t have access to a GUI, for example on a server running Linux, knowing how to zip/unzip a file using the terminal can be a lifesaver.

Also read: What is kernel in Linux?

How to zip a file in Linux

Step 1: Open up the terminal on your Linux distribution and navigate to the same directory as the files you want to compress.

Step 2: Type in the following command – zip [filename.zip] [file1] [file2] [file3]How to Zip and Unzip a file in Linux? | Candid.TechnologyIn case you want to put all files in the directory into one zip file, write – zip filename *
In case you want to put all directories inside a directory in a zip file, write — zip filename -r

And that’s it. That’s how you zip a file in Linux.

How to unzip a file in Linux

Unzipping a file is a very similar process to zipping it.

Step 1: Open up the terminal on your Linux distribution and navigate to the same directory as the files you want to compress.

Step 2: Type in the following command — unzip [filename]

How to Zip and Unzip a file in Linux? | Candid.Technology

Troubleshooting

If you run across an error along these lines –

-bash: zip: command not found

It means that the zip utility isn’t installed on your system. This usually won’t happen, but if you’re running a very old Linux distro or if you haven’t updated your system in quite some time or you’ve seriously broken something, you can run into such errors.

To resolve this, use the apt-get or yum command as follows

For Debian/Ubuntu:
sudo apt-get install zip

For Red Hat Linux/Fedora/CentOS:
sudo yum install zip

Also read: 9 reasons why developers tend to choose Linux over Windows

Hello There!

If you like what you read, please support our publication by sharing it with your friends, family and colleagues. If you're running an Adblocker, we humbly request you to whitelist us.

Share on facebook
Share on whatsapp
Share on twitter
Share on reddit
Share on linkedin
Share on pocket
Share on pinterest
Share on telegram
Share on stumbleupon
Share on digg
Share on tumblr
Share on email
Share on delicious
Share on skype







>