15 February 2012

7zip command line examples and password-protection (7z, 7za)

7zip is a nice, cross-platform compression software, similar in purpose to WinZip or GZip.  &zip can create and extract those .zip and .gz (and tar.gz) files, but it uses LZMA for its own native compression, which is a much more modern compression format.  (if you're using .rar, please stop already).

Use 7zip to create a password-protected file of a list of files and directories; note the flags -p -mhe which are REQUIRED for the password part to function!  7zip uses AES encryption with 256-bit keys, so this encryption isn't joking around.

Some basic command-line examples for using 7zip are listed below, which is run with either 7z or 7za on a GNU/Linux system, the 7za being a bit less capable but also has fewer dependencies.

To Archive the files and folders 'test/ test2/ file1 file2'
shell$ 7z a -t7z -p -mhe out-file.7z test/ test2/ file1 file2
Scanning
Updating archive out-file.7z
Enter password (will not be echoed) :
Verify password (will not be echoed) :
Everything is Ok

To List the files:
shell$ 7z l out-file.7z

And to Extract the files:
shell$ 7z e out-file.7x 

There is also a graphical (GUI) version for Windows (with the password option) and KDE's Ark can also create .7z files, but I don't see a way to do that with the password protection in KDE's Ark (yet!)

Again, note the flags -p -mhe which are REQUIRED for the password part to function.  More info about 7zip command line examples here.

0 comments: