Creating a RAR archive in Linux packs files and directories into one compressed file that is easier to upload, move, or hand off without flattening the original directory layout. That is useful for project folders, log collections, or any bundle that needs to stay together as a single file.

The rar command writes the archive with the a action, then rar l lists the stored paths and rar t tests the finished archive without extracting it. That keeps the workflow centered on one archive file while still providing a quick proof that the expected files were stored and can be read cleanly.

Package availability still differs across current Linux distributions and architectures. Ubuntu 24.04 exposes rar from multiverse on amd64, RARLAB publishes the current Linux x64 build, and other environments ship only readers such as unrar or omit the writer entirely. The steps below assume a working rar command is already available in the shell.

Steps to create a RAR archive in Linux:

  1. Change to the parent directory that contains the files or folders to store.
    $ cd /tmp/rar-demo

    Paths passed after the archive name are stored relative to the current directory. Starting from the nearest useful parent keeps the archived path names predictable.

  2. Create the archive by naming the new .rar file first, followed by the file or directory paths to add.
    $ rar a demo.rar demo
    
    RAR 7.20   Copyright (c) 1993-2026 Alexander Roshal   1 Feb 2026
    Trial version             Type 'rar -?' for help
    
    Evaluation copy. Please register.
    
    Creating archive demo.rar
    
    Adding    demo/file-02.txt                                                29%  OK
    Adding    demo/file-01.txt                                                64%  OK
    Adding    demo/subdir/file-03.txt                                        100%  OK
    Adding    demo/subdir                                                      OK
    Adding    demo                                                             OK
    Done

    The a action adds files recursively when a directory name is supplied, so demo stores both its files and the nested subdir content in one archive.

  3. Confirm that the new file is a RAR archive before moving or uploading it.
    $ file demo.rar
    demo.rar: RAR archive data, v5

    The file output is a quick format check before the archive is copied to another system or attached elsewhere.

  4. List the archive contents without extracting anything.
    $ rar l demo.rar
    
    RAR 7.20   Copyright (c) 1993-2026 Alexander Roshal   1 Feb 2026
    Trial version             Type 'rar -?' for help
    
    Archive: demo.rar
    Details: RAR 5
    
     Attributes       Size     Date    Time   Name
    ----------- ----------  ---------- -----  ----
     -rw-rw-r--          5  2026-04-14 12:51  demo/file-02.txt
     -rw-rw-r--          6  2026-04-14 12:51  demo/file-01.txt
     -rw-rw-r--          6  2026-04-14 12:51  demo/subdir/file-03.txt
     drwxrwxr-x          0  2026-04-14 12:51  demo/subdir
     drwxrwxr-x          0  2026-04-14 12:51  demo
    ----------- ----------  ---------- -----  ----
                        17                    5

    rar l shows the stored paths and sizes without writing files to disk, which is the fastest way to confirm that the expected directory tree made it into the archive.

  5. Test the finished archive to verify that all entries can be read successfully.
    $ rar t demo.rar
    
    RAR 7.20   Copyright (c) 1993-2026 Alexander Roshal   1 Feb 2026
    Trial version             Type 'rar -?' for help
    
    Testing archive demo.rar
    
    Testing     demo/file-02.txt                                              30%  OK
    Testing     demo/file-01.txt                                              52%  OK
    Testing     demo/subdir/file-03.txt                                       77%  OK
    Testing     demo/subdir                                               OK
    Testing     demo                                                      OK
    All OK

    An All OK result confirms that the archive metadata and compressed file data can both be read cleanly, which is a stronger final check than only confirming that demo.rar exists.