7zip on Linux is a port from Windows. The man page explicitly cautions against using it as a general purpose backup solution on Linux because it does not preserve file permissions. It can be more useful than Unix zip for creating cross-platform archives, however, as 7zip can be used to encrypt both data and filenames in an archive with strong 256-bit AEC encryption (Unix zip uses relatively weaker encryption limited to 96-bits for circa 2008 export compliance).
On Ubuntu, 7zip is suppled by the p7zip-full package.
As the result of syntax changes over the years anyone using 7zip on Linux should pay careful attention to its man pages and release notes.
- Create a password protected archive of a file or folder:
7z a -p beta.7z beta
The 7z file extension is mandatory, unless you use the -t option to set a different archive type.
- Do the same thing but with header and data encryption turned on:
7z a -mhe=on -p beta.7z beta
Header encrpytion prevents the reading of file and directory names.
- Extract a 7zip archive:
7z x beta.7z