Unix Questions and Answers – Compressing and Archiving Files – 1

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Compressing and Archiving Files – 1”.

1. Which of the following is used to compress files?
a) cmp
b) gzip
c) gunzip
d) comm
View Answer

Answer: b
Explanation: To conserve disk space we need to compress a file. gzip is a very popular program used with one or more filenames for compression.

$ gzip  file01.txt

2. Which one of the following extension is provided by gzip to the compressed filename?
a) .cm
b) .gz
c) .zip
d) .zp
View Answer

Answer: b
Explanation: gzip adds an extension to the filename after compressing it and removes the original file. For example, if we compress a file named file01.txt using gzip then the new filename will be file01.txt.gz.
advertisement
advertisement

3. Which option is used with gzip command to check compression ratio for files?
a) -l
b) -c
c) -e
d) -x
View Answer

Answer: a
Explanation: Compression ratio is the ratio of, size of the original file to the size of a compressed file. We can check how much compression ratio is achieved using -l option with gzip.

$ gzip -l abd.txt.gz  file01.txt.gz
Compressed    Uncompressed        Ratio    	Uncompressed name
788096        3875302             79.6%    	 abd.txt
128341        372267              65.5%    	 file01.txt
916437        4247569             78.9%    	 (totals)

4. We can provide original filenames without .gz extension while checking compression ratio using gzip – l?
a) True
b) False
View Answer

Answer: a
Explanation: Specifying the .gz extension is an optional feature which may be neglected. The command will work properly even without the extension.

5. Which option is used with gzip command for recursive compression?
a) -c
b) -l
c) -d
d) -r
View Answer

Answer: d
Explanation: Like many other UNIX commands, we can perform recursive compression. Through this process, we can compress all files in the directory. To perform this operation, -r option is used with gzip command.

advertisement
$ gzip  -r  dir_01        		// compress all files  in dir_01

advertisement

6. Which of the following is used for decompressing files?
a) GZIP
b) gunzip
c) uncmp
d) cmp
View Answer

Answer: b
Explanation: To restore our original and uncompressed file we can use gunzip with filename as an argument.

$ gunzip  file_01.txt.gz

7. We cannot uncompress files using gzip.
a) True
b) False
View Answer

Answer: b
Explanation: gzip can also be used to uncompress files, all we have to do is to use -d option with gzip command.

$ gzip -d file01.txt.gz

8. We can provide multiple filenames as arguments to gunzip.
a) True
b) False
View Answer

Answer: a
Explanation: Multiple files can be unzipped using gunzip command by providing multiple filenames as arguments to the command.

9. Which of the following is a better agent than gzip?
a) bzip2
b) bzip2 and bunzip2
c) bunzip2
d) allzip
View Answer

Answer: b
Explanation: For many years, gzip remained as the most favorite compression utility but now we have a better one called bzip2 (bzip2 and bunzip2). bzip2 is slower than gzip and it creates files with .bz2 extension.

10. Which of the following is an archival program?
a) arch
b) archive
c) ar
d) tar
View Answer

Answer: d
Explanation: For archiving files to the disk we use tar. It can be used to archive a group of files or an entire directory structure. tar program provides a handful of utilities like creating, maintaining, modifying and extracting files that are in tar format. Tar stands for ‘tape archival’.

Sanfoundry Global Education & Learning Series – Unix.

To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.