Skip to content

Instantly share code, notes, and snippets.

@kekneus373
Created January 12, 2026 15:19
Show Gist options
  • Select an option

  • Save kekneus373/875e0be0edd28b1eff6934354a265ceb to your computer and use it in GitHub Desktop.

Select an option

Save kekneus373/875e0be0edd28b1eff6934354a265ceb to your computer and use it in GitHub Desktop.
[7-Zip] Work with .7z from Terminal on Linux

To create a 7z archive in the Linux terminal, you can use the following command:

7z a archive.7z files_to_archive

Replace archive.7z with the desired name for your archive, and files_to_archive with the files you want to include in the archive.

If you want to specify additional options, such as compression level or password protection, you can use the following format:

7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z files_to_archive

This command creates a 7z archive with the following options:

  • -t7z specifies the archive type as 7z
  • -m0=lzma specifies the compression method as LZMA
  • -mx=9 specifies the compression level as maximum
  • -mfb=64 specifies the dictionary size
  • -md=32m specifies the memory limit for compression
  • -ms=on enables solid compression

You can customize these options to suit your needs.


To remove a file from a 7z archive, you can use the following command:

7z d archive.7z path/to/file_to_remove

Replace archive.7z with the name of your 7z archive, and path/to/file_to_remove with the path to the file you want to remove from the archive.

For example:

7z d archive.7z /path/to/file.txt

This command will remove the file file.txt from the archive.

If you want to remove multiple files, you can specify them separated by spaces:

7z d archive.7z file1.txt file2.txt file3.txt

If you need to remove files from a specific folder, you can use the -r option:

7z d -r archive.7z /path/to/folder/*

This command will remove all files from the specified folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment