How to Zip files online on Linux
When you need to generate a.zip archive on a Linux system, it is not always as simple as it is on a Windows system. Every time you need to download a big number of files or do several operations, or even make a backup of a website, you should master a few simple commands for zipping and unzipping folders in Linux. We happen to use the zip command to compress archive files. It is a utility for compression and file packaging. We also have a program called unzip that is used to unpack the zip archives. This tutorial will help you learn to compress and manage a folder on Ubuntu Linux using the command line.
Zip is most likely one of the most used compression algorithms available.Zip, created by Philip Katz in 1989, is frequently used by system administrators to minimise the size of large files and directories on your system.Zip is now accessible on all major operating systems, including Windows, Linux, and MacOS.
The folder should be zipped or compressed
To compress files, we must first instal the zip command, which we will do using “apt command” or “apt-get command.” So, let’s use the terminal and instal the zip command.
The first step is to - To instal the zip command, enter the terminal and type “sudo apt instal zip unzip.”
Enter the necessary credentials.
Sometimes, when you need to create a .zip archive on a Linux machine, it is not that much easy as it is in windows. Every time, you need to download a larger number of files or numerous tasks, or even when you need a backup for a website, you need to learn few basic commands for zipping and unzipping the folders in Linux. For compression of archive files, we happen to use the zip command. It is a utility for compression and file packaging. We also have a program called unzip that is used to unpack the zip archives. This tutorial will help you learn to compress and manage a folder on Ubuntu Linux using the command line.
Zip or compress the folder
For the purpose of compression, we need to install the zip command at first, for which we will use “apt command” or “apt-get command”. So, now we will open the terminal to install the zip command.
Step 1:
After opening the terminal, write the command, “sudo apt install zip unzip” to install the zip command.
Enter the required credentials.
The installation begins and the command line looks like this. After a few moments, it will be done.
Step 2: The next step is to use the zip command to compress the necessary files. We wish to compress the TestDir folder, whose current directory is Desktop.
You can effortlessly move data between operating systems and conserve disc space by using zip. In this lesson, we’ll look at how to use the zip command to effortlessly zip files and directories on Linux.
So, therefore in command line in Linux, we will also change our current directory to the desktop.
We can see the currently present folders on our Desktop by using ls command.
The file we want to compress is also in the list.
We use the command “zip –r folderName folder” to compress the folder.
Eventually, the compressed TestDirTerminal.zip is created, which we wanted to create by compressing our folder TestDir, so as we can see it has been created.
The folder that we wanted to compress has already been compressed.
Step three: In Linux, we may also compress the files using the command line. As you can see, we’ve picked a folder called TestFolder and a file called TestFile for this purpose. Both may be found on the Desktop once more. In this stage, we will compress a file and a folder.
If we haven’t already done so, we’ll change our current directory to Desktop. After that, we use the “dir” command to view the directory’s items. Anything of importance is included where TestFolder and TestFile are also included.
For the sake of zipping the folder, we will use the following command.
This will zip our TestFile.
Once created, both the TestFile and Testfolder.zip can be seen at the Desktop.
Using gzip command
We can also use gzip command to compress a file as we did with the GroceryList.
The outcome shows that a GroceryList.gz has been created at the Desktop directory.
Using tar command
For too many files we will use tar command. Here we have GroceryList so, for this we will be using tar cvf
C: Create
V: to display the output in the terminal (used for verification)
F: Just for fire options
We can always use the ls command for the verification Here, as you can see the GroceryList.tar has been created.
Unzip the zipped folder as follows:
The command unzip will be used to unzip the file. But first, just like we did with zipping, we must instal the unzip code. For this, we execute the command sudo apt-get instal unzip. The command is used as follows:
Enter the credentials:
This will be installed eventually. You may see the following commands on the screen while you run it on our own end.
For the zip command
First, we’ll extract our files to make zip files. So, as you can see in the above list, the first sample we compressed is listed as compressed file “TestDirTerminal.zip,” and we will now compress this file using the unzip command. In this field, enter unzip and the name of the zipped file to be unzipped.
In this tutorial, we have seen how to create compressed folders/ files in Linux command line. We have also learned how to extract the original files from the compressed ones in Linux command line.
Using zip, create a folder
The simplest approach to zip a folder on Linux is to use the “zip” command with the “-r” option and provide the archive file as well as the folders to be included in your zip file.
If you wish to compress numerous directories in your zip file, you can specify several folders. For example, let’s say that you want to archive a folder named “Documents” in a zip file named “temp.zip”.
In order to achieve that, you would run the following command
In order to check if your zip file was created, you can run the “ls” command and look for your archive file.
Alternatively, if you are not sure where you stored your zip files before, you can search for files using the find command.
Using zip, create a folder
The simplest approach to zip a folder on Linux is to use the “zip” command with the “-r” option and provide the archive file as well as the folders to be included in your zip file.
If you wish to compress numerous directories in your zip file, you can specify several folders.
This approach is quite handy since you may archive folders recursively or only a specific level of directories in your archive.
Using the Desktop Interface to Zip a Folder
If you’re using GNOME or KDE, there’s also an option to effortlessly compress your files.
KDE Dolphin may be used to compress folders.
You will be able to traverse your folder if you are using the KDE Graphical Interface.
Select “Dolphin – File Manager” from the drop-down menu.
Now that Dolphin is open, pick the zipped folders by holding down the “Control” key and left-clicking on the folders to be compressed together.
Now that folders are selected, right-click wherever you want and select the “Compress” option.
When hovering your mouse cursor over the “Compress” option and select the “Here (as ZIP)” option in the menu.
After a quick time, depending on the size of your archive, your zip should be created with all the folders you have selected in it.
Congratulations, you have successfully made a zip file for your Linux files!
GNOME Folder Compression
If you use GNOME, for example, on Debian 10 or CentOS 8, you will be able to compress your files straight from the user interface.
Search for “Files” under the “Applications” option in the upper left corner of your Desktop.
Select the “Files” option : your file explorer should start automatically.
Now that you are in your file explorer, select multiple folders by holding the “Control” key and left-clicking on all the folders to be zipped.
When you’re finished, right-click and select “Compress.”
Now that you’ve selected the “Compress” option, a popup box should open asking for the filename of your zip as well as the extension to be used.
When you are done, simply click the “Create” option for your zip file to be created.
That’s all there is to it! Your folders should now be packed into an archive file, and you can begin emailing it or extracting the files contained inside it.
Conclusion
In this tutorial, you learnt how you can easily create zip files for your folders on Linux.