Zipping folders in linux

How to Zip and Unzip a directory and its files in Linux [duplicate]

I am a newbie in Linux.Whats is the complete process to zip and unzip a directory and its files.Please mention if any installation has to be done.

3 Answers 3

You say you are a newbie. Maybe you got Windows-experiences. If you do not have the packages installed yet, you need to

sudo apt-get install zip gzip tar 

first (or by a graphical pkg-manager).

Then, for an entry it would be the easiest way to use zip/unzip:

zip -r my_arch.zip my_folder 

Zip stores relative path names by default. There are several parameter-options available for zip. For that read: the manual (man zip). For a starting this will do.

Most often you will see .tar.gz endings in linux-world. That’s the product of two tools: TAR (the tape archiver) and GZIP (the GNU-Zip). Tar has got the call option to automatically gzip/gunzip files after «taring».

tar -cvzf may_arch.tar.gz my_folder 
  • -c means «create»
  • -v means «verbose» (sometimes bothersome and slowing down. )
  • -z means «use (GNU)zip»
  • -f XYZ declares the name of the output file. (You should chose a helping name like XYZ.tar.gz)

There may also be .tar.bz2 endings. This is the product of the -j parameter instead of the -z parameter: you will choose compression with BZIP2 (-> man bzip2).

To extract you simply use -x (eXtract) instead of -c (Create):

You can use the zip and unzip command line utilities. These can be installed by running

sudo apt-get install zip unzip 

I know several ways, but since you’re new on linux. So I’ll tell you how to zip a file using GUI method (the easiest way).

enter image description here

  1. Create a new folder and fill it with anything you want, for example many of file (In my case, I’ll fill it with theme folder) :

enter image description here

  1. Right click the folder you want to zip and select «Compress. » option : enter image description here
  2. You can choose which file format you want by clicking combobox next to «Filename» textbox. Also you can set the folder you want to zip location. enter image description here

enter image description here

Clicking «Other options» will lead you to password section, in other word you can set password for your preferred file so someone (include you) have to enter password before unzip the file.

Читайте также:  Path shared object linux

Источник

How to Zip Files and Folders in Linux

This quick tip shows you how to create a zip folder in Ubuntu and other Linux distributions. Both terminal and GUI methods have been discussed.

Zip is one of the most popular archive file format out there. With zip, you can compress multiple files into one file. This not only saves disk space, it also saves network bandwidth. This is why you’ll encounter zip files almost all the time. As a normal user, mostly you’ll unzip files in Linux. But how do you zip a folder in Linux? This article helps you answer that question. Prerequisite: Verify if zip is installed Normally zip support is installed but no harm in verifying. Open a terminal and use the following command:

If you see some details on the zip version, you have zip installed already. If it displays ‘zip command not found’, you can run the below command to install zip and unzip support in Ubuntu and Debian based distributions.

sudo apt install zip unzip

Now that you know your system has zip support, you can read on to learn how to zip a directory in Linux.

Zip a folder in Linux Command Line

zip [option] output_file_name input1 input2

While there could be several options, I don’t want you to confuse with them. If your only aim is to create a zip folder from a bunch of files and directories, use the command like this:

zip -r output_file.zip file1 folder1
zip -r myzip abhi-1.txt abhi-2.txt sample_directory adding: abhi-1.txt (stored 0%) adding: abhi-2.txt (stored 0%) adding: sample_directory/ (stored 0%) adding: sample_directory/newfile.txt (stored 0%) adding: sample_directory/agatha.txt (deflated 41%)

You can use the -e option to create a password protect zip folder in Linux. You are not always restricted to the terminal for creating zip archive files. You can do that graphically as well. Here’s how!

Zip a folder in Linux Using GUI

Though I have used Ubuntu here, the method should be the same in other distributions using GNOME or other desktop environments.

If you want to compress a file or folder in desktop Linux, it’s just a matter of a few clicks. Go to the folder where you have the desired files (and folders) you want to compress into one zip folder. Here, select the files and folders. Now, right-click and select Compress. You can do the same for a single file as well. Creating zip file in UbuntuNow you can create a compressed archive file in zip , tar xz or 7z format. In case you are wondering, all three are various compression algorithms that you can use for compressing your files. Give it the name you desire and click on Create. Compress a zip folder in UbuntuIt shouldn’t take long and you should see an archive file in the same directory. Zip file created in Ubuntu LinuxWell, that’s it. You successfully created a zip folder in Linux. The next step is to learn to unzip a zipped file in the Linux command line. I hope this quick little tip helped you with the zip files. Please feel free to share your suggestions.

Читайте также:  Linux исполняемые файлы elf

Источник

How to ZIP a Folder in Linux

Folder compression is a great way to organize data on your machine while saving storage. Here’s how you can add folders to a zip archive in Linux.

Zipper over a folder with linux penguin logo

Readers like you help support MUO. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

ZIP is a highly useful archive file format that helps in storage and file management. With an efficient zipping utility in tow, you can share multiple files and folders efficiently by combining them into one single file.

In Linux, zipping a folder saves a lot of space and network bandwidth. Since its development in 1989, ZIP has become one of the preferred ways to compress data and reduce the file size.

Using some native commands like zip, you too can zip a folder on Linux-based systems with ease.

How to Install zip on Linux

Most of the time, you won’t find the zip utility installed on your Linux system by default. To install zip, you can use your distribution’s default package manager.

Install zip on CentOS and Fedora using:

On Arch Linux and Manjaro:

Run the following command to install zip on OpenSUSE:

How Does the Zipping Process Work?

As soon as the zip command is invoked, the utility starts scanning the files specified in the input. In case the scan takes more than five seconds, the zip command will display the message: Scanning files.

The interesting part is, how you as a user, can understand what’s happening in the backend. If the output displays progress dots at an interval of every two seconds, it means the files are being processed.

If the time lapsed is more than two seconds, it means either the command is taking time to locate the files or the network connection is slow. In case zip is not able to locate a specific file, it will issue a warning, but still, continue to process your request.

Читайте также:  Узнать версию сервера линукс

Finally, in case some files are skipped during the process, the command will issue a warning at the end, telling you how many files it processed and how many it skipped.

Zipping a Folder Using the Command Line

Use the following command syntax to zip folder(s):

zip -r outputfile folder1 folder2 folder3 

. where outputfile is the name of the archive and folder1, folder2, and folder3 are the absolute or relative path to the folders.

Let’s try to archive the data folder in a zip file named temp.zip. To do so, run this command:

After running the aforementioned command, use the Is command to confirm the creation of the archive.

If the zip command determines the file size is too big, it will store the file as it is within the archive, without compressing it.

Specifying Compression Levels

You can specify the compression method using the -Z flag.

zip -r -Z bzip2 archivename.zip directory_name 

The output will show the compression levels of each file added to the archive.

Additionally, you can specify the compression levels by using numbers ranging from zero to nine. The default value is -6; however, use -0 to store files without compression. On the other hand, -9 will force the zip command to use an optimal compression for all the files within the archive.

zip -9 -r archivename.zip directory_name 

Zipping a Folder Using find

To zip a folder with an unknown path, you can use the find command effectively. Firstly pipe find to the exec command so that you can execute the zip command for the creation of an archive.

For zipping folders present in the current working directory, run this command:

find . –maxdepth 1 type d –exec zip archive.zip <> + 

Using this option is quite helpful as you get the flexibility for choosing archive folders recursively. You can also choose to have a certain level of folders zipped into your archive.

Using the GUI for Zipping Folders

Mostly every desktop environment within Linux includes a way to zip files. Even though this guide focuses on Ubuntu, rest assured, the procedure will be similar for other Linux distros as well.

To create a compressed (zipped) file using the graphical user interface, launch your system’s file manager application from the Applications menu.

Once the window opens up, select the folders you would like to compress. To select multiple folders, keep the Ctrl key pressed while clicking on the folders.

Источник

Оцените статью
Adblock
detector