translations: [ es/Español ] · [ fr/Français ] · [ de/Deutsch ]
Table of contents
7z is a versatile and powerful command-line tool used for creating, extracting, and managing compressed archive files. It supports various compression algorithms, providing high compression ratios.
Basic Commands
Creating an Archive
To compress files into an archive using 7z, use the a
command followed by the archive’s name and the files you want to compress.
SHELL
# Create an archive named 'archive.7z' with files 'file1.txt' and 'file2.txt'
7z a archive.7z file1.txt file2.txt
Extracting an Archive
To extract files from an archive, use the e
command followed by the archive’s name.
Listing Contents
To view the contents of an archive without extracting it, use the l
command.
Compression Levels and Formats
Specifying Compression Levels
You can adjust the compression level using the -mx
flag followed by a value from 0 to 9, where 0 indicates no compression and 9 is the highest compression level.
Choosing Archive Formats
7z supports various archive formats. To specify a format, use the -t
flag followed by the format abbreviation.
Password Protection
Adding a Password
To protect your archive with a password, use the -p
flag followed by your chosen password.
File Exclusion and Inclusion
Excluding Files
You can exclude specific files or file types using the -x
flag followed by the file(s) or wildcard pattern.
Including Only Certain Files
To include only specific files or file types, use the -i
flag followed by the file(s) or wildcard pattern.
Created on: Jan 8, 2024
Discover More within this Subject:
- Usage of Tar Command for File Archiving in Linux
- Understanding SSH and Its Usage in Linux
- Essential Linux Network Commands for Webmasters
- Ways to Check Linux Distribution and Kernel Version
- Comperhensive Guide to Gzip in Linux