7-Zip command line parameters overview:
I wrote this realizing that the documentation I found in text format (from 7-Zip's ports in FreeDOS, and in 7-Zip 4.45 from one of the OpenBSD -current flavors before OpenBSD 4.2's release) weren't sufficient. Also, it wasn't immediately clear on the -m page that options like pass= really meant -mpass=.

To make small zip files that are generally compatible with other software that also uses zip files, try using the following:

7za a -tzip -mx=9 filename.zip file

To take longer during compression (although decompression may still go fast), the following may save a bit of space:

7za a -tzip -mx=9 -mfb=258 -mpass=15 filename.zip file

After the zip's filename, zero or more filenames may be specified. If zero, 7-Zip may compress all the data found in the current directory, including files and folders and the contents of the folders found.

Using -mx=9 may take a bit longer to create the zip file, but will often make zip files that are smaller than files created by other zip programs, but which are still usable (and seemingly extracting at a normal speed) by other Zip-compatible software. However, do note that 7-Zip has often reported bug fixes as improvements in new versions, implying that old versions would have some bugs. I have personally experienced some zip files where the extracted data is not identical to the original data, so it may be wise to verify the contents of data before deleting the originals. (In such cases, simply trying again to create a small zip file, just like what was attempted before, would typically work.) This may become less of an issue over time as the software is improved, but such verification is always good practice anyway, and there have been known cases where such checking has been good and useful.



Where filename is a *.sfx file, e.g.: -sfx7zCon.sfx

The *.sfx files should be bundled with 7-Zip. For the OpenBSD release the file was found in /usr/local/bin/p7zip/7zCon.sfx. /usr/local/share/doc/p7zip/MANUAL/switches/sfx.htm says: "All SFX modules are uncompressed. You can use UPX program (http://upx.sourceforge.net) to compresss such modules. After compressing by UPX program size of sfx module will be reduced to 40-50% of original size."

The 7-Zip for Windows installation, DOS port, and OpenBSD ports all came with 7zCon.sfx file. The 7-Zip for Windows port also came with a 7z.sfx (Windows version) file. There are also two other files mentioned in the 7-Zip for Windows documentation (the 7-zip.chm file): They are 7zS.sfx (Windows version for installers) and 7zSD.sfx: (Windows version for installers, that uses MSVCRT.dll). For the 7zS.sfx and 7zSD.sfx, archives can be made with:
copy/b 7zSD.sfx+config.txt+archive.7z archive.exe where the format for a config.txt file is documented in the Installer/readme.txt file included in the archive that comes with the 7zS.sfx and 7zSD.sfx files. (The format is also documented in the 7-Zip.chm file that comes with the Windows version of 7-zip, on the "Command Line Version", Switches, "-sfx (Create SFX archive)" page.)

The -t(archive_type) options are: -t7z, -tzip, -tgzip, -tbzip2, -ttar. -t7z is the default.

The 7zip.chm help file shows the effect of using a “method_parameter”. What might not be quite as clear is that these method parameters are meant to be combined with the -m option. So, when the 7zip.chm file describes that x=9 specifies Ultra compression, that is a method_parameter, and what is actually typed in the command line is -mx=9.

Where method_parameters can be:

Common method options
These compression methods are supported by all archive types except tar (when using -ttar). This documentation may be biased towards recommending options that increase compression ratio.
Compression Level: -mx={0, 1, 3, 5, 7, or 9}
Default is -mx=5. -mx=9 is maximum compression. -mx=0 is using no compression. If -ttar supports anything (I haven't tested this), I would imagine it would only support -mx=0. If the archive type is bzip2 (-tbzip2 is being used), then values less than 5 might not be supported: Specifically that guess is made since 7-Zip.chm doesn't give NumPasses values for compression levels under 5.
Multi-threading mode -mmt=on
-mmt=on (The default): Use Multi-threading mode on multi-processor systems and Pentium 4 systems with Hyperthreading. Or could use -mmt=off or -mmt=# where # is a number of threads to use. For compression, affects Deflate, Deflate64, Bzip2, and LZMA. For 7z format, though, it doesn't support Deflate. For decompression, affects Bzip2 and LZMA.
Additional format-specific options
If archive type (-t) is set to tar (-ttar)
There are no -m options listed (so even the above options aren't supported). This makes sense since tar does not compress. (One would imagine that -mx=0 and -mmt=off would make sense, but I haven't tested to see if this causes syntax errors or not.)
If archive type (-t) is set to bzip2 (-tbzip2)
BZip2 options:
Pass value: -mpass=#
-mpass=# where # is in range of 1 through 10 for Bzip2 (with archive type at Bzip2 -tbZip2, or as Archive type Zip -tzip and when using -mm=BZip2). (When using -tzip and -mm=Deflate, values of 11-15 are also permitted.) Usually big number gives little bit better compression. Default is -mpass=1 if -mx= is set to 5, 3, or 1 (although when -tbzip2 is set, no documented values exist), -mpass=2 if -mx=7, or -mpass=7 if -mx=9. Usually bigger numbers give better compression.
Method? Dictionary size?
One would think perhaps -mm=BZip2 would work, although that is not documented to work. Also, one would think perhaps -md (like the -tzip -m=Bzip2 -md900000 option), especially since the bzip2 program's command line parameters mention supporting block sizes from 100k to 900k. Maybe it isn't supported when -tbzip2 is used, though, as there is no documentation about such a thing in 7-zip.chm.
If archive type (-t) is set to zip (-tzip) or gzip (-tgzip)
Zip/GZip options:
Standard archive format options
As a reminder, Zip/GZip support the standard options mentioned above: -mm={MethodId}, -mx={CompressionLevelNumber}, and -mmt= for multi-threaded mode.
Encryption: -mem={EncryptionMethodID}
-mem=ZipCrypto (the default), -mem=AES256, -mem=AES192, -mem=AES128. The password is specified in a compeltely different option: -pPassword.
Compression Method: -mm={CompressionMethod}
Choose from some compression methods. (The 7z file format has a different way of specifying the CompressionMethod. The -mm= parameter is just meant for Zip/Gzip files.) Gzip supports the -mm=Deflate option, which is the default for Zip files as well. Zip files have more choices: Other options that could be specified instead of -mm=Deflate would be -mm=Copy, -mm=Bzip2, -mm=Deflate64. (The 7z file format also supports most of these compression types, but not Deflate64.)
More options, specific to the compression method
There are additional options, depending on the method used:
If using -mm=Deflate
Supports -mfb= and -mpass= as documented with the other methods, except -mfb= also supports -mfb=258 and -mpass= supports up to -mpass=15.
If using -mm=Deflate64
Fast Bytes: -mfb=#
-mfb=#, which can be from 3 to 257 (or up to 258 in the case of using -mm=Deflate). Defaults to 32. Bigger numbers "usually" gives a little bit better compression ratio and slows the process. "Big number of fast bytes parameter can significantly increase compression ratio in case when files contain long identical sequences of bytes." (Quoting 7-zip.chm.)
If using -mm=BZip2
See description under the -tbzip2 documentation.
Dictionary Size: -md=900000b
Sets dictionary size: Above example is for largest dictionary size: 900,000 bytes. Values can be specified with size suffix of b, k, or m (for bytes, kilobytes or megabytes). If a number is specified without a suffix, then the number of bytes will be equal to 2 raised to the specified power. Default value is 900000b.
If archive type (-t) is set to 7z (-t7z)
Standard options
Supports -mx=, -mmt=
Solid mode: -ms={on, or off, or e and/or #f and/or { #b or #k or #m or #g }
By default, it is set to -ms=on. Alternatives can be -ms=off, or to specify specifically how the solid mode should work, as in: -ms=e#f#b. To cover the latter example with each of its individual parts:
Extention-based method: -ms=e
If the e is mentioned, that specifies to use spearate solid block for each new file extention.
Number of files to use: -ms=#f
Sets the number of files in one solid block.
Solid block size: -ms=#b
Sets limit for total size of solid block in bytes. Alternative formats are -ms=#k for kilobytes, -ms=#m for megs, and -ms=#g for gigs. Default has to do with compression level: Store is -ms=0b, Fastest is -ms=16m, Fast is -ms=128m, Normal is -ms=512m, Maximum is -ms=2g, Ultra is -ms=8g.
The e, #f, and #b parts are documented separately. The e method has been documented as being left off, so that works. (e.g. -ms=#f#b).
Header options
Header compression: -mhc=on
Seems like a good idea. -mhc=off could be used. -mhc=on is default.
Full Archive Header Compression: -mhcf=on
Enables/disables full archive header compression. Archives created with -mhcf=on require 7-Zip 2.30 beta 25 or newer. -mhcf=off is also supported, but is not the default.
Header Encryption: -mhe=off
Default is off. -mhe=on is supported.
Bind streams: -mb{C1}[s{S1}]:{C2}[s{S2}]
Binds. See 7-zip documentation. The curly brackets around the C1 and S1 indicate those are not literal text, so should be replaced. The square brackets indicates an optional parameter, so the [s{Sx}] parts can be left off entirely. (So a simpler working example would be -mb{C1}:{C2} where {C1} and {C2} get replaced. ("If stream number is not specified, stream with number 0 will be used." I believe that refers to a file handle of 0 which would be standard input/output, so if I am understanding that, it probably means -mb{C1}:{C2} would be the same as -mb{C1}s0:{C2}s0 7-Zip.chm says: "Binds output stream S1 in coder C1 with input stream S2 in coder C2. If stream number is not specified, stream with number 0 will be used." Usually "coder has one input stream and one output stream. In 7z some coders can have multiple input and output streams." "For example, BC32 encoder has one input stream and four output sterams."
Method: -m#={MethodID}[:paramN]
Sets compression method. This is made up of several pieces:
The first compression method is zero (-m0=). If more than one is desired, then the next method is -m1=. "You can use any number of methods. The default method is LZMA."
This needs to be either a supported compression method's MethodID or supported compression filter's MethodID. The MethodIDs supported are as follows:
Compression MethodIDs
Lempel-Ziv-Markov algorithm (abbreviated LZMA) is based on Lempel-ZivZ, devloped by Igor Pavlov. Wikipedia's page says "Decompression-only code for LZMA generally compiles to around 5kB and the amount of RAM required during decompression is principally determined by the size of the sliding window used during compression. "
Dmitry Shkarin's PPMdH with small changes
Burros-Wheeler transform algorithm, by Michael Burrows and David Wheeler. (Also called block-sorting compression.) (The Wikipedia page linked to has some simple psuedo code.) Used by the compressor program bzip2.

Dmitry Shkarin's PPMdH with small changes.

Perhaps unrelated to 7-Zip, for PPM in general, references are: PPMD, Prediction by Partial Matching (compression), PPM. (Another compressor to check out for PPM usage is Matt Mahoney's PAQ).

LZ77 (Limpel-Ziv, 1977) compression plus Huffman coding. ( "Huffman compression" page name that redirects ) (not to be confused with Shannon-Fano, as I believe BCL did, perhaps mentioned in its source code) BCL PDF
No compression
Filter MethodIDs
In a broad sense, these act like the above Compression Method filter IDs (as far as how they are referenced on the command line), but cannot be used alone: "Filters must be used with one of the compression method (for example, BCJ + LZMA)." (per 7-zip.chm). These allow increased compression ratios for some types of files (especially executables, it would seem).
converter for x86 executables
converter for x86 executables (version 2)
BC_ARM and BC_ARMThumb
Converters for ARM/"ARM Thumb" (little endian) executables
converters for IA-64, PowerPC (big endian), and SPARC executables (respectively)
One or more optional parameters. The parameters depend on the compression method specified. One can have no parameters, or one, or multiple. (That is why :paramN is surrounded in square brackets in the above documentation: Every occurence of :paramN is optional.) The colon before each parameter is required.
If the methodID is LZMA
Methods include:
Compression mode :a=1
Default is 1 (normal). :a=0 can be used to specify fast.
Dict Size :d=64m
Can be specified in bytes (e.g. :d=10000b) or kilobytes (:d=4k) or megabytes (:d=64m). Above example is 64 megs. Maximum is 1 GB (2^30 byte). Leaving off the suffix (not specifying b for bytes, k for kilobytes or m for megs) will equate to a number of bytes which is 2 raised to the specified power. Defaults are 22 (4m) in normal mode, 24 (16m) in maximum mode, 26 (64m) in ultra mode.
Match finder :mf={MF_ID}
See 7-zip.chm
Fast Bytes :fb=#
Sets number of fast bytes. Default is 32 for normal mode and 64 for maximum and ultra modes. Range is 5-273. Usually big number gives a little bit better compression ratio. (I wonder if the quote by the -mfb option applies here, where it said: "Big number of fast bytes parameter can significantly increase compression ratio in case when files contain long identical sequences of bytes." (Quoting 7-zip.chm.) 7-zip.chm did not put that quote by this fast bytes.)
Match finder cycles :mc=#
See 7-zip.chm for more documentation. Can range from 0 to 1000000000. (default is 16 + the :fb value / 2, or 8+ :fb /4)
Literal Context bits :lc=#
Sets number of literal context bits (high bits of previous literal). Can be 0-8. Default is 3. Sometimes lc=4 gives gain for big files.
Sets number of literal pos bits (low bits of current position for literals). Can range from default of 0 up to 4. Reading from 7-zip.chm, one can find the :lp switch is intended for periodical data when the period is a number of bytes equal to the number 2 raised to the value of the :lp switch. For example, 32-bit (4 bytes) periodical data may benefit with :lp=2. Often it is better to set :lc=0 when the :lp switch is changed.
Number of pos bits :pb=#
Sets number of pos bits (low bits of current position). Can range from 0 to 4, and has a default of 2. pb switch is intended for periodical data when the period is equal to 2 raised to the number of "value". (The 7-zip.chm then says "(where lp=value)", indicating the number specified in the :lp parameter, although it says the same thing in the :lp documentation section, so I wonder if "value" really refers to the value set by the pb parameter.
If using PPMd MethodID
The parameters can be one of the following values:
Sets the size of used memory for PPMd. PPMd uses the same amount of memory for decompressing as what it uses to compress. The number can include a suffix of b, k, or m to specify bytes, kilobytes, or megs. e.g. :mem=768k. If there is no suffix, the number of bytes is equal to 2 raised to the specified number. Default value is 24 (which is 2 raised to 24 bytes, which is 16MB).
Sets model order for PPMd. Default is 6, and can rage from 2-32.
If using BCJ2 MethodID
7-zip.chm has note.
(End of breakdown of -m#={MethodID}[:paramN])
(End of format-specific options that are specific to -t7z)
(End of listing the various archive types that have special options)
(End of compression options types)
Specifies password. e.g. -psecret uses a password of secret. Note that in a multi-user system, other users can often see what commands people run (using ps), and so it may be good to perform this on a single-user system, or to use a password file. (However, I haven't seen any documentation about 7-zip being able to use a password file.) (See also the -mem= option, and -mhe option.)

Note: For more information about data compression, see ][CyberPillar]['s guide to data compression.

Here are some older notes written.

Some misc notes
Above example contains three parts: Not all are needed. e means to "Use separate solid block for each new file extension" 100f means to set the limit for the number of files in one solid block (to 100 files) 8g means to use that as a limit for the solid block size. default values are dependent on compression level: Store=0b Fastest=16m Fast=128m Normal=512m Maximum=2g Ultra=8g. Also 0k should be valid. (s parameter also supports options of off and on. The default is on.)
LZMA settings:
-m0=LZMA:d=0b. Maximum is documented as "1 GB" (which would be 1073741824b, presumably 1024m. "For decompressing file compressed by LZMA method with dictionary size N you need about N bytes of memory (RAM) available." So that would require 1G of RAM. Ultra mode -mx=9 uses 64M by default. -d=450k might be good idea if one is expecting to extract on a DOS machine. fb=273 (default 32 or 64, can be as low as 5) -m0=LZMA:mc=1000000000 (default is 16 + the fb value / 2, or 8+fb/4) -m0=LZMA:lc=8
PPMd: mem=amount (maximum is 2GB, default is 24M) (PPMd uses same amount of memory to decompress, as to compress)
Dictionary size
d=400k (sets dictionary size: "For decompressing file compressed by LZMA method with dictionary size N you need about N bytes of memory (RAM) available."