{"id":21477,"date":"2023-09-30T12:26:35","date_gmt":"2023-09-30T12:26:35","guid":{"rendered":"https:\/\/linuxways.net\/?p=21477"},"modified":"2023-09-30T12:26:35","modified_gmt":"2023-09-30T12:26:35","slug":"how-do-i-extract-tar-xz-in-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-do-i-extract-tar-xz-in-ubuntu-22-04\/","title":{"rendered":"How Do I Extract tar.xz in Ubuntu 22.04?"},"content":{"rendered":"<p>In <strong>Ubuntu <\/strong>and other distros, files are compressed to reduce storage space consumption. Compressed or zipped files make it easy to transfer files at high speed. Once transferred or stored, these compressed files (in many cases the \u201c<strong>tar.xz<\/strong>\u201d files), need to be extracted so that users can access the data or files inside.<\/p>\n<p>This article explains how you can extract \u201ctar.xz\u201d files in Ubuntu.<\/p>\n<h2><strong>How do I Extract tar.xz in Ubuntu 22.04?<\/strong><\/h2>\n<p>The \u201ctar.xz\u201d files are easily extracted in Ubuntu System using the \u201ctar\u201d command which is a built-in command in Ubuntu to manage the file system. Below are the steps explained to extract the \u201ctar.xz\u201d file in Ubuntu.<\/p>\n<h3><strong>Step 1: Open Terminal<\/strong><\/h3>\n<p>Open the terminal in Ubuntu using the GUI. Hover your mouse pointer over the \u201cShow Applications\u201d icon and then click on it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" class=\"wp-image-21478\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-1.png 1920w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-1-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-1-1024x576.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-1-768x432.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-1-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>The Applications Menu opens and on the top of the screen, you will see the Search Bar. Search for the application you want to filter. In our case, we will search for \u201cTerminal\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1776\" height=\"419\" class=\"wp-image-21480\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-2.png 1776w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-2-300x71.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-2-1024x242.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-2-768x181.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-2-1536x362.png 1536w\" sizes=\"auto, (max-width: 1776px) 100vw, 1776px\" \/><\/p>\n<p>Click on the Terminal to Open it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"229\" class=\"wp-image-21481\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-3.png 736w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-3-300x93.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/p>\n<p>You can also use the shortcut key \u201c<strong>ctrl+alt+t<\/strong>\u201d to open the Terminal Directly:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1514\" height=\"460\" class=\"wp-image-21482\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-4.png 1514w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-4-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-4-1024x311.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-4-768x233.png 768w\" sizes=\"auto, (max-width: 1514px) 100vw, 1514px\" \/><\/p>\n<h3><strong>Step 2: Navigate to the File Directory<\/strong><\/h3>\n<p>Navigate to the directory having the \u201ctar.xz\u201d file using the \u201ccd\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">cd<\/span> <span class=\"sy0\">&lt;<\/span>directory<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, the \u201ctar.xz\u201d file is located in the Downloads folder:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1660\" height=\"241\" class=\"wp-image-21483\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-5.png 1660w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-5-300x44.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-5-1024x149.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-5-768x111.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-5-1536x223.png 1536w\" sizes=\"auto, (max-width: 1660px) 100vw, 1660px\" \/><\/p>\n<p>To navigate to the Downloads Directory from the Terminal, the cd command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">cd<\/span> Downloads<\/div><\/div>\n<p>The command line will now have the Downloads path meaning the Directory is accessed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"122\" class=\"wp-image-21484\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-6.png 735w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-6-300x50.png 300w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/p>\n<p>The \u201cls\u201d command can be used to list the files and folders in the directory. To confirm if the command line moved to the Downloads path, use the ls command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span><\/div><\/div>\n<p>This will list the files in the Downloads Directory and you can see the \u201ctar.xz\u201d file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"112\" class=\"wp-image-21485\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-7.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-7-300x46.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<h3><strong>Step 3: Extract the \u201ctar.xz\u201d File<\/strong><\/h3>\n<p>Once you are in the directory, you can use the \u201ctar\u201d command to extract the files inside the same directory:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xf<\/span> <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, the file name is \u201ctarred.tar.xz\u201d. To extract the \u201ctarred.tar.xz\u201d file, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xf<\/span> tarred.tar.xz<\/div><\/div>\n<p>The \u201c-xf\u201d flag is used to extract the files of the same archive. The \u201ctarred.tar.xz\u201d file will be extracted and the extracted files will now be available in the same directory, in our case, the \u201cfileA.txt\u201d and the \u201cfileB.txt\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1206\" height=\"520\" class=\"wp-image-21486\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-8.png 1206w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-8-300x129.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-8-1024x442.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-8-768x331.png 768w\" sizes=\"auto, (max-width: 1206px) 100vw, 1206px\" \/><\/p>\n<h2><strong>Extracting a Specific File from the Tar File<\/strong><\/h2>\n<p>To extract only a single or specific file using the \u201ctar\u201d command, the command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">tar<\/span> <span class=\"sy0\">&lt;<\/span>options<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">&lt;<\/span>tar-file<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">&lt;<\/span>file-to-extract<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, to extract only the \u201cfileA.txt\u201d from the \u201ctarred.tar.xz\u201d file, the command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xf<\/span> tarred.tar.xz fileA.txt<\/div><\/div>\n<p>This will only extract the \u201cfileA.txt\u201d from the \u201ctarred.tar.xz\u201d file instead of extracting all the files:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1276\" height=\"469\" class=\"wp-image-21487\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-9.png 1276w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-9-300x110.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-9-1024x376.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-9-768x282.png 768w\" sizes=\"auto, (max-width: 1276px) 100vw, 1276px\" \/><\/p>\n<h2><strong>Bonus Step: Untar or Compress the Files<\/strong><\/h2>\n<p>The \u201ctar\u201d command can also be used to Compress or untar files and directories. To Compress files or directories the command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">tar<\/span> <span class=\"sy0\">&lt;<\/span>tar.xz-fileName<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">&lt;<\/span>files<span class=\"sy0\">\/<\/span>folder-to-compress<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, we have the \u201cfileA.txt\u201d and folder \u201cHello\u201d inside the Downloads Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1662\" height=\"244\" class=\"wp-image-21488\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-10.png 1662w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-10-300x44.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-10-1024x150.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-10-768x113.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-10-1536x226.png 1536w\" sizes=\"auto, (max-width: 1662px) 100vw, 1662px\" \/><\/p>\n<p>To compress the \u201cfileA.txt\u201d and the folder \u201cHello\u201d into a \u201ctar.xz\u201d file, the tar command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">tar<\/span> cfj Compr.tar.xz fileA.txt Hello<\/div><\/div>\n<p>The \u201ccfj\u201d command will create a new archive file. The new \u201cCompr.tar.xz\u201d file will be created and it will compress the \u201cfileA.txt\u201d and \u201cHello\u201d inside it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1241\" height=\"534\" class=\"wp-image-21489\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-11.png 1241w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-11-300x129.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-11-1024x441.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21477-11-768x330.png 768w\" sizes=\"auto, (max-width: 1241px) 100vw, 1241px\" \/><\/p>\n<p>That\u2019s all about extracting tar.xz in Ubuntu 22.04.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The \u201ctar\u201d command is a useful way of extracting files in Ubuntu. It can be used to extract multiple files inside the \u201ctar.xz\u201d file or can extract specific files as well according to the user&#8217;s requirements. The \u201ctar\u201d command can compress files as well into a \u201ctar.xz\u201d file. This article explained the different methods to extract \u201ctar.xz\u201d files and also to compress files into a \u201ctar.xz\u201d file.<\/p>","protected":false},"excerpt":{"rendered":"<p>The \u201ctar\u201d Command is used to extract multiple files inside the \u201ctar.xz\u201d file, it can extract specific files as well and compress files into a \u201ctar.xz\u201d file.<\/p>","protected":false},"author":110,"featured_media":21479,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-21477","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21477","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=21477"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21477\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21479"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}