I would like to zip up my homework from last year. How do I tar and zip the whole folder from command line Ubuntu (I don't have GUI).
It is not a good idea compressing directly with 7z spcially on unix/linux systems: 7z does not preserve permissions and or user/group info. So: first tar, and then compress.
As reported on 7zip wiki page at http://en.wikipedia.org/wiki/7z#Limitations :
The 7z format does not store filesystem permissions (such as UNIX owner/group permissions or NTFS ACLs), and hence can be inappropriate for backup/archival purposes. A workaround on UNIX-like systems for this is to convert data to a tar bitstream before compressing with 7z.
man tar. It offers:
-a, --auto-compress use archive suffix to determine the compression program -j, --bzip2 --lzip --lzma --lzop -z, --gzip, --gunzip --ungzip -Z, --compress, --uncompress
Or, if none of those is right for you, and you have a compression program that reads
stdin, you could:
tar cf- $HOME | my_compression_program >/tmp/compressed.output
Note that I'm writing the output somewhere other than
$HOME (backing up into a directory that you're backing up leads to unconstrained file growth).
Or, you could read
man 7z - it looks like you could do
dir="directory to save" 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on /tmp/archive.7z $dir
I would suggest that you use:
tar cf - foldername | 7z a -si -m0=lzma2 -mx=3 foldername.tar.7z
for dramatic speedup increase.
It has the advantage of using lzma2 (
-m0=lzma2) (which utilizes max available cores on your system and "Fast compression" preset (
-mx=3), which is basically fast and good enough.
Note that LZMA2 is not only utilizing all cores on compression, but also on decompression.