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).
4 Answers
Read 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
- 37,856
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.
- 171
You should use tar -Jchf <Filename>.tar.xz <Files to compress>
The -J uses the XZ compression algorithm, the same as 7zip
-c creates a new file
-h preserves simlinks
-f sets the filename
- 41