How to Change Unrar Temporary Directory

When extracting large RAR archives, unrar may exhaust the storage capacity of your operating system's default temporary partition. You can resolve this by redirecting unrar's temporary file buffer to an alternative drive or folder. This guide covers how to set a custom temporary directory using the command-line -w switch, system environment variables, and persistent configuration files across Linux, macOS, and Windows.

Method 1: Use the Command-Line Switch (-w)

The most direct way to specify a working directory for temporary files during extraction is using the -w switch.

Linux / macOS:

unrar x -w/path/to/custom_tmp archive.rar

Windows:

unrar x -wD:\CustomTemp archive.rar

Note: In standard RAR/UNRAR syntax, do not include a space between the -w switch and the directory path. Ensure the target folder already exists and your user account has write permissions to it.


Method 2: Change Environment Variables

If you do not want to specify the -w flag every time, unrar adheres to standard operating system temporary directory variables when a working directory is not explicitly defined.

On Linux / macOS

Set the TMPDIR variable inline before running the command:

TMPDIR=/path/to/custom_tmp unrar x archive.rar

To make this change permanent for your shell session, export the variable:

export TMPDIR=/path/to/custom_tmp

On Windows

Change the TEMP or TMP environment variable in Command Prompt:

set TEMP=D:\CustomTemp
set TMP=D:\CustomTemp
unrar x archive.rar

Method 3: Make the Change Persistent via Configuration File

To permanently assign a default working directory without modifying global system environment variables, add the switch to the rar configuration file.

On Linux / macOS

Open or create the configuration file at ~/.rarrc (user-specific) or /etc/rarrc (system-wide):

nano ~/.rarrc

Add the -w switch followed by the path on its own line:

-w/path/to/custom_tmp

Save and exit. Whenever unrar runs, it reads this file automatically and directs temporary unpack buffers to the specified location.

On Windows

Create or edit rar.ini in the same directory where unrar.exe is located, or inside %APPDATA%\WinRAR\:

-wD:\CustomTemp