Gzip:
- Gzip is used to compress a file. To zip "thisfile", type gzip thisfile. You'll get a file named thisfile.gz.
- $gzip thisfile
- $thisfile.gz
- To unzip thisfile.gz, type gunzip thisfile.gz.
- $gunzip thisfile.gz
- Gzip supports 9 levels of compression; 1 being the fastest and least compressed; 9 being the slowest and most compressed; 6 being the default. To get the best compression, use the command: gzip -9 readme
Tar:
- Tar is used to pack the entire contents of a directory or directories into a single file called a tarball.
- Tar preserves the entire directory organization including file ownership, permissions, links, and the directory structure.
- The most commonly used tar functions are:
- c - create an archive
- x - extract files from an archive
- t - list the contents of an archive
- v - verbose
- f filename - use the specified file
- z - gzip/gunzip
Examples: Back |up the contents of the home directory for gemini (/home/gemini) in a tarball called a.tar on a floppy disk.
mount /floppy
cd /home
tar -cvf /floppy/a.tar gemini
Explanation:- Change to the parent of the /home/gemini directory.
- Create a backup of gemini in the file /floppy/a.tar.
- Now, check the contents of the tarball that you just created.
cd /floppy
tar -tvf a.tar
- Back |up the contents of the etc directory in an archive called etc.tar . Make sure that the archive is created in your own home directory.
cd /
tar -cvf ~/etc.tar etc
Explanation:- Change to the parent of the /etc directory.
- Create a backup of etc in the file ~/etc.tar
- Back |up and compress the contents of the home directory into the tarball home.tgz on a floppy disk.
mount /floppy
cd /
tar -cvzf /floppy/home.tgz home
Explanation:- change to the parent of the /home directory
- Create a compressed backup of home in the file /floppy/home.tgz.
- Now check the contents of the archive that you just created.
cd /floppy
tar -tvzf home.tgz
- Unpack the archive home.tgz on your floppy.
cd /floppy
tar -xvzf home.tgz
Explanation:- change to the /floppy directory
- unpack and unzip the tarball home.tgz
No comments:
Post a Comment