{"id":13766,"date":"2019-04-06T02:56:29","date_gmt":"2019-04-06T02:56:29","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13766"},"modified":"2019-04-06T02:56:29","modified_gmt":"2019-04-06T02:56:29","slug":"how-to-open-extract-and-create-rar-files-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-open-extract-and-create-rar-files-in-linux\/","title":{"rendered":"How to Open, Extract and Create RAR Files in Linux"},"content":{"rendered":"<p><strong>RAR<\/strong>\u00a0is a most popular tool for creating and extracting compressed archive\u00a0<code>(.rar)<\/code>\u00a0files. When we download an archive file from the web, we required a\u00a0<strong>rar<\/strong>\u00a0tool to extract them.<\/p>\n<p><strong>RAR<\/strong>\u00a0is available freely under Windows operating systems to handle compressed files, but unfortunately,\u00a0<strong>rar<\/strong>\u00a0tool doesn\u2019t pre-installed under Linux systems.<\/p>\n<p>This article explains how to install\u00a0<strong>unrar<\/strong>\u00a0and\u00a0<strong>rar<\/strong>\u00a0command-line tools using official binary tar file under Linux systems to open, extract, uncompress or unrar an archive file.<\/p>\n<h4>Step 1: How to Install Unrar in Linux<\/h4>\n<p>On\u00a0<strong>Debian<\/strong>\u00a0and\u00a0<strong>Ubuntu<\/strong>\u00a0based distributions, you can easily install\u00a0<strong>unrar<\/strong>\u00a0package using the\u00a0<a href=\"https:\/\/www.tecmint.com\/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management\/\" target=\"_blank\" rel=\"noopener\">apt-get<\/a>\u00a0or\u00a0<a href=\"https:\/\/www.tecmint.com\/apt-advanced-package-command-examples-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">apt<\/a>\u00a0program as shown.<\/p>\n<pre>$ sudo apt-get install unrar\r\nOr\r\n$ sudo apt install unrar\r\n<\/pre>\n<p>If you are using\u00a0<strong>Fedora<\/strong>\u00a0distribution, you can use the\u00a0<a href=\"https:\/\/www.tecmint.com\/dnf-commands-for-fedora-rpm-package-management\/\" target=\"_blank\" rel=\"noopener\">dnf command<\/a>\u00a0to install it.<\/p>\n<pre>$ sudp dnf install unrar\r\n<\/pre>\n<p>If you are using a\u00a0<strong>CentOS<\/strong>\u00a0\/\u00a0<strong>RHEL<\/strong>\u00a0distribution, you need to\u00a0<a href=\"https:\/\/www.rarlab.com\/download.htm\" target=\"_blank\" rel=\"nofollow noopener\">download the latest unrar\/rar file<\/a>\u00a0and install it using following commands.<\/p>\n<pre><strong>--------------- On 64-bit ---------------<\/strong> \r\n# cd \/tmp\r\n# wget https:\/\/www.rarlab.com\/rar\/rarlinux-x64-5.6.0.tar.gz\r\n# tar -zxvf rarlinux-x64-5.6.0.tar.gz\r\n# cd rar\r\n# sudo cp -v rar unrar \/usr\/local\/bin\/\r\n\r\n<strong>--------------- On 32-bit ---------------<\/strong> \r\n# cd \/tmp\r\n# wget https:\/\/www.rarlab.com\/rar\/rarlinux-5.6.0.tar.gz\r\n# tar -zxvf rarlinux-5.6.0.tar.gz\r\n# cd rar\r\n# sudo cp -v rar unrar \/usr\/local\/bin\/\r\n<\/pre>\n<h4>Step 2: How to Open\/Extract a RAR File in Linux<\/h4>\n<p>To open\/extract a\u00a0<strong>RAR<\/strong>\u00a0file in current working directory, just use the following command with\u00a0<strong>unrar e<\/strong>\u00a0option.<\/p>\n<pre><strong># unrar e tecmint.rar<\/strong>\r\n\r\nUNRAR 4.20 beta 3 freeware      Copyright (c) 1993-2012 Alexander Roshal\r\n\r\nExtracting from tecmint.rar\r\n\r\nExtracting  index.php                                                 OK\r\nExtracting  index.html                                                OK\r\nExtracting  xyz.txt                                                   OK\r\nExtracting  abc.txt                                                   OK\r\nAll OK<\/pre>\n<p>To open\/extract a\u00a0<strong>RAR<\/strong>\u00a0file in specific path or destination directory, just use the\u00a0<strong>unrar e<\/strong>\u00a0option, it will extract all the files in specified destination directory.<\/p>\n<pre><strong># unrar e tecmint.rar \/home\/<\/strong>\r\n\r\nUNRAR 4.20 beta 3 freeware      Copyright (c) 1993-2012 Alexander Roshal\r\n\r\nExtracting from tecmint.rar\r\n\r\nExtracting  \/home\/index.php                                           OK\r\nExtracting  \/home\/index.html                                          OK\r\nExtracting  \/home\/xyz.txt                                             OK\r\nExtracting  \/home\/abc.txt                                             OK\r\nAll OK<\/pre>\n<p>To open\/extract a\u00a0<strong>RAR<\/strong>\u00a0file with their original directory structure. just issue below command with\u00a0<strong>unrar x<\/strong>\u00a0option. It will extract according their folder structure see below output of the command.<\/p>\n<pre><strong># unrar x tecmint.rar<\/strong>\r\n\r\nUNRAR 4.20 beta 3 freeware      Copyright (c) 1993-2012 Alexander Roshal\r\n\r\nExtracting from tecmint.rar\r\n\r\nCreating    tecmint                                                   OK\r\nExtracting  tecmint\/index.php                                         OK\r\nExtracting  tecmint\/index.html                                        OK\r\nExtracting  tecmint\/xyz.txt                                           OK\r\nExtracting  tecmint\/abc.txt                                           OK\r\nCreating    default                                                   OK\r\nExtracting  default\/index.php                                         OK\r\nExtracting  default\/index.html                                        OK\r\nCreating    include                                                   OK\r\nExtracting  include\/abc.txt                                           OK\r\nCreating    php                                                       OK\r\nExtracting  php\/xyz.txt                                               OK\r\nAll OK<\/pre>\n<h4>Step 3: How to List a RAR File in Linux<\/h4>\n<p>To list a files inside a archive file use\u00a0<strong>unrar l<\/strong>\u00a0option. It will display the list of files with their\u00a0<strong>sizes<\/strong>,\u00a0<strong>date<\/strong>,\u00a0<strong>time<\/strong>\u00a0and\u00a0<strong>permissions<\/strong>.<\/p>\n<pre><strong>unrar l tecmint.rar<\/strong>\r\n\r\nUNRAR 4.20 beta 3 freeware      Copyright (c) 1993-2012 Alexander Roshal\r\n\r\nArchive tecmint.rar\r\n\r\n Name             Size   Packed Ratio  Date   Time     Attr      CRC   Meth Ver\r\n-------------------------------------------------------------------------------\r\n index.php           0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n index.html          0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n xyz.txt             0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n abc.txt             0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n index.php           0        8   0% 18-08-12 19:22 -rw-r--r-- 00000000 m3b 2.9\r\n index.html          0        8   0% 18-08-12 19:22 -rw-r--r-- 00000000 m3b 2.9\r\n abc.txt             0        8   0% 18-08-12 19:22 -rw-r--r-- 00000000 m3b 2.9\r\n xyz.txt             0        8   0% 18-08-12 19:22 -rw-r--r-- 00000000 m3b 2.9\r\n-------------------------------------------------------------------------------\r\n    8                0       64   0%<\/pre>\n<h4>Step 4: How to Test a RAR File in Linux<\/h4>\n<p>To test an integrity of a archive file, use option\u00a0<strong>unrar t<\/strong>. The below command will perform a complete integrity check for each file and displays the status of the file.<\/p>\n<pre><strong>unrar t tecmint.rar<\/strong>\r\n\r\nUNRAR 4.20 beta 3 freeware      Copyright (c) 1993-2012 Alexander Roshal\r\n\r\nTesting archive tecmint.rar\r\n\r\nTesting     tecmint\/index.php                                         OK\r\nTesting     tecmint\/index.html                                        OK\r\nTesting     tecmint\/xyz.txt                                           OK\r\nTesting     tecmint\/abc.txt                                           OK\r\nTesting     default\/index.php                                         OK\r\nTesting     default\/index.html                                        OK\r\nTesting     include\/abc.txt                                           OK\r\nTesting     php\/xyz.txt                                               OK\r\nAll OK<\/pre>\n<p>The\u00a0<strong>unrar<\/strong>\u00a0command is used to extract, list or test archive files only. It has no any option for creating\u00a0<strong>RAR<\/strong>\u00a0files under Linux. So, here we need to install\u00a0<strong>RAR<\/strong>\u00a0command-line utility to create archive files.<\/p>\n<h4>Step 5: How to Install Rar in Linux<\/h4>\n<p>To install\u00a0<strong>RAR<\/strong>\u00a0command option in Linux, just execute following command.<\/p>\n<pre># sudo apt-get install rar\r\n# sudo dnf install rar\r\n# yum install rar\r\n<\/pre>\n<h5>Sample Output<\/h5>\n<pre>Loaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\nDependencies Resolved\r\n=========================================================================================\r\n Package\t\t\tArch\t\t\tVersion\t\t\t\tRepository\t\t\tSize\r\n=========================================================================================\r\nInstalling:\r\n rar\t\t\t\ti386            3.8.0-1.el5.rf      rpmforge\t\t\t264 k\r\n\r\nTransaction Summary\r\n=========================================================================================\r\nInstall       1 Package(s)\r\nUpgrade       0 Package(s)\r\n\r\nTotal download size: 264 k\r\nIs this ok [y\/N]: y\r\nDownloading Packages:\r\nrar-3.8.0-1.el5.rf.i386.rpm\t\t\t\t\t\t\t\t\t\t| 264 kB     00:01\r\nRunning rpm_check_debug\r\nRunning Transaction Test\r\nFinished Transaction Test\r\nTransaction Test Succeeded\r\nRunning Transaction\r\n  Installing     : rar                                          1\/1\r\n\r\nInstalled:\r\n  rar.i386 0:3.8.0-1.el5.rf\r\n\r\nComplete!<\/pre>\n<h4>Step 6: How to Create Rar File in Linux<\/h4>\n<p>To create a archive(<strong>RAR<\/strong>) file in Linux, run the following command with\u00a0<strong>rar a<\/strong>\u00a0option. It will create archive file for a\u00a0<strong>tecmint<\/strong>\u00a0directory.<\/p>\n<pre><strong>rar a tecmint.rar tecmint<\/strong>\r\n\r\nRAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nEvaluation copy. Please register.\r\n\r\nCreating archive tecmint.rar\r\n\r\nAdding    tecmint\/index.php                                           OK\r\nAdding    tecmint\/index.html                                          OK\r\nAdding    tecmint\/xyz.txt                                             OK\r\nAdding    tecmint\/abc.txt                                             OK\r\nAdding    tecmint                                                     OK\r\nDone<\/pre>\n<h4>Step 7: How to Delete files from Archive<\/h4>\n<p>To delete a file from a archive file, run the command.<\/p>\n<pre><b>rar d filename.rar<\/b>\r\n<\/pre>\n<h4>Step 8: How to Recover Archives<\/h4>\n<p>To recover or fix a archive file or files, run the command with option\u00a0<strong>rar r<\/strong>.<\/p>\n<pre><strong>rar r filename.rar<\/strong>\r\n\r\nRAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nBuilding fixed.tecmint.rar\r\nScanning...\r\nData recovery record not found\r\nReconstructing tecmint.rar\r\nBuilding rebuilt.tecmint.rar\r\nFound  tecmint\\index.php\r\nFound  tecmint\\index.html\r\nFound  tecmint\\xyz.txt\r\nFound  tecmint\\abc.txt\r\nFound  tecmint\r\nDone<\/pre>\n<h4>Step 9: How to Update Archives<\/h4>\n<p>To update or add files to existing archive file, use the following command with option\u00a0<strong>rar u<\/strong>.<\/p>\n<pre><strong>rar u tecmint.rar tecmint.sql<\/strong>\r\n\r\nRAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nEvaluation copy. Please register.\r\n\r\nUpdating archive tecmint.rar\r\n\r\nAdding    tecmint.sql                                                 OK\r\nDone<\/pre>\n<p>Now, verify that the file\u00a0<strong>tecmint.sql<\/strong>\u00a0is added to archive file.<\/p>\n<pre><strong>rar l tecmint.rar<\/strong>\r\n\r\nRAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nArchive tecmint.rar\r\n\r\n Name             Size   Packed Ratio  Date   Time     Attr      CRC   Meth Ver\r\n-------------------------------------------------------------------------------\r\n index.php           0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n index.html          0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n xyz.txt             0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n abc.txt             0        8   0% 18-08-12 19:11 -rw-r--r-- 00000000 m3b 2.9\r\n tecmint             0        0   0% 18-08-12 19:23 drwxr-xr-x 00000000 m0  2.0\r\n <strong>tecmint.sql 0 8 0% 18-08-12 19:46 -rw-r--r-- 00000000 m3b 2.9<\/strong>\r\n-------------------------------------------------------------------------------\r\n    6                0       40   0%<\/pre>\n<h4>Step 10: How to Set Password to Archives<\/h4>\n<p>This is very interesting feature from\u00a0<strong>Rar<\/strong>\u00a0tool, it allows us to set a password to archive file. To password protect archive file use option\u00a0<strong>rar a -p<\/strong>.<\/p>\n<pre><strong>rar a -p tecmint.rar<\/strong>\r\n\r\nEnter password (will not be echoed):\r\n\r\nReenter password:\r\n\r\nAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nEvaluation copy. Please register.\r\n\r\nUpdating archive tecmint.rar\r\n\r\nUpdating  tecmint.sql                                                 OK\r\nDone<\/pre>\n<p>Now verify it by extracting the archive file and see whether it will prompt us to enter password that we have set above.<\/p>\n<pre><strong>rar x tecmint.rar<\/strong>\r\n\r\nRAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nExtracting from tecmint.rar\r\n\r\nCreating    tecmint                                                   OK\r\nExtracting  tecmint\/index.php                                         OK\r\nExtracting  tecmint\/index.html                                        OK\r\nExtracting  tecmint\/xyz.txt                                           OK\r\nExtracting  tecmint\/abc.txt                                           OK\r\n<strong>Enter password (will not be echoed) for tecmint.sql<\/strong>:\r\n\r\nExtracting  tecmint.sql                                               OK\r\nAll OK<\/pre>\n<h4>Step 11: How to Lock Archives<\/h4>\n<p>Another interesting lock feature from rar tool, it provides a option to lock a particular archive file from extracting it.<\/p>\n<pre><strong>rar k tecmint.rar<\/strong>\r\n\r\nRAR 3.80   Copyright (c) 1993-2008 Alexander Roshal   16 Sep 2008\r\nShareware version         Type RAR -? for help\r\n\r\nProcessing archive tecmint.rar\r\n<strong>Locking archive<\/strong>\r\nDone<\/pre>\n<h4>Conclusion<\/h4>\n<p>For mor\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<pre><strong># man unrar<\/strong>\r\n<strong># man rar<\/strong><\/pre>\n<p>We have presented almost all of the options above for\u00a0<strong>rar<\/strong>\u00a0and\u00a0<strong>unrar<\/strong>\u00a0commands 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 comment form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/how-to-open-extract-and-create-rar-files-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RAR\u00a0is a most popular tool for creating and extracting compressed archive\u00a0(.rar)\u00a0files. When we download an archive file from the web, we required a\u00a0rar\u00a0tool to extract them. RAR\u00a0is available freely under Windows operating systems to handle compressed files, but unfortunately,\u00a0rar\u00a0tool doesn\u2019t pre-installed under Linux systems. This article explains how to install\u00a0unrar\u00a0and\u00a0rar\u00a0command-line tools using official binary tar &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-open-extract-and-create-rar-files-in-linux\/\" 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-13766","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\/13766","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=13766"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13766\/revisions"}],"predecessor-version":[{"id":13767,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13766\/revisions\/13767"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}