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?
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?
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.
3. Which option is used with gzip command to check compression ratio for files?
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?
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?
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.
$ gzip -r dir_01 // compress all files in dir_01
6. Which of the following is used for decompressing files?
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.
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.
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?
b) bzip2 and bunzip2
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?
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.