Linux Zip Folder
This is how you zip a folder in Linux. Make sure that you use the -r flag otherwise it will not include any of the actual contents of the directory. This example will place a copy of the folder inside the zip file. It doesn’t just copy the contents of that dir in to the file. This is nice because when you unzip it you will be given the folder instead of just dumping a pile of random files in to the current directory.
zip -r folder1.zip folder1
To unzip a folder on Linux use the following command. This will unzip the folder in the current directory.
If you want to specify a directory to unzip the file to you can do that with the ‘-d’ option like this.
unzip folder1.zip -d new
This will unpack your file into the directory ‘new’. The directory will be created if it doesn’t exist. If your zip file contains a directory that will also be placed inside the new specified directory. Here is how the folder structure might look.
new/folder1 new/folder1/test1.txt new/folder1/test2.txt new/folder1/test3.txt
Install Zip Command on Ubuntu Linux and Red Hat
The zip command may or may not be installed on your system. It wasn’t installed by default on the version of Ubuntu Server that we tested.
Here is how you can install it on Ubuntu and probably Debian.
sudo apt update sudo apt install zip
You can use this command to install it on Red Hat.
sudo yum install zip unzip -y sudo yum install unzip unzip -y
For Fedora and newer versions of Red Hat you can use the following to install the zip command:
sudo dnf install zip sudo dnf install unzip
To install the zip command on Manjaro or Arch Linux you can use the following:
sudo pacman -S zip sudo pacman -S unzip
Here is a video showing how to zip a folder on Linux: