{"id":21995,"date":"2023-10-01T05:11:02","date_gmt":"2023-10-01T05:11:02","guid":{"rendered":"https:\/\/linuxways.net\/?p=21995"},"modified":"2023-10-01T05:11:26","modified_gmt":"2023-10-01T05:11:26","slug":"how-to-zip-files-and-directories-in-linux-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-zip-files-and-directories-in-linux-ubuntu\/","title":{"rendered":"\u200b\u200bHow to Zip Files and Directories in Linux\/Ubuntu?"},"content":{"rendered":"<p><strong>Files<\/strong> are compressed into <strong>archives<\/strong> resulting in conservation of storage space and bandwidth. Software packages are usually available to download in compressed archives from the software developer\u2019s website. Compressed archives save time by enabling faster downloading. There are many archive formats for data compression. <strong>\u201c.zip\u201d<\/strong> is a popular archive format as it is cross platform compatible. \u201c.zip\u201d uses the \u201c<strong>DEFLATE<\/strong>\u201d compression algorithm.<\/p>\n<p>This article will demonstrate compressing data i.e., files and directories using .zip archive format on Linux\/Ubuntu 22.04 LTS. This article will discuss:<\/p>\n<ul>\n<li>How to Zip Files\/Directories in Ubuntu 22.04 Terminal?<\/li>\n<li>How to Zip Files\/Directories in Ubuntu Using 22.04 GUI?<\/li>\n<\/ul>\n<h2><a id=\"post-21995-_3um0xoaznvnc\"><\/a>How to Zip Files\/Directories in Ubuntu 22.04 Terminal?<\/h2>\n<p>The following sections will discuss creating Zip Archives from multiple files, single and multiple directories by using the command line:<\/p>\n<h2><a id=\"post-21995-_vwi4ezl9toa3\"><\/a>How to Zip Files in Ubuntu 22.04 via Terminal?<\/h2>\n<p>\u201c<strong>Zip\u201d <\/strong>command is used to compress files via Terminal. For example, files File1, File2, File3, File4, and File5 can be compressed to create a zipped archive \u201cCompressedFile.zip\u201d by executing the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">zip<\/span> CompressedFile.zip <span class=\"sy0\">*<\/span>.txt<\/div><\/div>\n<p>The above command comprises of:<\/p>\n<ul>\n<li>zip: tar command line tool.<\/li>\n<li>CompressedFile.zip: Name of compressed archive.<\/li>\n<li>*.txt: selects all the txt files present in the directory.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"679\" class=\"wp-image-21996\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-1.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-1-300x99.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-1-1024x340.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-1-768x255.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-1-1536x509.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>From the above image, it can be seen that File1.txt, File2.txt, File3.txt, File4.txt, and File5.txt are compressed to form a zip archive, i.e., \u201cCompressedFile.zip\u201d archive.<\/p>\n<h2><a id=\"post-21995-_3cbpnoqd2msr\"><\/a>How to Zip a Directory\/Folder in Ubuntu 22.04 via Terminal?<\/h2>\n<p>A single Directory is compressed to a zip archive by launching the terminal and executing the <strong>zip<\/strong> command. For example, a directory \u201cScreenshots\u201d can be compressed to create a zipped archive \u201cCompressedFolder.zip\u201d by executing the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">zip<\/span> <span class=\"re5\">-r<\/span> CompressedFolder.zip Screenshots<\/div><\/div>\n<p>The above command comprises of:<\/p>\n<ul>\n<li>zip: tar command line tool<\/li>\n<li>-r: flag for directory<\/li>\n<li>CompressedFolder.zip: Name of compressed archive<\/li>\n<li>Screenshots: Name of Directory to be compressed<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1207\" class=\"wp-image-21997\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2-300x177.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2-1024x604.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2-768x453.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2-1536x905.png 1536w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-2-1020x600.png 1020w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>From the above image, it can be seen that the directory \u201cScreenshots\u201d is compressed to a zip archive, i.e., \u201cCompressedFolder.zip\u201d.<\/p>\n<h2><a id=\"post-21995-_g0gpwwom4uj3\"><\/a>How to Zip Multiple Directories in Ubuntu 22.04 via Terminal?<\/h2>\n<p>\u201c<strong>Zip\u201d <\/strong>command is used to compress multiple directories via Terminal. For example, directories: Directory1, Directory2, and Directory3 can be compressed to create a zipped archive \u201cCompressedFile.zip\u201d by executing the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">zip<\/span> <span class=\"re5\">-r<\/span> CompressedFile.zip Directory1 Directory2 Directory3<\/div><\/div>\n<p>The above command comprises of:<\/p>\n<ul>\n<li>zip: tar command line tool<\/li>\n<li>-r: flag for directory<\/li>\n<li>CompressedFile.zip: Name of compressed archive<\/li>\n<li>Directory1, Directory2, Directory 3: Name of Directories to be compressed<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"924\" class=\"wp-image-21998\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-3.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-3-300x135.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-3-1024x462.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-3-768x347.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-3-1536x693.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>From the above image, it can be seen that the directories, Directory1, Directory2, and Directory3 are compressed to a zip archive, i.e., \u201cCompressedFile.zip\u201d.<\/p>\n<h2><a id=\"post-21995-_xvlr6ujhsk5q\"><\/a>How to Zip Files\/Directories in Ubuntu 22.04 Using GUI?<\/h2>\n<p>Files and Directories are compressed with ease with just a few clicks using Linux\/Ubuntu GUI. The following sections discuss creating Zip Archives from multiple files, and single and multiple directories:<\/p>\n<h2><\/h2>\n<h2><a id=\"post-21995-_mlysfc2jkfcq\"><\/a>How to Zip Files in Ubuntu 22.04 Using GUI?<\/h2>\n<p>Multiple Files can be compressed into a <strong>zip archive<\/strong> by selecting all files by either a keyboard or a mouse and then selecting \u201cCompress\u201d from the right-click drop-down menu:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"942\" class=\"wp-image-21999\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-4.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-4-300x138.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-4-1024x471.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-4-768x353.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-4-1536x707.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>This will redirect to the \u201c<strong>Create Archive<\/strong>\u201d window where we can insert the <strong>Archive name<\/strong> and select <strong>.zip<\/strong> format to compress the file in .zip format. Finally, we can press the <strong>Create<\/strong> button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1866\" height=\"1106\" class=\"wp-image-22000\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-5.png 1866w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-5-300x178.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-5-1024x607.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-5-768x455.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-5-1536x910.png 1536w\" sizes=\"auto, (max-width: 1866px) 100vw, 1866px\" \/><\/p>\n<p>Then click on the Create button to create a zip archive file \u201c<strong>CompressedFile.zip<\/strong>\u201d from the selected files, i.e., File1, File2, File3, File4, and File5.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1866\" height=\"1102\" class=\"wp-image-22001\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-6.png 1866w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-6-300x177.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-6-1024x605.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-6-768x454.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-6-1536x907.png 1536w\" sizes=\"auto, (max-width: 1866px) 100vw, 1866px\" \/><\/p>\n<h2><a id=\"post-21995-_d4h9xqt20vcg\"><\/a>How to Zip a Directory\/Folder in Ubuntu 22.04 Using GUI?<\/h2>\n<p>A directory can be compressed into a <strong>zip archive<\/strong> by selecting the directory with either a keyboard or a mouse and then selecting \u201cCompress\u201d from the right-click drop-down menu:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2004\" height=\"1102\" class=\"wp-image-22002\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-7.png 2004w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-7-300x165.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-7-1024x563.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-7-768x422.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-7-1536x845.png 1536w\" sizes=\"auto, (max-width: 2004px) 100vw, 2004px\" \/><\/p>\n<p>This will redirect to the \u201c<strong>Create Archive<\/strong>\u201d window where we can insert the <strong>Archive name<\/strong> and select <strong>.zip<\/strong> format to compress the file in .zip format. Finally, we can press the <strong>Create<\/strong> button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"998\" height=\"516\" class=\"wp-image-22003\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-8.png 998w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-8-300x155.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-8-768x397.png 768w\" sizes=\"auto, (max-width: 998px) 100vw, 998px\" \/><\/p>\n<p>Then click the <strong>Create <\/strong>button to create a zip archive file \u201c<strong>CompressedFile.zip<\/strong>\u201d from the selected directory, i.e., \u201cScreenshots\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1866\" height=\"1100\" class=\"wp-image-22004\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9.png 1866w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9-300x177.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9-1024x604.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9-768x453.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9-1536x905.png 1536w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-9-1020x600.png 1020w\" sizes=\"auto, (max-width: 1866px) 100vw, 1866px\" \/><\/p>\n<h2><a id=\"post-21995-_v7c05550tz9n\"><\/a>How to Zip Multiple Directories\/Folders in Ubuntu 22.04 Using GUI?<\/h2>\n<p>Multiple directories can be compressed into a <strong>zip archive <\/strong>by selecting the directories with either a keyboard or a mouse and then by selecting \u201cCompress\u201d from the right-click drop-down menu:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1102\" class=\"wp-image-22005\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-10.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-10-300x161.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-10-1024x551.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-10-768x413.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-10-1536x827.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>This will lead us to the \u201c<strong>Create Archive<\/strong>\u201d window where we can insert the <strong>Archive name<\/strong> and select the <strong>.zip<\/strong> format to compress the selected directories in .zip format.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"518\" class=\"wp-image-22006\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-11.png 1002w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-11-300x155.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-11-768x397.png 768w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/p>\n<p>Finally, click on the Create button to create a zip archive file \u201c<strong>CompressedDirectory.zip<\/strong>\u201d of the selected directories, i.e., Directory1, Directory2, and Directory3.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1868\" height=\"1106\" class=\"wp-image-22007\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-12.png 1868w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-12-300x178.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-12-1024x606.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-12-768x455.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-21995-12-1536x909.png 1536w\" sizes=\"auto, (max-width: 1868px) 100vw, 1868px\" \/><\/p>\n<h2><a id=\"post-21995-_k4r3ojha6hv3\"><\/a>Conclusion<\/h2>\n<p>Files and Directories can be compressed to a zip archive with ease with the command line as well as GUI. Files can be compressed using \u201c<strong>zip &lt;archivename&gt; &lt;file1&gt; &lt;file2&gt;<\/strong>\u201d. Similarly, single and multiple directories can be compressed by using \u201c<strong>zip -r &lt;archivename&gt; &lt;Directory&gt;<\/strong>\u201d and \u201c<strong>zip -r &lt;archivename&gt; &lt;Directory1&gt; &lt;Directory2&gt;<\/strong>\u201d. This article has demonstrated the process of compressing files and directories using .zip archive format on Linux\/Ubuntu 22.04 LTS by command line as well as by GUI.<\/p>","protected":false},"excerpt":{"rendered":"<p>Files and Directories can be compressed to zip archive with ease with the command line as well as GUI by \u201czip <archive> <files>\u201d and \u201czip -r <archive> <directories>\u201d. <\/p>","protected":false},"author":110,"featured_media":22008,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1049,2],"tags":[],"class_list":["post-21995","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21995","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21995"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21995\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/22008"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}