Compressing files and folders is an effective way to save disk space and simplify file transfer tasks. By bundling together various files and directories into a single compressed file, users can better manage, store, and share their data.
Most Linux distributions come with built-in tools for compression and decompression, and one of the most widely recognized is the zip utility. The zip format is universal and supported across different operating systems, including Windows, macOS, and of course, Linux.
Whether you're aiming to share a group of files with a colleague, backup your data, or just reduce clutter, zip is a dependable and easy-to-use tool.
$ cd /path/to/directory/
$ zip output_filename.zip file_or_folder_name
If compressing multiple items, you can separate them with spaces. For example:
$ zip documents.zip file1.txt file2.txt folder1/
$ zip -r output_foldername.zip folder_name/
This will include all files and sub-folders inside the specified folder in the compressed file.
$ ls -lh
You should see the .zip file listed among the other files.
$ unzip -l output_filename.zip
This displays the list of files and directories inside the compressed file.
$ unzip output_filename.zip
Ensure you have sufficient disk space before extracting large zip files.
By following these steps, users can seamlessly create zip archives in Linux, making file management and sharing both efficient and hassle-free.
Comment anonymously. Login not required.