PRACTICE QUESTIONS AND CORRECT
ANSWERS WITH DETAILED RATIONALES
LINUX COMMAND LINE AND SYSTEM
ADMINISTRATION STUDY GUIDE
What command displays manual pages? (Specify ONLY the command
without any path or parameters.) - CORRECT ANSWER-MAN
Which command copies the contents of the directory /etc/, including all
sub-directories, to /root/?
A. copy /etc /root
B. cp -r /etc/* /root
C. cp -v /etc/* /root
D. rcp /etc/* /root
E. cp -R /etc/*.* /root - CORRECT ANSWER-B
Which of the following commands puts the lines of the file data.csv into
alphabetical order?
A. a..z data.csv
B. sort data.csv
C. abc data.csv
D. wc -s data.csv
,E. grep --sort data.csv - CORRECT ANSWER-B
Which of the following examples shows the general structure of a for loop
in a shell script?
A. for *.txt as file => echo $file
B. for *.txt ( echo $i )
C. for file in *.txt do echo $i done
D. for ls *.txt exec {} \;
E. foreach @{file} { echo $i } - CORRECT ANSWER-C
Which operator in a regular expression matches the preceding character
either zero or one time?
A. ?
B. *
C. +
D. %
E. $ - CORRECT ANSWER-B
The file script.sh in the current directory contains the following
content:#!/bin/bashecho $MYVARThe following commands are used to
execute this script:MYVAR=value -./script.shThe result is an empty line
instead of the content of the variable MYVAR. How should MYVAR be set
in order to make script.sh display the content of MYVAR?
A. !MYVAR=value
B. env MYVAR=value
C. MYVAR=value
, D. $MYVAR=value
E. export MYVAR=value - CORRECT ANSWER-E
What is the return value of a shell script after successful execution?
A. 1
B. 0
C. -1
D. -255
E. 255 - CORRECT ANSWER-B
Which of the following commands creates the ZIP archive poems.zip
containing all files in the current directory whose names end in .txt?
A. zip *.txt > poems.zip
B. zcat *.txt poems.zip
C. zip poems.zip *.txt
D. zip cfz poems.zip *.txt
E. cat *.txt | zip poems.zip - CORRECT ANSWER-C
Which of the following statements are true regarding a typical shell script?
(Choose two.)
A. It has the executable permission bit set.
B. It starts with the two character sequence #!.
C. It is located in /usr/local/scripts/.
D. It is located in /etc/bash/scripts/.