This site contains affiliate links. If you make a purchase, we may earn a commission.

How To Create RAR Files on Command Line (Many Methods!)

Ezriah Zippernowsky
September 28 2023


Hello, fellow primates! Welcome back to the jungle of archive files. If you’re going bananas over big files, let’s squash them into a neat RAR file for you! Using the command line to create RAR files is as easy as bundling bananas together. So, let’s stop monkeying around and get started!

Table of contents

Video guide showing how to create RAR files on the command line using terminal.

How To Create RAR Files Using Command Line

Creating RAR files on the command line is easy. Here’s how you do it:

  1. Install RAR: First, you need to install RAR. It’s like getting the right tool to bundle your bananas. You can install it using the following command on Debian based linux systems (Ubuntu, Mint):

    sudo apt-get install rar

    How To Create RAR Files Using Command Line on Linux: Step 1 How To Create RAR Files Using Command Line on Linux: Step 1 How To Create RAR Files Using Command Line on Linux: Step 1

  2. Open Terminal on Directory: Open up your file manager and find the directory where your rar archive is located. Click the three dots and click on (Open in terminal). It’s like the tree where all the magic happens.

    How To Create RAR Files Using Command Line on Linux: Step 2

  3. Compress Command: For a specific file use: rar a yourfile.rar yourfile for all files in directory, use * wildcard: rar a yourfile.rar * This is the magic spell that bundles your files into a neat RAR file. Replace ‘yourfile’ with the name of the file you want to compress or use * to indicate all files in the directory.How To Create RAR Files Using Command Line on Linux: Step 3How To Create RAR Files Using Command Line on Linux: Step 3

    Remember, when it comes to archiving software, it’s a jungle out there! But with these command line tips, you’ll be the king of the jungle in no time. Happy compressing!

How To Create RAR Files with Maximum Compression Using Command Line

Want to squash your files even more? Here’s how you do it:

  1. Open Terminal on Directory: Open up your file manager and find the directory where your rar archive is located. Click the three dots and click on (Open in terminal). It’s like the tree where all the magic happens.

    How To Create RAR Files with Maximum Compression Using Command Line: Step 1

  2. Compress Command: Type

    rar a -m5 yourfile.rar yourfile

    The -m5 switch is the magic spell that squashes your files to their smallest size.

    How To Create RAR Files with Maximum Compression Using Command Line: Step 2How To Create RAR Files with Maximum Compression Using Command Line: Step 2

How To Compress a Folder Recursively Using Command Line

Got a whole tree of files to compress? No problem!

  1. Open Terminal on Directory: Open up your file manager and find the directory where your rar archive is located. Click the three dots and click on (Open in terminal). It’s like the tree where all the magic happens.

    How To Compress a Folder Recursively Using Command Line: Step 1

  2. Compress Command: Type

    rar a -r yourfile.rar yourfolder/**

    The -r switch is the magic spell that compresses all the files in your folder and its subfolders.

    How To Compress a Folder Recursively Using Command Line: Step 2 How To Compress a Folder Recursively Using Command Line: Step 2

How To Add More Files to an Existing RAR File Using Command Line

Got more bananas for your bunch? Here’s how you add them:

  1. Open Terminal on Directory: Open up your file manager and find the directory where your rar archive is located. Click the three dots and click on (Open in terminal). It’s like the tree where all the magic happens.

    How To Add More Files to an Existing RAR File Using Command Line: Step 1

  2. Add Command: Type

    rar a yourfile.rar newfile

    This is the magic spell that adds more files to your RAR file. Replace ‘newfile’ with the name of the file you want to add.

    How To Add More Files to an Existing RAR File Using Command Line: Step 2How To Add More Files to an Existing RAR File Using Command Line: Step 2

How To Create a Password Protected RAR File Using Command Line

Want to protect your bananas from other monkeys? Here’s how you do it:

  1. Open Terminal on Directory: Open up your file manager and find the directory where your rar archive is located. Click the three dots and click on (Open in terminal). It’s like the tree where all the magic happens.

    How To Create a Password Protected RAR File Using Command Line: Step 1

  2. Compress Command: Type

    rar a -p yourfile.rar yourfile

    The -p switch is the magic spell that protects your bananas with a password. You’ll be prompted to enter a password after you type the command.

    How To Create a Password Protected RAR File Using Command Line: Step 2 How To Create a Password Protected RAR File Using Command Line: Step 3 How To Create a Password Protected RAR File Using Command Line: Step 3

    It will ask you to re-enter your password.

    How To Create a Password Protected RAR File Using Command Line: Step 3

    Remember, with the command line, you’re the king of the jungle! Happy compressing!