Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

zip and unzip can perform each and every function that is performed by gzip, gunzip and tar.(a) True(b) FalseThis question was posed to me in homework.This interesting question is from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

Right choice is (a) True

To elaborate: Using zip and unzip command we can compress, archive, uncompress FILES. So these two COMMANDS can PERFORM all the functions which are PERFORMED by gzip, gunzip and TAR.

2.

Which option is used with unzip command to view the contents of a compressed archive?(a) -v(b) -t(c) -c(d) -xI had been asked this question at a job interview.I want to ask this question from Compressing and Archiving Files topic in division Handling Ordinary Files of Unix

Answer»

The correct option is (a) -V

Explanation: We can view the COMPRESSED archive using the -v option. The OUTPUT list will show both compressed and uncompressed size of each file in the archive ALONG with the PERCENTAGE of compression achieved.

3.

If the uncompressed file already exists on disk, unzip asks for the user confirmation whether to replace the existing file or not.(a) True(b) FalseI got this question during an online interview.Query is from Compressing and Archiving Files topic in portion Handling Ordinary Files of Unix

Answer»

Correct CHOICE is (a) True

For EXPLANATION I WOULD SAY: If we invoke the following command,

4.

Which command is used for unzipping files which are compressed using zip command?(a) gunzip(b) gzip(c) unzip(d) guzipI got this question in class test.My doubt is from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

Right option is (c) unzip

For explanation: unzip command is used for RESTORING FILES which are compressed USING zip command. To unzip a file, SIMPLY type the filename as an ARGUMENT with unzip command.

5.

For recursive compression, zip uses -r option.(a) True(b) FalseThis question was addressed to me in examination.My query is from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

Correct answer is (a) True

For EXPLANATION I would SAY: Just like other UNIX commands, zip command can also perform recursive COMPRESSION. In recursive compression, it will compress all the subdirectories and files that will be ENCOUNTERED while tracing the tree STRUCTURE.

6.

For using zip command, the first argument should be a compressed filename.(a) True(b) FalseI had been asked this question in an interview.I need to ask this question from Compressing and Archiving Files topic in portion Handling Ordinary Files of Unix

Answer»

The correct option is (a) True

For explanation I would say: For using ZIP COMMAND, the FIRST argument should be a COMPRESSED filename, the REMAINING arguments are interpreted as files and directories to be compressed.

7.

Which command is used for compressing and archiving files together?(a) gzip and tar(b) gzip(c) bzip2(d) zipThis question was posed to me in semester exam.I need to ask this question from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

The correct OPTION is (d) zip

To elaborate: zip command combines the work of both GZIP and tar i.e. it can COMPRESS and archive files together. The compression ratio using zip is lower as COMPARED to bzip2 or gzip.

8.

Which option is used by tar to append files to the end of an archive?(a) -t(b) -c(c) -x(d) -rI have been asked this question in exam.My doubt stems from Compressing and Archiving Files in division Handling Ordinary Files of Unix

Answer»

The correct OPTION is (d) -r

The EXPLANATION: We can append files to an archive which is CREATED already using -r option with TAR.

9.

To create an archive named abc.tar consisting of two files,file01 and file02, which of the following command will be used?(a) tar -cvfabc.tarfile01file02(b) tar -cvffile01file02abc.tar(c) tar -cvabc.tarfile01file02(d) tar -cabc.tarfile01file02This question was addressed to me in an internship interview.This key question is from Compressing and Archiving Files in chapter Handling Ordinary Files of Unix

Answer»

Correct choice is (b) TAR -cvffile01file02abc.tar

To EXPLAIN I WOULD say: To create an archive -c option is used, -v is used to display the progress while tar works while -f is used to specify the name of the archive. All these OPTIONS can be combined together as (-cvf).

10.

Which command will be used for extracting files from an archive named abc.tar?(a) tar -xvfabc.tar(b) tar -cvfabc.tar(c) tar-tvfabc.tar(d) tar-tabc.tarThe question was asked in homework.Asked question is from Compressing and Archiving Files in chapter Handling Ordinary Files of Unix

Answer» CORRECT choice is (a) tar -xvfabc.tar

The best EXPLANATION: To EXTRACT files from an archive, we can use -x OPTION along with -v and -f. Above command will extract all the files which are present in the archive named abc.tar.
11.

Which of the following command is used for viewing the attributes of contents of an archive?(a) tar -tvfabc.tar(b) tar -cvfabc.tar(c) tar-xvfabc.tar(d) tar-tabc.tarI got this question in quiz.Origin of the question is Compressing and Archiving Files topic in section Handling Ordinary Files of Unix

Answer»

Correct answer is (a) tar -tvfabc.tar

To explain I would say: -t OPTION is used with tar for viewing the contents of the ARCHIVE in a table manner. It does not extract files rather it simply shows their ATTRIBUTES in a suitable form CONTAINING file permissions, file size and file name.

12.

Which of the following key options is used with tar to create an archive?(a) -c(b) -x(c) -t(d) -farchive nameThe question was asked during an online exam.This interesting question is from Compressing and Archiving Files in portion Handling Ordinary Files of Unix

Answer» RIGHT option is (a) -c

To explain: The TAR PROGRAM USES these specified key options where each key option performs a specific function.
13.

Which of the following is an archival program?(a) arch(b) archive(c) ar(d) tarThis question was posed to me in an interview.I need to ask this question from Compressing and Archiving Files in chapter Handling Ordinary Files of Unix

Answer»

Right option is (d) tar

The explanation is: 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’.

14.

We can provide multiple filenames as arguments to gunzip.(a) True(b) FalseI had been asked this question in exam.My question is from Compressing and Archiving Files in chapter Handling Ordinary Files of Unix

Answer»

Correct option is (a) True

Best EXPLANATION: MULTIPLE files can be UNZIPPED using gunzip command by providing multiple FILENAMES as arguments to the command.

15.

Which of the following is a better agent than gzip?(a) bzip2(b) bzip2 and bunzip2(c) bunzip2(d) allzipI got this question in my homework.I'd like to ask this question from Compressing and Archiving Files topic in chapter Handling Ordinary Files of Unix

Answer»

The correct option is (b) BZIP2 and bunzip2

Best 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.

16.

We cannot uncompress files using gzip.(a) True(b) FalseThe question was posed to me in an online quiz.Query is from Compressing and Archiving Files topic in chapter Handling Ordinary Files of Unix

Answer»

The CORRECT OPTION is (b) False

To ELABORATE: gzip can ALSO be used to uncompress files, all we have to do is to use -d option with gzip command.

17.

Which of the following is used for decompressing files?(a) GZIP(b) gunzip(c) uncmp(d) cmpThis question was addressed to me during an online interview.This question is from Compressing and Archiving Files topic in section Handling Ordinary Files of Unix

Answer» RIGHT choice is (B) gunzip

Easiest EXPLANATION: To restore our original and uncompressed file we can use gunzip with FILENAME as an ARGUMENT.
18.

Which option is used with gzip command for recursive compression?(a) -c(b) -l(c) -d(d) -rI had been asked this question in my homework.I'd like to ask this question from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

Right answer is (d) -r

To explain: 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.

19.

We can provide original filenames without .gz extension while checking compression ratio using gzip– l?(a) True(b) FalseI had been asked this question in final exam.The query is from Compressing and Archiving Files topic in section Handling Ordinary Files of Unix

Answer» CORRECT answer is (a) True

The EXPLANATION is: Specifying the .gz extension is an optional FEATURE which may be neglected. The command will work properly even WITHOUT the extension.
20.

Which option is used with gzip command to check compression ratio for files?(a) -l(b) -c(c) -e(d) -xThis question was addressed to me by my college director while I was bunking the class.Asked question is from Compressing and Archiving Files in division Handling Ordinary Files of Unix

Answer» CORRECT choice is (a) -l

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.
21.

Which one of the following extension is provided by gzip to the compressed filename?(a) .cm(b) .gz(c) .zip(d) .zpThis question was addressed to me in an interview for job.This interesting question is from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

Right option is (B) .gz

The 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.

22.

Which of the following is used to compress files?(a) cmp(b) gzip(c) gunzip(d) commI had been asked this question by my school principal while I was bunking the class.This intriguing question comes from Compressing and Archiving Files in section Handling Ordinary Files of Unix

Answer»

The correct answer is (b) GZIP

To explain I WOULD SAY: To conserve DISK space we need to compress a file. gzip is a very POPULAR program used with one or more filenames for compression.

23.

Which of the following is not an internal command for more?(a) q(b) f(c) b(d) zI got this question in an internship interview.My question is taken from Counting File Data: wc Command topic in chapter Handling Ordinary Files of Unix

Answer»

The correct option is (d) z

To explain I would SAY: more pager offers a set of INTERNAL COMMANDS which are used for viewing PAGES differently. For scrolling one page at a time, use ‘F’ or the space bar. Similarly for scrolling backward press ‘b’ and for quitting the pager use ‘q’.

24.

file command identifies the file type by examining the magic number of the file.(a) True(b) FalseThe question was asked in examination.This intriguing question originated from Counting File Data: wc Command in section Handling Ordinary Files of Unix

Answer» RIGHT option is (a) True

The explanation: Magic number is the number which is embedded in the first few bytes of a FILE. EVERY file has a unique magic number which helps in IDENTIFYING the file TYPE.
25.

UNIX offers a pager named ____ which has replaced the original pager of UNIX called ____(a) more, less(b) less, more(c) more, pg(d) pg, moreThe question was posed to me in a national level competition.The doubt is from Counting File Data: wc Command in portion Handling Ordinary Files of Unix

Answer»

The correct choice is (C) more, pg

The explanation is: The man command displays its output one page at a time. This is possible because it sends its output to a pager PROGRAM. more pager is extensively used in UNIX system and it has replaced the ORIGINAL pager of UNIX i.e. pg. The task of a pager program is to simply display pages on the terminal. It can also be used to display the CONTENTS of a file.

26.

-t option prints the title on the first page.(a) True(b) FalseThe question was posed to me in final exam.The doubt is from Counting File Data: wc Command in division Handling Ordinary Files of Unix

Answer»

Right option is (a) True

Best EXPLANATION: To print a specific title on the first page, we use the -t option FOLLOWED by the STRING which we WANT to print as a title. For EXAMPLE,

27.

Which command is used for knowing the file type?(a) file(b) type(c) filetype(d) type of fileThe question was asked in an internship interview.My question comes from Counting File Data: wc Command topic in portion Handling Ordinary Files of Unix

Answer»

The correct option is (a) file

For explanation: UNIX provides the file command for determining the type of file i.e. WHETHER it is a text file, SCRIPT file, ARCHIVE file or any other type of file.

28.

Which option is used for printing multiple copies of a file using lp command?(a) -l(b) -i(c) -t(d) -nI got this question in unit test.My question is taken from Counting File Data: wc Command in section Handling Ordinary Files of Unix

Answer»

Right option is (d) -n

The explanation: If we want to PRINT multiple COPIES of a FILE, we can USE the -n option FOLLOWED by an integer i.e. the number of copies that we want to print. For example to print 5 copies of file abd.txt use the following command,

29.

Which option is used with lp command if there are more than one printers in the system?(a) -t(b) -d(c) -i(d) -pThis question was posed to me in examination.The origin of the question is Counting File Data: wc Command topic in section Handling Ordinary Files of Unix

Answer»

Right CHOICE is (B) -d

Explanation: lp command prints the file as a default printer has been already SPECIFIED by the system administrator. In case if there is more than one printer in the system we have to use the -d option with the printer name to print the file. For example, if there is another printer NAMED laser_001 then,

30.

Which command is used for printing a file?(a) lp(b) pr(c) pg(d) moreI had been asked this question during an interview for a job.Enquiry is from Counting File Data: wc Command in portion Handling Ordinary Files of Unix

Answer» CORRECT CHOICE is (a) lp

Best explanation: lp command is USED for printing a single copy of the file SPECIFIED as an argument to lp command. For example,
31.

wc command can also work on a data stream.(a) True(b) FalseI got this question by my school teacher while I was bunking the class.This question is from Counting File Data: wc Command topic in section Handling Ordinary Files of Unix

Answer» RIGHT choice is (a) True

Easy explanation: wc COMMAND when invoked without any SPECIAL symbol ( like < or | ) or an argument it reads the INPUT from standard input. we have to provide the input from the keyboard and mark the end of input with Ctrl-D. For example,
32.

Which option is used for counting the number of characters in a file only.(a) -l(b) -W(c) -c(d) -wThis question was posed to me in an interview.My query is from Counting File Data: wc Command topic in section Handling Ordinary Files of Unix

Answer»

Correct OPTION is (c) -c

For explanation: -c option when used with WC COMMAND display only the number of characters in the specified file.

33.

Which option is used for counting the number of words in a file only?(a) -l(b) -W(c) -c(d) -wThis question was addressed to me during an interview.This interesting question is from Counting File Data: wc Command topic in chapter Handling Ordinary Files of Unix

Answer»

The correct OPTION is (d) -w

The explanation: -w option when USED with WC command display only the number of WORDS in the SPECIFIED file.

34.

Which command is used for counting words, lines and characters in a file?(a) diff(b) count(c) man(d) wcThis question was posed to me in an internship interview.My doubt stems from Counting File Data: wc Command in chapter Handling Ordinary Files of Unix

Answer»

Correct OPTION is (d) wc

The explanation: UNIX PROVIDES a universal word counting program that ALLOWS us to count the NUMBER of words, lines and characters in a file. It takes a filename as an argument as produces a 4 column output.

35.

If we are interested in knowing that whether the two files are identical or not, we can use ___ command.(a) comm(b) diff(c) cmp(d) differI have been asked this question in unit test.I'd like to ask this question from Comparing Files:comm, cmp and diff Command topic in section Handling Ordinary Files of Unix

Answer»

The correct choice is (c) cmp

To elaborate: All the three commands comm, DIFF and cmp are used for comparing files but if we are interested in knowing WHETHER two files are identical or not we can USE comm command without any option. It will SIMPLY return the prompt without DISPLAYING any output if both the files are identical.

36.

wc command cannot take multiple filenames as arguments.(a) True(b) FalseThis question was addressed to me in semester exam.My doubt is from Counting File Data: wc Command in section Handling Ordinary Files of Unix

Answer»

The correct answer is (b) False

Easy explanation: wc command can take MULTIPLE FILENAMES as arguments. If multiple filenames are specified with wc command then it will produce a separate line of OUTPUT for each file ALONG with an additional line as a TOTAL count for all files specified. For example,

37.

Which option is used for counting the number of lines in a file only.(a) -l(b) -W(c) -c(d) -wThis question was addressed to me in semester exam.Question is from Counting File Data: wc Command in portion Handling Ordinary Files of Unix

Answer» CORRECT option is (a) -l

The best I can explain: -l option when used with wc COMMAND DISPLAY only the number of lines in the SPECIFIED FILE.
38.

Which option is used to produce multi columnar output in diff command?(a) -y(b) -v(c) -s(d) -eI had been asked this question by my college director while I was bunking the class.My question comes from Comparing Files:comm, cmp and diff Command topic in division Handling Ordinary Files of Unix

Answer» RIGHT option is (a) -y

Easiest explanation: -y option when used with DIFF COMMAND produces output in multiple COLUMNS. For example,
39.

For comm command to work properly, files specified should be sorted.(a) True(b) FalseI got this question during an online exam.Asked question is from Comparing Files:comm, cmp and diff Command topic in portion Handling Ordinary Files of Unix

Answer»

The correct answer is (a) True

To explain: comm command only compares those FILES that are already sorted. If the files are not sorted it will THROW an ERROR MESSAGE displaying “file not in sorted ORDER”.

40.

When two files are identical, what is the output of diff command?(a) Files are identical(b) Returns prompt(c) No output(d) Throws an errorThe question was posed to me in an online interview.This question is from Comparing Files:comm, cmp and diff Command in portion Handling Ordinary Files of Unix

Answer»

The correct choice is (b) Returns PROMPT

The best explanation: When two files are IDENTICAL, diff command does not produce any output. It simply returns the SHELL prompt $. However, we can USE the -s option to display an informative message on the terminal if the files are identical.

41.

Which command is used to display the differences between files?(a) comm(b) diff(c) cmp(d) differThis question was addressed to me in class test.This question is from Comparing Files:comm, cmp and diff Command in chapter Handling Ordinary Files of Unix

Answer»

Correct option is (b) diff

Explanation: diff COMMAND is used for comparing FILES and DISPLAYING the DIFFERENCES between them.

diff command uses certain SYMBOLS and instructions to indicate the changes that are required to make two files identical. For example,

a– for appending

c– for changing

d– for deleting

42.

What will be the command if we want to suppress column 1 and column 2 in the output of comm Command?(a) comm-12(b) comm -1-2(c) comm -3(d) comm -1,-2I had been asked this question in unit test.This question is from Comparing Files:comm, cmp and diff Command topic in section Handling Ordinary Files of Unix

Answer» RIGHT answer is (a) comm-12

Easy explanation: comm command provides us with an OPTION for suppressing the columns in the output. For this task, we have to provide the column number as an option in the comm command. For EXAMPLE, -1 for column 1, -2 for column 2 and -3 for column 3.
43.

Which option is used with cmp command to limit the number of bytes to be compared?(a) -n(b) -l(c) -f(d) -bI have been asked this question during an online exam.The above asked question is from Comparing Files:comm, cmp and diff Command topic in section Handling Ordinary Files of Unix

Answer»

Correct option is (a) -n

The explanation: We can limit the number of bytes to be compared by the cmp COMMAND by using -n option with it. For EXAMPLE, if we want to compare at most 50 bytes then the command will be written as:

44.

Which command compares two sorted files line by line?(a) cmp(b) diff(c) comm(d) sortThe question was posed to me in semester exam.The query is from Comparing Files:comm, cmp and diff Command topic in section Handling Ordinary Files of Unix

Answer»

Correct option is (c) comm

For explanation: comm COMMAND is used for comparing two sorted files line by line. When there is no option specified with comm command it PRODUCES three column output. For example, if we WANT to compare two files namely file01 and file02 then the first column will contain those entries which are unique to file01 whereas the SECOND column will contain those entries which are unique to file02. The third column will contain the ACTUAL information i.e. those entries which are common to both fil01 and file02.

45.

-b option is used with cmp command to print the differing bytes in both files.(a) True(b) FalseThis question was addressed to me by my college director while I was bunking the class.My question comes from Comparing Files:comm, cmp and diff Command topic in portion Handling Ordinary Files of Unix

Answer» RIGHT choice is (a) True

The explanation is: -b option when used with cmp command print the byte number and the line number along with the differing BYTES, where the first MISMATCH OCCUR. For example,
46.

How can we skip some initial bytes from both the files to be compared?(a) using -b option(b) using -n option(c) using -l option(d) using -i optionI have been asked this question during an online exam.Query is from Comparing Files:comm, cmp and diff Command topic in portion Handling Ordinary Files of Unix

Answer»

Right CHOICE is (d) using -i option

To elaborate: We can skip the number of initial bytes to be compared from both the FILES such that the CMP command will not consider that number of bytes while comparing both files. For this FACILITY, we use -i option followed by the number of bytes to be skipped. For example, to skip the first 10 bytes use the FOLLOWING command,

47.

Which option is used with cmp command to display a detailed list of mismatches?(a) -a(b) -b(c) -f(d) -lThe question was posed to me in an internship interview.This interesting question is from Comparing Files:comm, cmp and diff Command in section Handling Ordinary Files of Unix

Answer»

The correct answer is (d) -l

To explain: cmp command by default only displays the first mismatch that OCCURS in both files. For a detailed LIST of all the mismatches, we use the -l option. It prints byte POSITION and the byte VALUE for all differing bytes.

48.

Which option is used with mv command so that the destination file does not get overwritten?(a) -n(b) -f(c) -b(d) -iI got this question in final exam.Enquiry is from Deleting and Renaming files: rm and mv Command in division Handling Ordinary Files of Unix

Answer» CORRECT option is (a) -n

For explanation I WOULD say: If the destination file already EXISTS in mv command then it will be overwritten which can be harmful. To avoid this we use -n option with mv so that the destination file does not GET overwritten. -i option displays interactive messages and ASKS the user before overwriting the destination file.
49.

What is the exit status of cmp command if both the files are identical?(a) 0(b) 1(c) 2(d) undefinedI got this question in a national level competition.I'm obligated to ask this question of Comparing Files:comm, cmp and diff Command in division Handling Ordinary Files of Unix

Answer»

The CORRECT answer is (a) 0

For explanation I WOULD SAY: The exit status of cmp COMMAND is 0 if both the files are identical and 1 if both the files are different. The exit status is 2 if the program encounters a problem.

50.

-f option when used with mv command overwrites existing files without prompting any messages.(a) True(b) FalseThe question was asked during an online interview.I want to ask this question from Deleting and Renaming files: rm and mv Command topic in division Handling Ordinary Files of Unix

Answer»

The correct choice is (a) True

To explain: When -f OPTION is USED with mv command then, the system will not display any diagnostic messages on to the terminal. It will simply replace the EXISTING FILE without any warning.