Professional Documents
Culture Documents
21MCA2234 Linux Worksheet 2.2
21MCA2234 Linux Worksheet 2.2
21MCA2234 Linux Worksheet 2.2
Aim- To compress and backup files using compression and archiving commands respectively.
Task to be done-
1. You wish to restore the file named ABC.txt which was backed up in the tarfile with name
MyBackup.tar. What command should you type? Use an option of gzip command to
compress a tar file MyBackup.tar. Now create a file with name MyBackUp.tar and then
try to search a file named MyBackup.tar using regular expressions after executing listing
command.
2. Create a file named try.txt and write about yourself in about 20 lines. Now check the size
of the file. Reduce the size of this file using zip and also add a comment to zipfile also.
After compression, check the size of file again.
Concept Used-
Compression and Archiving commands
Synta Description Example(
x s)
gzip {filename} Gzip compress the size of gzip
the given files using mydata.doc
Lempel-Ziv coding (LZ77). gzip *.jpg
Whenever possible, each
file is replaced by
one with the extension .gz.
bzip2 {filename} bzip2 compresses files using bzip2
the Burrows-Wheeler block mydata.doc
sorting text compression bzip2 *.jpg
algorithm, and Huffman
coding. Compression is
generally considerably better
than that achieved by bzip
command (LZ77/LZ78-based
compressors). Whenever
possible, each file is replaced
by one with the extension
.bz2.
zip {.zip-filename} zip is a compression and file zip mydata.zip
{filename-to- compress} packaging utility for mydata.doc zip
Unix/Linux. Each file is data.zip *.doc
stored in single .zip
{.zip-filename} file
with the extension .zip.
tar -zcvf {.tgz-file} The GNU tar is archiving tar -zcvf data.tgz *.doc
{files} tar -jcvf {.tbz2- utility but it can be use to tar -zcvf pics.tar.gz *.jpg
file} {files} compressing large file(s). *.png tar -jcvf data.tbz2
GNU tar supports both *.doc
archive compressing through
gzip and bzip2. If you have
more than 2 files then it is
recommended to use tar
instead of gzip or bzip2.
-z: use gzip compress
-j: use bzip2 compress
2.
i. creating try.txt and adding 20 lines
$vi try.txt
ii. checking size of try.txt file
$ls -lh
iii.compressing try.txt using zip command with comment
$zip -c try.zip try.txt
1.
Figure 1.1
Figure 1.2
Figure 1.3
Figure 1.4
Figure 1.5
2.
Figure 2.1
Figure 2.2
Figure 2.3
Figure 2.4
Learning Outcomes:
1. Compressing files using zip,gzip,bzip2 commands
2. Decompressing files.
3. Archiving files using tar command.
4. Archiving and compressing files.
5. Unarchiving files.
Evaluation Grid:
Sr. Parameters Marks Maximum
No. Obtained Marks
1. Worksheet 10
2. Demonstration/Performance 5
/Pre Lab Quiz
3. Post Lab Quiz 5