7zip The 7z file format uses a combination of various compression algorithms, with the primary one being LZMA (Lempel-Ziv-Markov chain algorithm). LZMA is known for its high compression ratio and fast decompression. Here is an overview: - *LZMA/LZMA2:* This is the default and most commonly used algorithm when creating 7z archives. LZMA2 is an improved version of LZMA, offering better multithreading support. - *PPMd:* Stands for Prediction by Partial Matching, which is good at compressing text data. - *BCJ/BCJ2:* These are Branch/Call/Jump conversion filters that pre-process executable files to improve compression. - *DEFLATE:* A widely used compression algorithm that is also used in ZIP file format. - *BZip2:* Another block-sorting compression algorithm that is particularly effective at compressing large text files. Here are some technical details of LZMA/LZMA2, in case they are needed for advanced utilization: - *Dictionary size:* Highly customizable, allowing the compressor to store patterns, which can dramatically affect compression ratio and memory requirements. - *Compression speed versus Decompression speed:* These are adjustable; typically, LZMA offers slower compression speeds but fast decompression speeds. - *Multi-threading support:* LZMA2 in particular can utilize multiple processor cores to improve compression speed on modern computers. For archival purposes using 7z, it is also possible to enable solid compression, which treats multiple files within the archive as a single data block for potentially better compression ratios. Encryption algorithm : AES-256 Terminal https://www.redhat.com/sysadmin/encrypting-decrypting-7zip Encrypting ```bash $ tar -cf directory.tar $ 7z a -p -mhe=on directory.tar.7z directory.tar or 7z a -pYourPassword -mhe=on directory.tar.7z directory.tar ``` Here a means adding files to archive mhe=on means header encryption means metadata like file names will be encrypted too For non interactive password typing type password just after `-p` with no space also for level of compression `7z a path/to/archive.7z -mx=0|1|3|5|7|9 path/to/file_or_directory` 0 means lowest compression while 9 being highest   **for exluding directories** To exclude directories when creating a 7z archive, use the -x switch with the ! wildcard operator, and add an r flag (for recursive) to the switch name if the directories might be in subfolders. The basic syntax for creating an archive and excluding a specific directory named exclude_dir is: `7z a archive.7z source_dir/ -xr\!exclude_dir/` dont forget `\` before `!` as ! is reserved for events Decrypting ```bash 7z x archive.7z ``` here x means extracting mroe flags - `-aoa`: Overwrite All existing files without asking - `-aos`: Skip extracting any files that already exist (prevents replacing). - `-aou`: Auto-rename the extracted file (e.g., file_1.txt) if the target name exists. - `-aot`: Auto-rename the existing file and extract the new one.   **for splitting** `7z a -v100m archive.7z my_folder/` for mass compression of folders ```sh #!/bin/bash # Check if 7z is installed if ! command -v 7z &> /dev/null then echo "7z command not found! Please install 7zip." exit 1 fi # Loop through all directories in the current directory for dir in */; do # Make sure it's a directory if [ -d "$dir" ]; then # Remove the trailing slash from the directory name dir_name=${dir%/} # Create a .7z archive for each directory echo "Creating archive for $dir_name..." 7z a "${dir_name}.7z" "$dir_name" fi done echo "Done!" ```   to print only filepaths instead of other info `7z l -ba archive.7z | grep -oP '(?<=^.{53}).*'` from https://stackoverflow.com/questions/55355466/7z-list-only-filenames to list only top level use this `7z l -ba archive.7z | grep -oP '(?<=^.{53}).*' | grep -v '/'`