{"id":16949,"date":"2023-11-01T10:49:11","date_gmt":"2023-11-01T10:49:11","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=16949"},"modified":"2023-11-01T10:49:13","modified_gmt":"2023-11-01T10:49:13","slug":"how-to-open-extract-and-create-rar-files-in-linux-2","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/11\/01\/how-to-open-extract-and-create-rar-files-in-linux-2\/","title":{"rendered":"How to Open, Extract and Create RAR Files in Linux."},"content":{"rendered":"\n<p><strong>RAR<\/strong>&nbsp;files, a common compressed file format, are widely used to store and share large amounts of data efficiently. While Linux natively supports various compression formats like&nbsp;<a href=\"https:\/\/www.tecmint.com\/install-zip-and-unzip-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">ZIP<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/www.tecmint.com\/tar-command-examples-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">TAR<\/a>.<\/p>\n\n\n\n<p><strong>RAR<\/strong>&nbsp;is the most popular tool for creating and extracting compressed archive&nbsp;<code>(.rar)<\/code>&nbsp;files. When we download an archive file from the web, we require a&nbsp;<strong>rar<\/strong>&nbsp;tool to extract them.<\/p>\n\n\n\n<p><strong>RAR<\/strong>&nbsp;is available freely under Windows operating systems to handle compressed files, but unfortunately, the&nbsp;<strong>rar<\/strong>&nbsp;tool isn\u2019t pre-installed under Linux systems.<\/p>\n\n\n\n<p>In this article, we\u2019ll guide you through the process of installing\u00a0<strong>unrar<\/strong>\u00a0and\u00a0<strong>rar<\/strong>\u00a0command-line tools to open, extract, uncompress, or unrar and create an archive file on a Linux system.<\/p>\n\n\n\n<p><strong>Table of Contents<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install Unrar on Linux<\/li>\n\n\n\n<li>How to Extract RAR Files in Linux<\/li>\n\n\n\n<li>How to List RAR Files in Linux<\/li>\n\n\n\n<li>How to Check Integrity of RAR File in Linux<\/li>\n\n\n\n<li>How to Install Rar in Linux<\/li>\n\n\n\n<li>How to Create RAR File in Linux<\/li>\n\n\n\n<li>How to Delete Files in RAR Archive<\/li>\n\n\n\n<li>How to Repair RAR Files in Linux<\/li>\n\n\n\n<li>How to Add Files to RAR Archive<\/li>\n\n\n\n<li>How to Set Password to RAR File<\/li>\n\n\n\n<li>How to Lock RAR File<\/li>\n\n\n\n<li>Conclusion<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Install Unrar on Linux<\/strong><\/h2>\n\n\n\n<p>To work with\u00a0<strong>RAR<\/strong>\u00a0files on Linux, you\u2019ll need the\u00a0<strong>unrar<\/strong>\u00a0tool, which allows you to extract content from RAR archives. To install unrar, open a terminal and use the default package manager specific to your Linux distribution.<\/p>\n\n\n\n<p>For example, on\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.tecmint.com\/debian-based-linux-distributions\/\" target=\"_blank\">Debian and Ubuntu-based distributions<\/a>, you can easily install the\u00a0<strong>unrar<\/strong>\u00a0package using the\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.tecmint.com\/apt-get-command\/\" target=\"_blank\">apt-get<\/a>\u00a0or\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.tecmint.com\/apt-command-in-linux\/\" target=\"_blank\">apt<\/a>\u00a0program as shown.<\/p>\n\n\n\n<p>$ sudo apt-get install unrar <\/p>\n\n\n\n<p>Or <\/p>\n\n\n\n<p>$ sudo apt install unrar<\/p>\n\n\n\n<p>If you are using\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.tecmint.com\/redhat-based-linux-distributions\/\" target=\"_blank\">RHEL-based distributions<\/a>, you can use the\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.tecmint.com\/dnf-commands-for-fedora-rpm-package-management\/\" target=\"_blank\">dnf command<\/a>\u00a0or\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.tecmint.com\/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement\/\" target=\"_blank\">yum command<\/a>\u00a0to install it.<\/p>\n\n\n\n<p><strong>&#8212;&#8212;&#8212;&#8212; On Fedora Linux &#8212;&#8212;&#8212;&#8212;<\/strong> <\/p>\n\n\n\n<p>$ sudo dnf install unrar <\/p>\n\n\n\n<p><strong>&#8212;&#8212;&#8212;&#8212; On RHEL-based Linux &#8212;&#8212;&#8212;&#8212;<\/strong> <\/p>\n\n\n\n<p>$ sudo yum install epel-release <\/p>\n\n\n\n<p>$ sudo yum install unrar<\/p>\n\n\n\n<p>On other&nbsp;<a href=\"https:\/\/www.tecmint.com\/top-most-popular-linux-distributions\/\" target=\"_blank\" rel=\"noreferrer noopener\">popular Linux distributions<\/a>, you can install it using your default package manager as shown.$ sudo emerge -a app-arch\/unrar [On <strong>Gentoo Linux<\/strong>] $ sudo apk add unrar [On <strong>Alpine Linux<\/strong>] $ sudo pacman -S unrar [On <strong>Arch Linux<\/strong>] $ sudo zypper install unrar [On <strong>OpenSUSE<\/strong>]<\/p>\n\n\n\n<p>If your distribution does not offer an\u00a0<strong>unrar<\/strong>\u00a0package, you need to\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.rarlab.com\/download.htm\" target=\"_blank\">download the latest unrar\/rar file<\/a>\u00a0and install it using the following commands.<\/p>\n\n\n\n<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212; On 64-bit &#8212;&#8212;&#8212;&#8212;&#8212;<\/strong> <\/p>\n\n\n\n<p># cd \/tmp # wget https:\/\/www.rarlab.com\/rar\/rarlinux-x64-623.tar.gz <\/p>\n\n\n\n<p># tar -zxvf rarlinux-x64-623.tar.gz <\/p>\n\n\n\n<p># cd rar <\/p>\n\n\n\n<p># sudo cp -v rar unrar \/usr\/local\/bin\/<\/p>\n\n\n\n<p> <strong>&#8212;&#8212;&#8212;&#8212;&#8212; On 32-bit &#8212;&#8212;&#8212;&#8212;&#8212;<\/strong><\/p>\n\n\n\n<p> # cd \/tmp <\/p>\n\n\n\n<p># wget https:\/\/www.rarlab.com\/rar\/rarlinux-x32-623.tar.gz<\/p>\n\n\n\n<p># tar -zxvf rarlinux-x32-623.tar.gz <\/p>\n\n\n\n<p># cd rar<\/p>\n\n\n\n<p> # sudo cp -v rar unrar \/usr\/local\/bin\/<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Extract RAR Files in Linux<\/strong><\/h2>\n\n\n\n<p>Once you have\u00a0<strong>unrar<\/strong>\u00a0installed, you can easily open or extract the contents of a RAR file in the current working directory by using the following command with the\u00a0<code>e<\/code>\u00a0option.<\/p>\n\n\n\n<p>$ unrar e tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52788\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Extracting-RAR-Files.png\" alt=\"Extracting RAR Files\" class=\"wp-image-52788\"\/><figcaption class=\"wp-element-caption\">Extracting RAR Files<\/figcaption><\/figure>\n\n\n\n<p>To open\/extract a\u00a0<strong>RAR<\/strong>\u00a0file in a specific path or destination directory, just use the\u00a0<code>e<\/code>\u00a0option, it will extract all the files in the specified destination directory.<\/p>\n\n\n\n<p>$ unrar e tecmint.rar \/home\/tecmint\/rarfiles<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52789\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Extracting-RAR-Files-to-Directory.png\" alt=\"Extracting RAR Files to Directory\" class=\"wp-image-52789\"\/><figcaption class=\"wp-element-caption\">Extracting RAR Files to the Directory<\/figcaption><\/figure>\n\n\n\n<p>To open\/extract an\u00a0<strong>RAR<\/strong>\u00a0file with its original directory structure, just issue the below command with the\u00a0<code>x<\/code>\u00a0option, which will extract according to their folder structure see below the output of the command.<\/p>\n\n\n\n<p>$ unrar x tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52790\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Extracting-RAR-Files-with-Directory-Structure.png\" alt=\"Extracting RAR Files with Directory Structure\" class=\"wp-image-52790\"\/><figcaption class=\"wp-element-caption\">Extracting RAR Files with Directory Structure<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to List RAR Files in Linux<\/strong><\/h2>\n\n\n\n<p>To list the contents of an RAR file in Linux, you can use the\u00a0<code>unrar l<\/code>\u00a0command, which will display the list of files with their\u00a0<strong>sizes<\/strong>,\u00a0<strong>dates<\/strong>,\u00a0<strong>time,<\/strong>\u00a0and\u00a0<strong>permissions<\/strong>.<\/p>\n\n\n\n<p>$ unrar l tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52792\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Listing-Content-of-RAR-Files.png\" alt=\"Listing Content of RAR Files\" class=\"wp-image-52792\"\/><figcaption class=\"wp-element-caption\">Listing Content of RAR Files<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Check Integrity of RAR File in Linux<\/strong><\/h2>\n\n\n\n<p>To check the integrity of an RAR archive file, you can use the\u00a0<code>unrar t<\/code>\u00a0command, which will perform a complete integrity check for each file for errors and displays the status of the file.<\/p>\n\n\n\n<p>$ unrar t tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52793\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Testing-RAR-Files.png\" alt=\"Testing RAR Files\" class=\"wp-image-52793\"\/><figcaption class=\"wp-element-caption\">Testing RAR Files<\/figcaption><\/figure>\n\n\n\n<p>The&nbsp;<strong>unrar<\/strong>&nbsp;command is used to extract, list, or test archive files only. It has no option for creating&nbsp;<strong>RAR<\/strong>&nbsp;files under Linux. So, here we need to install the&nbsp;<strong>RAR<\/strong>&nbsp;command-line utility to create archive files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Install Rar in Linux<\/strong><\/h2>\n\n\n\n<p>The\u00a0<strong>rar<\/strong>\u00a0command-line utility is used to create RAR archives, you can install\u00a0<strong>rar<\/strong>\u00a0using a package manager appropriate for your Linux distribution,<\/p>\n\n\n\n<p>$ sudo apt install rar [On <strong>Debian, Ubuntu and Mint<\/strong>]<\/p>\n\n\n\n<p> $ sudo yum install rar [On <strong>RHEL\/CentOS\/Fedora<\/strong> and <strong>Rocky\/AlmaLinux<\/strong>]<\/p>\n\n\n\n<p> $ sudo emerge -a app-arch\/rar [On <strong>Gentoo Linux<\/strong>]<\/p>\n\n\n\n<p> $ sudo apk add rar [On <strong>Alpine Linux<\/strong>] <\/p>\n\n\n\n<p>$ sudo pacman -S rar [On <strong>Arch Linux<\/strong>]<\/p>\n\n\n\n<p> $ sudo zypper install rar [On <strong>OpenSUSE<\/strong>]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Create RAR File in Linux<\/strong><\/h2>\n\n\n\n<p>To create an archive (<strong>RAR<\/strong>) file in Linux, run the following command with\u00a0<code>a<\/code>\u00a0option, which will create an archive file for a\u00a0<strong>tecmint<\/strong>\u00a0directory.<\/p>\n\n\n\n<p>$ rar a tecmint.rar tecmint<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52795\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Creating-RAR-File.png\" alt=\"Creating RAR File in Linux\" class=\"wp-image-52795\"\/><figcaption class=\"wp-element-caption\">Creating RAR File in Linux<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Delete Files in RAR Archive<\/strong><\/h2>\n\n\n\n<p>The\u00a0<code>rar d<\/code>\u00a0command is used to delete files from an existing RAR archive in Linux. The\u00a0<code>d<\/code>\u00a0option directly modifies the existing RAR archive by removing the specified files.<\/p>\n\n\n\n<p>$ rar d tecmint.rar randfile001 randfile002<\/p>\n\n\n\n<p>In the above command, the&nbsp;<strong>randfile001<\/strong>&nbsp;and&nbsp;<strong>randfile002<\/strong>&nbsp;files will be deleted from the&nbsp;<strong>tecmint.rar<\/strong>&nbsp;RAR archive.<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52796\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Delete-File-in-RAR-Archive.png\" alt=\"Delete Files in RAR Archive\" class=\"wp-image-52796\"\/><figcaption class=\"wp-element-caption\">Delete Files in the RAR Archive<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Repair RAR Files in Linux<\/strong><\/h2>\n\n\n\n<p>The\u00a0<code>rar r<\/code>\u00a0command is used to repair and recover data from damaged or corrupted RAR archives in Linux.<\/p>\n\n\n\n<p>$ rar r tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52797\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Fix-RAR-Files.png\" alt=\"Repair RAR Archive\" class=\"wp-image-52797\"\/><figcaption class=\"wp-element-caption\">Repair RAR Archive<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Add Files to RAR Archive<\/strong><\/h2>\n\n\n\n<p>To update or add files to the existing archive file, use the\u00a0<code>rar u<\/code>\u00a0command, which allows you to add files to an existing RAR archive or update files within the archive.<\/p>\n\n\n\n<p>$ rar u tecmint.rar hello.py<\/p>\n\n\n\n<p>Now, verify that the file\u00a0<strong>tecmint.sql<\/strong>\u00a0is added to the archive file.<\/p>\n\n\n\n<p>$ rar l tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52798\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Add-Files-to-RAR-Archive.png\" alt=\"Add Files to RAR Archive\" class=\"wp-image-52798\"\/><figcaption class=\"wp-element-caption\">Add Files to the RAR Archive<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Set Password to RAR File<\/strong><\/h2>\n\n\n\n<p>This is a very interesting feature of the\u00a0<strong>rar<\/strong>\u00a0tool, which allows us to set a password to the RAR archive file using the following command.<\/p>\n\n\n\n<p>$ rar a -p tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52799\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Set-Password-to-RAR-File.png\" alt=\"Set Password to RAR File\" class=\"wp-image-52799\"\/><figcaption class=\"wp-element-caption\">Set Password to RAR File<\/figcaption><\/figure>\n\n\n\n<p>Now verify it by extracting the archive file and see whether it will prompt us to enter the password that we have set above.<\/p>\n\n\n\n<p>$ rar x tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52800\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Extract-Password-Protected-RAR-File.png\" alt=\"Extract Password Protected RAR File\" class=\"wp-image-52800\"\/><figcaption class=\"wp-element-caption\">Extract Password Protected RAR File<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Lock RAR File<\/strong><\/h2>\n\n\n\n<p>The\u00a0<code>rar k<\/code>\u00a0command is used to lock an existing RAR archive file, which is useful if you want to prevent further modifications to the archive.<\/p>\n\n\n\n<p>$ rar k tecmint.rar<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_52801\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2023\/04\/Lock-RAR-File.png\" alt=\"Lock RAR File\" class=\"wp-image-52801\"\/><figcaption class=\"wp-element-caption\">Lock RAR File<\/figcaption><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Conclusion<\/h5>\n\n\n\n<p>For more\u00a0<strong>RAR<\/strong>\u00a0and\u00a0<strong>Unrar<\/strong>\u00a0options and usage, run the following command it will display a list of options with their description.<\/p>\n\n\n\n<p>$ man unrar<\/p>\n\n\n\n<p> $ man rar<\/p>\n\n\n\n<p>We have presented almost all of the options above for&nbsp;<strong>rar<\/strong>&nbsp;and&nbsp;<strong>unrar<\/strong>&nbsp;commands with their examples. If you feel that we\u2019ve missed anything in this list and you would like us to add, please update us using the comment form below.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.tecmint.com\/how-to-open-extract-and-create-rar-files-in-linux\/\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RAR&nbsp;files, a common compressed file format, are widely used to store and share large amounts of data efficiently. While Linux natively supports various compression formats like&nbsp;ZIP&nbsp;and&nbsp;TAR. RAR&nbsp;is the most popular tool for creating and extracting compressed archive&nbsp;(.rar)&nbsp;files. When we download an archive file from the web, we require a&nbsp;rar&nbsp;tool to extract them. RAR&nbsp;is available freely &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/11\/01\/how-to-open-extract-and-create-rar-files-in-linux-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Open, Extract and Create RAR Files in Linux.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-16949","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/16949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=16949"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/16949\/revisions"}],"predecessor-version":[{"id":16950,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/16949\/revisions\/16950"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=16949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=16949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=16949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}