A 7-Zip file with the extension .7z is a compressed file format that can be extracted using p7zip tool in Linux. p7zip is available for most Linux systems and can easily be installed at the terminal. Once installed, 7-Zip files can then be extracted from the terminal or supporting GUI-based file explorer applications such as Nautilus for GNOME or Dolphin for KDE.

Extract 7-Zip file in Linux:

  1. Launch terminal application.
  2. Install p7zip (optional, if not already installed).
    $ sudo apt update && sudo apt install --assume-yes p7zip #Ubuntu and Debian
    [sudo] password for user:
    ##### snipped
    Suggested packages:
    The following NEW packages will be installed:
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 358 kB of archives.
    After this operation, 996 kB of additional disk space will be used.
    ##### snipped
  3. Create folder where you want to extract the file onto (optional).
    $ mkdir target_directory
  4. Go to the target directory where you want to extract the file onto (optional).
    cd target_directory
  5. Extract using p7zip command.
    $ p7zip --decompress ~/archive.7z
    7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
    p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz (306D4),ASM,AES-NI)
    Scanning the drive for archives:
    1 file, 183 bytes (1 KiB)
    Extracting archive: /home/user/archive.7z
    Path = /home/user/archive.7z
    Type = 7z
    Physical Size = 183
    Headers Size = 183
    Solid = -
    Blocks = 0
    Everything is Ok
    Folders: 3
    Files: 4
    Size:       0
    Compressed: 183

    Decompressing a 7-Zip archive will delete its original file. Please make a backup if required.

    Common options for p7zip command:

    $ p7zip --help
    Usage: /usr/bin/p7zip [options] [--] [ name ... ]
        -c --stdout --to-stdout      output data to stdout
        -d --decompress --uncompress decompress file
        -f --force                   do not ask questions
        -k --keep                    keep original file
        -h --help                    print this help
        --                           treat subsequent arguments as file
                                     names, even if they start with a dash
  6. View decompressed 7-zip archive.
    $ ls -l
    total 4
    drwxrwxr-x 4 user user 4096 Jul 29 13:16 archive
  7. Right click the file on Nautilus or Dolphin to extract the file from the GUI.
Discuss the article:

Share your thoughts, suggest corrections or just say Hi. Login not required.