{"id":832,"date":"2026-10-29T12:04:31","date_gmt":"2026-10-29T09:04:31","guid":{"rendered":"https:\/\/blog.officesupport.ru\/?p=832"},"modified":"2026-10-29T12:04:31","modified_gmt":"2026-10-29T09:04:31","slug":"untar-command-in-linux","status":"publish","type":"post","link":"https:\/\/blog.officesupport.ru\/?p=832","title":{"rendered":"untar Command in Linux"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> tar -xvf archive.tar<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code><strong>-x<\/strong><\/code><\/strong>: It extract files from the archive<\/li>\n\n\n\n<li><strong><code><strong>-v<\/strong><\/code><\/strong>: It is used for verbose mode which shows the extraction process<\/li>\n\n\n\n<li><strong><code><strong>-f<\/strong><\/code><\/strong>: It specifies the archive file<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Use the Untar Command<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Extract a<\/strong> <strong><code><strong>.tar<\/strong><\/code><\/strong> <strong>File<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This takes out all the files and puts them into the current folder.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -xvf filename.tar<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Extract a<\/strong> <strong><code><strong>.tar.gz<\/strong><\/code><\/strong> <strong>(Gzipped Tarball) File<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The -z flag is added to process files that are compressed with gzip.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> tar -xzvf filename.tar.gz<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Extract a<\/strong> <strong><code><strong>.tar.bz2<\/strong><\/code><\/strong> <strong>(Bzip2 Compressed) File<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The -j flag is added to process files compressed with bzip2.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>tar -xjvf filename.tar.bz2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Extract to a Specific Directory<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using the command below, the extraction can be redirected to a different folder using option -C.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>tar -xvf filename.tar -C \/path\/to\/directory<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Extract Specific Files from an Archive<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Only file1.txt and file2.txt will be extracted from the archive.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>tar -xvf filename.tar file1.txt file2.txt<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. List Contents of a Tar File Without Extracting<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This retrieves the contents of the archive without extracting it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>tar -tvf filename.tar<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Advanced Tar Options<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Linux has the tar command that provides multiple advanced options for improving file archiving and extraction processes. With these options, users can extract individual files, manage compressed archives, and guide extractions into designated directories with ease. Learning these options is important to manage.tar,.tar.gz, and.tar.bz2 files properly.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Option<\/th><th class=\"has-text-align-center\" data-align=\"center\">Description<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-x<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Extract files from the archive<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-v<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Display extraction details<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-f<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Specify archive filename<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-z<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Handle gzip-compressed archives<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-j<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Handle bzip2-compressed archives<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-C<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Extract to a specified directory<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>-t<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">List files inside an archive<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong><code><strong>--wildcards<\/strong><\/code><\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Extract files using patterns<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Troubleshooting Common Issues<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">While extracting files with the tar command on Linux using the command line could give the user a tough time, here are some common errors and ways to fix them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. &#171;Permission Denied&#187; Error<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you do not have the requisite permission to extract a file, then to execute the command try using the <strong>sudo<\/strong> option alongside the command. use the below command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo tar -xvf filename.tar<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. &#171;No such file or directory&#187; Error<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The problem arises as soon as the designated archive file could not be tracked down in the current working directory. Use the below command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ls -l filename.tar<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. &#171;Archive File Corrupted&#187; Error<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before trying to extract files from an archive, always check to see if the archive is damaged. When damaged, try to do the following:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ntar -tvf filename.tar\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a href=\"https:\/\/www.geeksforgeeks.org\/linux-unix\/untar-command-in-linux\/\">https:\/\/www.geeksforgeeks.org\/linux-unix\/untar-command-in-linux\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax: tar -xvf archive.tar How to Use the Untar Command 1. Extract a .tar File This takes out all the files and puts them into the current folder. tar -xvf filename.tar 2. Extract a .tar.gz (Gzipped Tarball) File The -z [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-832","post","type-post","status-publish","format-standard","hentry","category-bsd","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=\/wp\/v2\/posts\/832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=832"}],"version-history":[{"count":2,"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":834,"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions\/834"}],"wp:attachment":[{"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.officesupport.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}