Compressing and Decompressing Files
Creating archive
tar cvf example.tar /sourcedir
Extracting archive
tar xvf example.tar
Two main compression commands:
- gzip
- bzip2
- gzip example:
gzip bigfile.stuff
gzip -d bigfile.stuff.gz
- bzip2 example:
bzip2 bigfile.stuff
bzip2 -d bigfile.stuff.bz2
Compress an archive
Tar does not compress by default
tar czvf home.tar.gz /home
or
tar cvjf home.tar.bz2 /home
Extracting:
tar xzvf home.tar.gz /home
or
tar xvjf home.tar.bz2 /home
Zip Files
Used for files that need to be managed on both Windows and Linux servers. Zip is similar to tar, but automatically try’s to compress files.
Examples:
zip -r archivename /home
unzip archivename