Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compress files and folders with zip in Linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to zip compressed files and folders in Linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Zip is one of the * archive file formats. With zip, you can compress multiple files into one file. This saves not only disk space, but also network bandwidth. That's why you almost always see zip files.

As a regular user, most of the time you will unzip the folder in Linux. But how to compress folders in Linux? This article can help you answer this question.

Prerequisites: verify that zip is installed

Usually zip is installed, but there is no harm in verifying it. You can run the following command to install zip and unzip. If it is not already installed, it will be installed immediately.

Sudo apt install zip unzip

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

Compress folders on the Linux command line

The syntax of the zip command is very simple.

Zip [option] output_file_name input1 input2

Although there are several options, I don't want you to confuse them. If you just want to turn a pile of files into a zip folder, use the following command:

Zip-r output_file.zip file1 folder1

The-r option recurses the directory and compresses its contents. The .zip extension in the output file is optional because .zip is added by default.

You should see the files to be added to the compressed folder during the zip operation.

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 password-protected zip folders in Linux.

You don't have to create zip archives only through the terminal. You can also do this graphically. How to do the following!

Use GUI to compress folders in Ubuntu Linux

Although I use Ubuntu here, the approach should be basically the same in other distributions that use GNOME or other desktop environments.

If you want to compress a file or folder on your Linux desktop, you only need to click a few times.

Go to the folder where you want to compress the files (and folders) into a zip folder.

Here, select the files and folders. Now, right-click and select compress. You can also do the same for a single file.

Select the files, right click and click compress

You can now create a compressed archive using zip, tar xz, or 7z format. If you're curious, these three are all kinds of compression algorithms, and you can use them to compress files.

Enter a name you want and click "create".

Create archive file

This won't take long, and you'll see an archive file in the same directory.

All right, that's it. You have successfully created a zip folder in Linux.

The above is the editor for you to share how to zip compressed files and folders in Linux, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report