{"id":400,"date":"2009-12-06T09:29:54","date_gmt":"2009-12-06T13:29:54","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=400"},"modified":"2014-08-05T05:31:21","modified_gmt":"2014-08-05T09:31:21","slug":"tar-untar-zip-unzip-gzip-and-extract-files-on-linux","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/tar-untar-zip-unzip-gzip-and-extract-files-on-linux","title":{"rendered":"How to create archives and compressed files?"},"content":{"rendered":"<p><strong>How to create a .tar, .tar.gz and .tar.bz2 file?<\/strong><\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong># tar -cf example.tar example<br \/>\n# tar -zcf example.tar.gz example<br \/>\n# tar -jcf example.tar.bz2 example<\/strong><\/span><\/p><\/blockquote>\n<p><span style=\"color: #0000ff;\"><strong>root@server [~]# ll<br \/>\ndrwxr-xr-x\u00a0 2 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0 4096 Dec\u00a0 6 07:02 example\/<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0 30720 Dec\u00a0 6 08:11 example.tar<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 912 Dec\u00a0 6 08:11 example.tar.bz2<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 659 Dec\u00a0 6 08:11 example.tar.gz<\/strong><\/span><\/p>\n<p><strong>How to extract a .tar, .tar.gz and .tar.bz2 file?<\/strong><\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong># tar -xf example.tar<br \/>\n# tar -zxf example.tar.gz<br \/>\n# tar -jxf example.tar.bz2<\/strong><\/span><\/p><\/blockquote>\n<p>If you use &#8216;v&#8217; switch in the above examples, it will display detail message during the command execution.<\/p>\n<p><strong>How to compress a file using zip, gzip and bzip2?<\/strong><\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong># zip file.zip file<br \/>\n# gzip file<br \/>\n# bzip2 file<\/strong><\/span><\/p><\/blockquote>\n<p><span style=\"color: #0000ff;\"><strong>root@server [~]# ll<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 14 Dec\u00a0 6 08:16 file.bz2<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 25 Dec\u00a0 6 08:15 file.gz<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0 140 Dec\u00a0 6 08:15 file.zip<\/strong><\/span><\/p>\n<p><strong>How to extract zip, gzip and bzip2 compressed files?<\/strong><\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong># unzip file.zip<br \/>\n# gunzip file.gz<br \/>\n# bzip2 -d file.bz2<\/strong><\/span><\/p><\/blockquote>\n<p>With gunzip and bzip2, the files will be extracted but you will no longer have the compressed file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to create a .tar, .tar.gz and .tar.bz2 file?<br \/>\n# tar -cf example.tar example<br \/>\n# tar -zcf example.tar.gz example<br \/>\n# tar -jcf example.tar.bz2 example<br \/>\nroot@server [~]# ll<br \/>\ndrwxr-xr-x\u00a0 2 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0 4096 Dec\u00a0 6 07:02 example\/<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0 30720 Dec\u00a0 6 08:11 example.tar<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 912 Dec\u00a0 6 08:11 example.tar.bz2<br \/>\n-rw-r&#8211;r&#8211;\u00a0 1 root\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 659 Dec\u00a0 6 08:11 example.tar.gz<br \/>\nHow to extract a .tar, .tar.gz and .tar.bz2 file?<br \/>\n# tar -xf example.tar<br \/>\n# tar -zxf example.tar.gz<br \/>\n# tar -jxf example.tar.bz2<br \/>\nIf you use &#8216;v&#8217; switch in the above examples, it will display detail message during the command [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[531,534,526,532,525,530,527,533,528,529],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/400"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=400"}],"version-history":[{"count":7,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":2363,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions\/2363"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}