23

On the Windows command-line, I can extract archives like this:

7za e somefile.zip

I know 7-Zip supports .rar in the GUI, but can it be done in commandline mode?

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Richard
  • 231
  • 1
  • 2
  • 3

2 Answers2

22

Yes, you can extract .rar archives from the command line, but only if you use 7z, not 7za:

7za.exe (a = alone) is a standalone version of 7-Zip. 7za.exe supports only 7z, lzma, cab, zip, gzip, bzip2, Z and tar formats. 7za.exe doesn't use external modules.

The above applies to both Linux and Windows and the syntax is identical:

Windows:

C:\Users\me>7z e dll-test.rar
7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Processing archive: dll-test.rar

Extracting  mso97.dll

Everything is Ok

Size:       3782416
Compressed: 1857291

Linux:

[me ~]$ 7z e dll-test.rar

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs)

Processing archive: dll-test.rar

Extracting  mso97.dll

Everything is Ok

Size:       3782416
Compressed: 1857291
Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
don_crissti
  • 2,804
  • 1
  • 20
  • 20
  • 1
    Fair warning: `7za.exe` doesn't support `.rar` only the `7z.exe` does. – Matt Clarkson Feb 18 '14 at 15:00
  • To get the `7z` command, and not just the `7za` command on Fedora, I had to also install the `p7zip-plugins` package. – zymhan Jul 23 '20 at 15:19
  • How do you get 7z.exe without admin privileges though? It seems the only way to do it is to install it in a UAC protected location. 7-Zip Portable would be a good example of it, but they bundle and run their own code instead of giving you a zip of the binary, so I don't trust them – Pluto Jan 25 '23 at 23:18
5

You can see all command lines in the "7-zip.chm" help file (from the installation):

Extracting rar is like extracting all files:

7z x archive.rar

For example:

"C:\Program Files\7-Zip\7z.exe" x "C:\Archives\test file.rar"
Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
DimitriD6
  • 51
  • 1
  • 1