Extract RAR and 7z archives on Linux
Open .rar and .7z files from the terminal with 7-Zip.
Run 7z x archive.rar -o./output-dir to extract the archive into a folder.
01Command
Command
$ 7z x photos.rar -o./photos && 7z x backup.7z02What it does
7z from p7zip-full reads dozens of archive formats, including RAR (except newest RAR5 variants) and its own 7z. The x switch extracts with the archive's internal folder structure, and -o points extraction at a directory you choose. If a RAR5 file is rejected, install the unrar package and run unrar x file.rar instead.
03Risk
!Warning: Extraction overwrites existing files in the target folder without asking. Extract into a fresh directory (-o./somewhere) rather than straight into ~/Downloads.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- 7z(1) — 7-Zip file archiverEvidence: 7z x extracts archives with full paths; -o sets the output directory and supports 7z, rar, zip and many other formats.
Last verified: 2026-09-18 · Category: Files & Folders