How To Zip A Folder In Linux

Whether you’re trying to save space or simply want to make files easier to send, you’ll often find yourself needing to compress or decompress files. In this blog post, we’ll learn how to zip and unzip files in the Linux operating system. Most Linux distributions come with pre-installed utilities for compressing/decompressing files. We’ll be using the zip and unzip commands in our examples.

How to Zip a Folder in Linux

To zip a folder in Linux, you will use the zip command. The basic format is as follows:

    zip -r filename.zip foldername/
    

Here, -r tells the zip command to traverse the directory structure recursively and include all files and subfolders. The filename.zip is the name of the compressed file you want to create, and foldername/ is the directory you want to compress.

Compress Multiple Folders into a Single zip File

If you want to compress multiple folders into a single zip file, use the command:

    zip -r filename.zip folder1/ folder2/
    

In this case, both folder1/ and folder2/ will be compressed into filename.zip.

Unzipping a Folder in Linux

To unzip a folder in Linux, you’ll use the unzip command. The basic format is:

    unzip filename.zip
    

This will extract the contents of filename.zip into the current directory.

Conclusion

Now you know how to zip and unzip files in Linux using the zip and unzip commands. These are powerful tools that can help you manage your files more effectively. Remember to replace the placeholders in the examples with the actual names of your files and folders.