{"id":476,"date":"2024-04-08T05:45:00","date_gmt":"2024-04-08T05:45:00","guid":{"rendered":"https:\/\/ale.newby.work\/?p=476"},"modified":"2024-04-08T05:45:02","modified_gmt":"2024-04-08T05:45:02","slug":"how-do-i-compress-a-whole-linux-or-unix-directory","status":"publish","type":"post","link":"https:\/\/ale.newby.work\/?p=476","title":{"rendered":"How do I Compress a Whole Linux or UNIX Directory?"},"content":{"rendered":"\n<p>Q.\u00a0How can I compress a whole directory under Linux \/ UNIX using a shell prompt?<\/p>\n\n\n\n<p>A.&nbsp;It is very easy to compress a Whole Linux\/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:<br>=&gt; Create the archive<br>=&gt; Compress the archive<\/p>\n\n\n\n<p>You need to use tar command as follows (syntax of tar command):<br><strong>tar -zcvf archive-name.tar.gz directory-name<\/strong><br><\/p>\n\n\n\n<p>Where,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>-z: Compress archive using gzip program<\/li>\n\n\n\n<li>-c: Create archive<\/li>\n\n\n\n<li>-v: Verbose i.e display progress while creating archive<\/li>\n\n\n\n<li>-f: Archive File name<\/li>\n<\/ul>\n\n\n\n<p>For example, you have directory called \/home\/jerry\/prog and you would like to compress this directory then you can type tar command as follows:<br><code>$ tar -zcvf prog-1-jan-2005.tar.gz \/home\/jerry\/prog<\/code><\/p>\n\n\n\n<p>Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory):<br><code>$ tar -zxvf prog-1-jan-2005.tar.gz<\/code><\/p>\n\n\n\n<p>Where,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>-x: Extract files<\/li>\n<\/ul>\n\n\n\n<p>If you wish to extract files in particular directory, for example in \/tmp then you need to use following command:<br><code>$ tar -zxvf prog-1-jan-2005.tar.gz -C \/tmp<br>$ cd \/tmp<br>$ ls -<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q.\u00a0How can I compress a whole directory under Linux \/ UNIX using a shell prompt?&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/ale.newby.work\/?p=476\">Read the post<span class=\"screen-reader-text\">How do I Compress a Whole Linux or UNIX Directory?<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-476","post","type-post","status-publish","format-standard","hentry","category-general","excerpt","zoom","full-without-featured","even","excerpt-0"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How do I Compress a Whole Linux or UNIX Directory? - ALE @ Newby.Work<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ale.newby.work\/?p=397\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How do I Compress a Whole Linux or UNIX Directory? - ALE @ Newby.Work\" \/>\n<meta property=\"og:description\" content=\"Q.\u00a0How can I compress a whole directory under Linux \/ UNIX using a shell prompt?&#8230;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ale.newby.work\/?p=397\" \/>\n<meta property=\"og:site_name\" content=\"ALE @ Newby.Work\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-08T05:45:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-08T05:45:02+00:00\" \/>\n<meta name=\"author\" content=\"chris.newby\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"chris.newby\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ale.newby.work\\\/?p=397#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ale.newby.work\\\/?p=397\"},\"author\":{\"name\":\"chris.newby\",\"@id\":\"https:\\\/\\\/ale.newby.work\\\/#\\\/schema\\\/person\\\/e42e06d6eac4394cf94b9d610c81b027\"},\"headline\":\"How do I Compress a Whole Linux or UNIX Directory?\",\"datePublished\":\"2024-04-08T05:45:00+00:00\",\"dateModified\":\"2024-04-08T05:45:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ale.newby.work\\\/?p=397\"},\"wordCount\":224,\"articleSection\":[\"General\"],\"inLanguage\":\"en-AU\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ale.newby.work\\\/?p=397\",\"url\":\"https:\\\/\\\/ale.newby.work\\\/?p=397\",\"name\":\"How do I Compress a Whole Linux or UNIX Directory? - ALE @ Newby.Work\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ale.newby.work\\\/#website\"},\"datePublished\":\"2024-04-08T05:45:00+00:00\",\"dateModified\":\"2024-04-08T05:45:02+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ale.newby.work\\\/#\\\/schema\\\/person\\\/e42e06d6eac4394cf94b9d610c81b027\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ale.newby.work\\\/?p=397#breadcrumb\"},\"inLanguage\":\"en-AU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ale.newby.work\\\/?p=397\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ale.newby.work\\\/?p=397#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ale.newby.work\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How do I Compress a Whole Linux or UNIX Directory?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ale.newby.work\\\/#website\",\"url\":\"https:\\\/\\\/ale.newby.work\\\/\",\"name\":\"ALE @ Newby.Work\",\"description\":\"Phone system things\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ale.newby.work\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-AU\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ale.newby.work\\\/#\\\/schema\\\/person\\\/e42e06d6eac4394cf94b9d610c81b027\",\"name\":\"chris.newby\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-AU\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4fdb11a55edd13be2a46ccc78c7b6af81e5dcebb84f925d4b8e748a862ab1fb9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4fdb11a55edd13be2a46ccc78c7b6af81e5dcebb84f925d4b8e748a862ab1fb9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4fdb11a55edd13be2a46ccc78c7b6af81e5dcebb84f925d4b8e748a862ab1fb9?s=96&d=mm&r=g\",\"caption\":\"chris.newby\"},\"sameAs\":[\"https:\\\/\\\/ale.newby.work\"],\"url\":\"https:\\\/\\\/ale.newby.work\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How do I Compress a Whole Linux or UNIX Directory? - ALE @ Newby.Work","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ale.newby.work\/?p=397","og_locale":"en_US","og_type":"article","og_title":"How do I Compress a Whole Linux or UNIX Directory? - ALE @ Newby.Work","og_description":"Q.\u00a0How can I compress a whole directory under Linux \/ UNIX using a shell prompt?&#8230;","og_url":"https:\/\/ale.newby.work\/?p=397","og_site_name":"ALE @ Newby.Work","article_published_time":"2024-04-08T05:45:00+00:00","article_modified_time":"2024-04-08T05:45:02+00:00","author":"chris.newby","twitter_card":"summary_large_image","twitter_misc":{"Written by":"chris.newby","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ale.newby.work\/?p=397#article","isPartOf":{"@id":"https:\/\/ale.newby.work\/?p=397"},"author":{"name":"chris.newby","@id":"https:\/\/ale.newby.work\/#\/schema\/person\/e42e06d6eac4394cf94b9d610c81b027"},"headline":"How do I Compress a Whole Linux or UNIX Directory?","datePublished":"2024-04-08T05:45:00+00:00","dateModified":"2024-04-08T05:45:02+00:00","mainEntityOfPage":{"@id":"https:\/\/ale.newby.work\/?p=397"},"wordCount":224,"articleSection":["General"],"inLanguage":"en-AU"},{"@type":"WebPage","@id":"https:\/\/ale.newby.work\/?p=397","url":"https:\/\/ale.newby.work\/?p=397","name":"How do I Compress a Whole Linux or UNIX Directory? - ALE @ Newby.Work","isPartOf":{"@id":"https:\/\/ale.newby.work\/#website"},"datePublished":"2024-04-08T05:45:00+00:00","dateModified":"2024-04-08T05:45:02+00:00","author":{"@id":"https:\/\/ale.newby.work\/#\/schema\/person\/e42e06d6eac4394cf94b9d610c81b027"},"breadcrumb":{"@id":"https:\/\/ale.newby.work\/?p=397#breadcrumb"},"inLanguage":"en-AU","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ale.newby.work\/?p=397"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ale.newby.work\/?p=397#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ale.newby.work\/"},{"@type":"ListItem","position":2,"name":"How do I Compress a Whole Linux or UNIX Directory?"}]},{"@type":"WebSite","@id":"https:\/\/ale.newby.work\/#website","url":"https:\/\/ale.newby.work\/","name":"ALE @ Newby.Work","description":"Phone system things","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ale.newby.work\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-AU"},{"@type":"Person","@id":"https:\/\/ale.newby.work\/#\/schema\/person\/e42e06d6eac4394cf94b9d610c81b027","name":"chris.newby","image":{"@type":"ImageObject","inLanguage":"en-AU","@id":"https:\/\/secure.gravatar.com\/avatar\/4fdb11a55edd13be2a46ccc78c7b6af81e5dcebb84f925d4b8e748a862ab1fb9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4fdb11a55edd13be2a46ccc78c7b6af81e5dcebb84f925d4b8e748a862ab1fb9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4fdb11a55edd13be2a46ccc78c7b6af81e5dcebb84f925d4b8e748a862ab1fb9?s=96&d=mm&r=g","caption":"chris.newby"},"sameAs":["https:\/\/ale.newby.work"],"url":"https:\/\/ale.newby.work\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/ale.newby.work\/index.php?rest_route=\/wp\/v2\/posts\/476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ale.newby.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ale.newby.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ale.newby.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ale.newby.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=476"}],"version-history":[{"count":1,"href":"https:\/\/ale.newby.work\/index.php?rest_route=\/wp\/v2\/posts\/476\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/ale.newby.work\/index.php?rest_route=\/wp\/v2\/posts\/476\/revisions\/477"}],"wp:attachment":[{"href":"https:\/\/ale.newby.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ale.newby.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ale.newby.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}