How to Make a Zip File in Linux

Zip files are one of the primary file types for archiving and compressing multiple files into one directory.  All operating systems have the ability to make Zip files, and you can easily do this in Linux as well. This minHour article teaches you how to make and unzip a zip file in Linux/UNIX/Mac.

Using the Terminal

Press Ctrl+Alt+T to open the Terminal.

The Terminal is where you can enter command-line functions in Linux. It is available in all Linux distributions. Press to open the Terminal.

  • On most Linux distributions that have a graphical user interface, you can open the terminal by opening the Apps menu and clicking on the icon that resembles a black screen with a white text cursor.

Install Zip.

Zip does not come pre-installed on all Linux distributions, type the following command and press to install Zip on Linux:

  • Ubuntu and Debian: sudo apt install zip
  • CentOS and Fedora: sudo yum install zip.

Navigate to the folder that contains the file or folder you want to zip.

To do so, type cd followed by the path that contains the file or folder. and press .

  • For example, if the file you want to zip is in your “Documents” folder, you would type cd Documents and press Enter.

Type zip zip_file.zip file1 file2 file3 and press Enter.

Replace “zip_file.zip” with the name of the zip file you want to create. Replace “file1,” “file2,” and “file3” with the names of the files or folders you want to compress into a zip file. Then press .

  • This command will not work if there is a space in the file name or folder you want to zip.
  • You can add as many files and folders to the end of the command as you want.
  • Add -r after “zip” in the command to include all subfolders in a folder to the zip file. For example zip -r zipfile.zip folder
  • Add -e after “zip” in the command to add a password to the zip file. You will then be asked to enter and verify a password.

Type unzip zip_file.zip and press ↵ Enter to unzip a file.

Replace “zip_file.zip” with the actual name of the zip file.

Using the Graphical User Interface

Open the Files app.

Each distribution of Linux is a little bit different. These steps may be a little different on your Linux distribution but should be fairly similar. Click the icon that resembles a folder to open the Files app or whichever file browser app you are using.

Navigate to the file or folder that you want to zip.

You can zip an entire folder or an individual file. Use the file browser to navigate to the file or folder you want to compress into a zip file.

Right-click the file or folder you want to zip.

This displays a context menu.

Click Compress.

It’s in the context menu. On some Linux distributions, this might say “Archive,” “Zip,” or something similar.

Type the name of the zip file you want to create.

Enter the name of the file you want to create in the space below “Archive Name.”

  • Some Linux distributions may use a default name instead of allowing you to enter a name for the file you are creating.

Click the radio option next to “Zip.

It’s the first option below the field with the archive name.

  • Alternatively, you can select “.tar.xz,” which is a compressed archive format used by LInux computers. You can also select “.7z,” which is a 7-zip file. 7-zip is an open-source version of Winzip.

Click Create.

It’s either in the upper-right corner or lower-right corner of the dialogue box. On some distributions, this may say “Ok” or something similar. This creates a zip file of the file or folder.

Warnings

  • If you zip up a file, change it, and then try to unzip it up, it will ask you if you want to replace the modified file with the file in the zip file.

Leave a Comment