ACTUAL Exam Questions and CORRECT
Answers
When writing shell scripts and using an if statement to determine whether a set of code should be
executed, what is the proper syntax to end the if construct? Answer:
________________________________ - CORRECT ANSWER - fi
The subdirectory newdir does not currently exist in the current directory that you are in. Which
of the following commands will create a new directory named newdir and then change into that
directory? (Choose two.)
Select one or more:
a. mkdir newdir; cd newdir
b. mkdir newdir || cd newdir
c. mkdir newdir >> cd newdir
d. mkdir newdir && cd newdir - CORRECT ANSWER - mkdir newdir && cd newdir
mkdir newdir; cd newdir
How many times will the following loop execute as part of a script:
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 7 ]
do
echo "hello world"
done
Select one:
a. 7
b. 0
, c. 1
d. until ctrl-c is used to terminate it - CORRECT ANSWER - until ctrl-c is used to
terminate it
Which of the following will the split command do on a file when no other options are specified?
Select one:
a. It will split a file into new files that are 1 kilobyte each.
b. It will split a file into new equally sized files that are 1/10th of the original file size.
c. It will split a file into new files that are 1 megabyte each.
d. It will split a file into new files that are 1,000 lines each. - CORRECT ANSWER - It
will split a file into new equally sized files that are 1/10th of the original file size.
Match the file with the order in which the BASH shell environment files are read:
/etc/profile, /etc/bashrc, ~/.bashrc, /etc/profile.d/* - CORRECT ANSWER - Second
/etc/profile.d/*
Fourth
~/.bashrc
Third
/etc/bashrc
First
/etc/profile
Which of the following is a valid method of running a script named myscript.sh? (Choose two)
Select one or more:
a. source myscript.sh
b. run myscript.sh
c. ./myscript.sh
d. exec ./myscript.sh - CORRECT ANSWER - ./myscript.sh