Zip all file linux

How Do I Zip All Files In A Directory In Linux?

The zip is a utility to compress files and directories with no data loss. It is also used as a file package utility, and all distributions of Linux support it. The zip file is useful when you have low bandwidth for sending data between 2 servers; the user can zip the file and send it. It consumes less storage which will make them easy to store and transfer.

This article will demonstrate the methods to zip all files in a directory. The content for the post is as follows:

  • Installation of zip
  • How to zip Files in Linux?
  • Method 1: Zip All Files in a Directory Through CLI
  • Method 2: Zip All Files in a Directory Through GUI

Installation of zip

In most Linux distributions, it comes with pre-installation, but users can also install it manually. Use the following command depending on the distribution:

For Debian/Ubuntu:

For CentOS/RHEL:

To verify whether the zip utility is installed or not, run the zip command with “–version”:

Zip version 3.0 is installed in the operating system.

The syntax for the zip command is given below:

Читайте также:  Xerox 5016 драйвер linux

Syntax

$ zip [File_Name.zip] [Source_File/Directory]

Type the “zip” keyword, the file name with .zip extension, and then the source file/directory name.

How do zip Files in Linux?

For a better understanding of zipping any files in Linux, check out the examples below:

Example 1: Zipping a File

We have a “date.txt” file in our home directory. Let’s zip it using the zip utility. Run the given command in the terminal:

The date.txt file is zipped with the name date.zip. Furthermore, the zip command has also displayed the percentage of compression.

Example 2: Zipping Multiple Files

To zip the multiple files, type the file using the zip utility as follows:

$ zip All_Files.zip file1.txt file2.txt file3.txt

All the files have been compressed and stored in the “All_Files.zip”.

Method 1: Zip All Files in a Directory Through CLI

For compressing all the files in the directory, check out the implementation of the example below.

Example 1: Compressing the Directory Including All files

To compress all files present in the directory, use the “r” flag, which will compress the entire directory, including its files:

$ sudo zip -r Files.zip /Henry

The directory will be compressed including all files.

Let’s check the created zip file for the directory.

The zip file with the name “Files.zip” has been created.

Example 2: Compressing the Directory Including All files to Another Directory

To compress the entire directory to the specified directory you can specify the path before the zip file name. Run the given command in the terminal:

$ sudo zip -r /home/itslinuxfoss/Desktop/Files.zip Henry

The directory has been compressed to the “Desktop” directory.

Let’s verify it using the “ls” command:

The zip file is present in the “Desktop” directory.

Читайте также:  Настройка сети через командную строку линукс

Method 2: Zip All Files in a Directory Through GUI

For zipping all files in Directory, the GUI method is also available. Just right-click on the specific directory which you want to compress and click on the “compress” option from the drop-down:

Once you click on the compress option it will ask you to enter the name of the zip file and choose the “.zip” extension from the given drop-down. After that, click on the create button as shown in the below image:

The zip file will be created which can be seen in the following screenshot:

That’s how all files in a directory are zipped in Linux.

Conclusion

In Linux, zip is a utility to compress files or directories without changing their data. To zip all the files in a directory user can use the “r” flag in the command or zip the directory manually by right-clicking and hitting the “compress” option. This write-up has briefly illustrated the method to zip files and directories using the zip utility.

Источник

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.

Читайте также:  Windows 10 exploit kali linux

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.

Источник

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