{"id":21602,"date":"2023-09-30T16:10:47","date_gmt":"2023-09-30T16:10:47","guid":{"rendered":"https:\/\/linuxways.net\/?p=21602"},"modified":"2023-09-30T16:10:47","modified_gmt":"2023-09-30T16:10:47","slug":"how-to-extract-a-tar-bz2-file-in-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-extract-a-tar-bz2-file-in-ubuntu\/","title":{"rendered":"How to Extract a Tar.bz2 File in Ubuntu?"},"content":{"rendered":"<p>Files in Ubuntu can often occupy more space and it usually makes file management a hectic task for administrators dealing with multiple files. Ubuntu offers the \u201ctar\u201d command for file management which can compress multiple files into one single file for easy management and file sharing. Those compressed archive files can then be extracted with the \u201ctar\u201d command once required.<\/p>\n<p>In this article, the extracting process of the \u201ctar.bz2\u201d file in Ubuntu is explained.<\/p>\n<h2><strong>How to Extract a Tar.bz2 File in Ubuntu?<\/strong><\/h2>\n<p>The \u201ctar\u201d command is used widely in Ubuntu for file management. With the \u201ctar\u201d command, you can compress a file and can also uncompress\/decompress or extract an archive file. The steps below explain the extraction process of the \u201ctar.bz2\u201d file.<\/p>\n<h3><strong>Step 1: Open Terminal<\/strong><\/h3>\n<p>Open the terminal by clicking on the \u201cApplication Menu\u201d icon on the bottom left of the Home Screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" class=\"wp-image-21603\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-1.png 1920w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-1-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-1-1024x576.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-1-768x432.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-1-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>In the Application Menu, you will see the \u201csearch bar\u201d box on top of the menu:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"976\" height=\"352\" class=\"wp-image-21604\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-2.png 976w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-2-300x108.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-2-768x277.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/p>\n<p>Click on the Search Box and type the application you want to search. In our case, Terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1235\" height=\"439\" class=\"wp-image-21605\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-3.png 1235w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-3-300x107.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-3-1024x364.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-3-768x273.png 768w\" sizes=\"auto, (max-width: 1235px) 100vw, 1235px\" \/><\/p>\n<p>Click on the Terminal Icon to Run the Terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"739\" height=\"214\" class=\"wp-image-21606\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-4.png 739w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-4-300x87.png 300w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/p>\n<p>Instead of going to the Application Menu and searching for Terminal, you can open the terminal directly using the \u201cctrl+alt+t\u201d shortcut key:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1514\" height=\"460\" class=\"wp-image-21607\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-5.png 1514w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-5-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-5-1024x311.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-5-768x233.png 768w\" sizes=\"auto, (max-width: 1514px) 100vw, 1514px\" \/><\/p>\n<h3><strong>Step 2: Navigate to the Directory containing the \u201ctar.bz2\u201d File<\/strong><\/h3>\n<p>Open the \u201ctar.bz2\u201d file directory with 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-path<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, the \u201ctar.bz2\u201d file is in the Documents Directory. To navigate to the Documents Directory, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">cd<\/span> Documents<\/div><\/div>\n<p>The Path in Terminal will change to the Documents Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"100\" class=\"wp-image-21608\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-6.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-6-300x41.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<p>Inside the Directory, you can see the \u201ctar.bz2\u201d file by listing the files in the directory using the 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>The \u201ctararchive\u201d file can be seen in the terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1326\" height=\"324\" class=\"wp-image-21609\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-7.png 1326w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-7-300x73.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-7-1024x250.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-7-768x188.png 768w\" sizes=\"auto, (max-width: 1326px) 100vw, 1326px\" \/><\/p>\n<h3><strong>Step 3: Extract the \u201ctar.bz2\u201d File<\/strong><\/h3>\n<p>The tar command extracts the \u201ctar.bz2\u201d file by using the below command:<\/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>fileName<span class=\"sy0\">&gt;<\/span>.tar.bz2<\/div><\/div>\n<p>In our case, the filename is \u201ctararchive\u201d. Thus to extract the file, the tar command used 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> <span class=\"re5\">-xjf<\/span> tararchive.tar.bz2<\/div><\/div>\n<p>The \u201c-xjf\u201d flag ensures the tar command extracts the file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"66\" class=\"wp-image-21610\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-8.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-8-300x27.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<p>The command line moves to the next line indicating the archive file was extracted. In our case, the tar archive file contained the \u201cFolderA\u201d and \u201cFolderB\u201d Directories. To verify the extracted files, the ls command can be used again:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span><\/div><\/div>\n<p>Here, the \u201cFolderA\u201d and \u201cFolderB\u201d in the list ensure the archive file was extracted using the tar command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1005\" height=\"384\" class=\"wp-image-21611\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-9.png 1005w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-9-300x115.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-9-768x293.png 768w\" sizes=\"auto, (max-width: 1005px) 100vw, 1005px\" \/><\/p>\n<h2><strong>Bonus Step: Compressing File into a \u201ctar.bz2\u201d Archive<\/strong><\/h2>\n<p>You can also compress files into an archive file using the \u201ctar\u201d command. In our case, we have the \u201cFolderA\u201d and \u201cFolderB\u201d in the Documents Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"974\" height=\"382\" class=\"wp-image-21612\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-10.png 974w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-10-300x118.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-10-768x301.png 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/p>\n<p>To Compress the Directories into a \u201ctar.bz2\u201d Archive File, the command used 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> <span class=\"re5\">-cjf<\/span> tararchive.tar.bz2 FolderA FolderB<\/div><\/div>\n<p>This will compress the Directories into the \u201ctararchive.tar.bz2\u201d file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"68\" class=\"wp-image-21613\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-11.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-11-300x28.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<p>The \u201c-cjf\u201d ensures the tar command compresses the files or directories.<\/p>\n<p>Once compressed, use the \u201cls\u201d command to verify the compressed \u201ctararchive.tar.bz2\u201d file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1251\" height=\"484\" class=\"wp-image-21614\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-12.png 1251w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-12-300x116.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-12-1024x396.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21602-12-768x297.png 768w\" sizes=\"auto, (max-width: 1251px) 100vw, 1251px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The \u201ctar\u201d is a useful command in Ubuntu for extracting files. To extract the \u201ctar.bz2\u201d file in Ubuntu, the tar command is used along with the \u201c-xjf\u201d flag ensuring the tar command extracts the file. This article explained the process of extracting a \u201ctar.bz2\u201d file in Ubuntu.<\/p>","protected":false},"excerpt":{"rendered":"<p>To extract the \u201ctar.bz2\u201d file in Ubuntu, the tar command is used along with the \u201c-xjf\u201d flag ensuring the tar command extracts the file.<\/p>","protected":false},"author":110,"featured_media":21615,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-21602","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\/21602","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=21602"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21602\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21615"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}