{"id":873,"date":"2009-10-29T17:53:00","date_gmt":"2009-10-29T16:53:00","guid":{"rendered":"http:\/\/it4bus.vn\/itersdesktop\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/"},"modified":"2014-01-27T23:43:01","modified_gmt":"2014-01-27T16:43:01","slug":"compression-and-decompression-in-ubuntu","status":"publish","type":"post","link":"https:\/\/www.itersdesktop.com\/vi\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/","title":{"rendered":"Compression and Decompression in Ubuntu"},"content":{"rendered":"<div dir=\"ltr\"><a href=\"http:\/\/linux.dsplabs.com.au\/tar-how-to-create-and-extract-tar-gz-and-bz2-compressed-archives-under-linux-p39\/\">This is a presentation of tar:<\/a> <a href=\"http:\/\/indiapoly.com\/content\/linux-file-compression-and-archiving-with-gzip-zip-and-tar-compressing-with-gzip-and-zip.htm\">Linux: File Compression and Archiving with gzip, zip, rar, tar, unzip&#8230;<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a0195272bf57\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a0195272bf57\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.itersdesktop.com\/vi\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/#cac-file-luu-tru-doi-khi-goi-la-file-nen-tren-he-thong-unixlinux-thuong-phan-mo-rong-la-targz-hoac-tgz-co-the-duoc-trich-xuat-bung-nen-%e2%80%93-extract-bang-mot-lenh-don-gian\" >C\u00e1c file l\u01b0u tr\u1eef (\u0111\u00f4i khi g\u1ecdi l\u00e0 file n\u00e9n) tr\u00ean h\u1ec7 th\u1ed1ng UNIX\/Linux (th\u01b0\u1eddng ph\u1ea7n m\u1edf r\u1ed9ng l\u00e0 tar.gz ho\u1eb7c .tgz) c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c tr\u00edch xu\u1ea5t (bung n\u00e9n &#8211; extract) b\u1eb1ng m\u1ed9t l\u1ec7nh \u0111\u01a1n gi\u1ea3n.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.itersdesktop.com\/vi\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/#vi-du-de-bung-mot-file-luu-tru-nen-ten-la-targettargz-vao-thu-muc-hien-hanh-ta-dung-lenh\" >V\u00ed d\u1ee5: \u0110\u1ec3 bung m\u1ed9t file l\u01b0u tr\u1eef n\u00e9n t\u00ean l\u00e0 target.tar.gz v\u00e0o th\u01b0 m\u1ee5c hi\u1ec7n h\u00e0nh, ta d\u00f9ng l\u1ec7nh:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.itersdesktop.com\/vi\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/#neu-file-duoc-nen-voi-chuan-bzip2-ie-tarbz2-chung-ta-co-the-thay-the-gzip-bang-lenh-bzip2\" >N\u1ebfu file \u0111\u01b0\u1ee3c n\u00e9n v\u1edbi chu\u1ea9n bzip2 (i.e., .tar.bz2), ch\u00fang ta c\u00f3 th\u1ec3 thay th\u1ebf gzip b\u1eb1ng l\u1ec7nh bzip2.<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.itersdesktop.com\/vi\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/#extract-trgz-file\" >Extract tr.gz. file<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.itersdesktop.com\/vi\/2009\/10\/29\/compression-and-decompression-in-ubuntu\/#extracting-an-entire-archive\" >Extracting an Entire Archive<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"cac-file-luu-tru-doi-khi-goi-la-file-nen-tren-he-thong-unixlinux-thuong-phan-mo-rong-la-targz-hoac-tgz-co-the-duoc-trich-xuat-bung-nen-%e2%80%93-extract-bang-mot-lenh-don-gian\"><\/span>C\u00e1c file l\u01b0u tr\u1eef (\u0111\u00f4i khi g\u1ecdi l\u00e0 file n\u00e9n) tr\u00ean h\u1ec7 th\u1ed1ng UNIX\/Linux (th\u01b0\u1eddng ph\u1ea7n m\u1edf r\u1ed9ng l\u00e0 <span>tar.gz<\/span> ho\u1eb7c <span>.tgz<\/span>) c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c tr\u00edch xu\u1ea5t (bung n\u00e9n &#8211; extract) b\u1eb1ng m\u1ed9t l\u1ec7nh \u0111\u01a1n gi\u1ea3n.<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h4><span class=\"ez-toc-section\" id=\"vi-du-de-bung-mot-file-luu-tru-nen-ten-la-targettargz-vao-thu-muc-hien-hanh-ta-dung-lenh\"><\/span><span><i><b>V\u00ed d\u1ee5: <\/b><\/i>\u0110\u1ec3 bung m\u1ed9t file l\u01b0u tr\u1eef n\u00e9n t\u00ean l\u00e0 <span>target.tar.gz<\/span> v\u00e0o th\u01b0 m\u1ee5c hi\u1ec7n h\u00e0nh, ta d\u00f9ng l\u1ec7nh:<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<blockquote><p>gzip -dc target.tar.gz | tar xf &#8211; tar xvzf target.tar.gz<\/p><\/blockquote>\n<div>\n<h4><span class=\"ez-toc-section\" id=\"neu-file-duoc-nen-voi-chuan-bzip2-ie-tarbz2-chung-ta-co-the-thay-the-gzip-bang-lenh-bzip2\"><\/span><code><span>N\u1ebfu file \u0111\u01b0\u1ee3c n\u00e9n v\u1edbi chu\u1ea9n <span>bzip2<\/span> (i.e., <span>.tar.bz2<\/span>), ch\u00fang ta c\u00f3 th\u1ec3 thay th\u1ebf gzip b\u1eb1ng l\u1ec7nh bzip2.<\/span> <\/code><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><span>N\u1ebfu file n\u00e9n v\u1edbi l\u1ec7nh n\u00e9n c\u1ee7a UNIX (ph\u1ea7n m\u1edf r\u1ed9ng l\u00e0 .z) th\u00ec ch\u00fang ta d\u00f9ng l\u1ec7nh sau:<\/span><\/p>\n<div><b><span><code>zcat target.tar.Z | tar xf -<\/code><\/span><\/b><\/div>\n<p><code><span><span>N\u1ebfu n\u00e9n \u1edf d\u1ea1ng *.tar.xz th\u00ec:<\/span><\/span><\/code> <code><span><span>tar Jxf *.tar.xz ho\u1eb7c d\u00f9ng unxz -z: \u0111\u1ec3 n\u00e9n, v\u00e0 -d \u0111\u1ec3 gi\u1ea3i n\u00e9n.<\/span><\/span><\/code> <code><span><span>Hy v\u1ecdng v\u1edbi t\u00f3m t\u1eaft n\u00e0y s\u1ebd l\u00e0 n\u01a1i \u0111\u1ec3 tham kh\u1ea3o qu\u00fd b\u00e1u.<\/span><\/span><\/code> <span>Q.<\/span> How do I extract tar.gz file under Linux \/ UNIX like operating systems? <span>A. <\/span> tar.gz is nothing but compressed tar archive. The tar program provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use Tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored. Initially, tar archives were used to store files conveniently on magnetic tape. The name &#8220;Tar&#8221; comes from this use; it stands for tape archiver. Despite the utility&#8217;s name, Tar can direct its output to available devices, files, or other programs (using pipes), it can even access remote devices or files (as archives).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"extract-trgz-file\"><\/span>Extract tr.gz. file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To extract one or more members from an archive, enter: <code>tar -zxvf {<span>file.tar.gz<\/span>}<\/code> If your tarball name is backup.tar.gz, enter the following at a shell prompt: <code>tar -zxvf backup.tar.gz<\/code><\/p>\n<h3><span class=\"ez-toc-section\" id=\"extracting-an-entire-archive\"><\/span>Extracting an Entire Archive<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To extract an entire archive, specify the archive file name only, with no individual file names as arguments. <code>tar -zxvf backup.tar.gz<\/code> <code> <\/code><code>tar xjvf cornbread.tar.bz2<\/code> <code> <\/code><code><span>N\u1ebfu ch\u1ec9 l\u00e0 .bz2 th\u00f4i th\u00ec:<\/span><\/code> <span>bunzip2 spankythefish.bz2<\/span> <span>Chu\u1ea9n n\u00e9n 7z<\/span> <span>C\u00e0i \u0111\u1eb7t:\u00a0<\/span><span>sudo apt-get install p7zip<\/span> <span>Bung n\u00e9n:\u00a0p7zip -d filename.7z<\/span> <span>Chu\u1ea9n n\u00e9n rar<\/span> <span>D\u00f9ng rar ho\u1eb7c unrar<\/span> <span>Chu\u1ea9n n\u00e9n zip<\/span> <span>zip v\u00e0 unzip.<\/span><\/div>\n<div><\/div>\n<div>tar [z|j]cvf<\/div>\n<div>tar zcvf\u00a0\/mnt\/tmp\/blahblah.tgz \/home\/user<\/div>\n<div>tar -cpzf \/mnt\/tmp\/user.tgz\u00a0\/home\/user<\/div>\n<div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a presentation of tar: Linux: File Compression and Archiving with gzip, zip, rar, tar, unzip&#8230; C\u00e1c file l\u01b0u tr\u1eef (\u0111\u00f4i khi g\u1ecdi l\u00e0 file n\u00e9n) tr\u00ean h\u1ec7 th\u1ed1ng&hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[174,3,176],"tags":[275,276,267,270,273,274,268,570,272,269,271,277],"class_list":["post-873","post","type-post","status-publish","format-standard","hentry","category-linux","category-tools","category-ubuntu","tag-7z","tag-bz2","tag-compression","tag-decompression","tag-gz","tag-rar","tag-tar","tag-ubuntu","tag-unrar","tag-unzip","tag-z","tag-zip"],"_links":{"self":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts\/873","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/comments?post=873"}],"version-history":[{"count":3,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts\/873\/revisions"}],"predecessor-version":[{"id":1311,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts\/873\/revisions\/1311"}],"wp:attachment":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/media?parent=873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/categories?post=873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/tags?post=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}