Administering Networking OS — Archiving and Compression #7
College Online Material
Published in
2 min readMay 3, 2021
Archiving Vs. Compression
Archiving collapses multiple files into one. A few files or multiple directories.
Compression makes a file smaller
- Remove redundant info, replace it with a smaller code
- Can be applied to individual files, groups of files, or entire dir. tree
Uses of Archiving and Compression
- Managing log files
- Sharing groups of files (Project doc, source code, etc)
- Compressing for more efficient transfer. Fewer data to send over the internet or to tape
- Keep like files together grouped by time (Backups)
Lossless Vs. Lossy Compression
Lossless
- The decompressed file is the same as the original
- Doesn’t compress as well as lossy
- Logs, documents, binaries, configuration, etc
Lossy
- The decompressed file might have lost info from the original
- Drops “unimportant” info from the file to make it compress better
- Images, sound, movies, etc
Gzip Vs. Bzip2
Gzip
- gzip and gunzip
- Uses Lempel-Ziv coding
- Lossless compression, good efficiency
$ gzip anime
removes anime file, create anime.gz (compress)$ gunzip anime.gz
removes anime.gz, create anime file (uncompress)$ gunzip -l anime.gz
show statistic
Bzip2
- bzip2 and bunzip2
- Burrows-Wheeler block sorting
- Lossless compression slightly more efficient than gzip, but requires more CPU
- Uses almost identically as gzip
$ bzip2 anime
removes anime file, create anime.bz2 (compress)$ bunzip2 anime.bz2
remove anime.bz2, create anime file (uncompress)
Tape Archive (TAR) Vs. ZIP
TAR
$ tar -cf anime.tar yakusoku*
archive tar file dari file yakusoku$ tar -tf anime.tar
show info$ tar -xf anime.tar
extract
ZIP
$ zip anime.zip gotoubun1 yakusoku2 yakunara3
create zip file from multiple file$ zip anime.zip gotoubun1
create zip file from one file$ zip -r anime.zip Downloads
recurse from other dir.$ unzip -l anime.zip
show contents$ unzip anime.zip
extract all file from anime.zip$ unzip anime.zip gotoubun1
extract one file$ unzip anime.zip Downloads/test/*
everything under Downloads/test/* will be archive