Ch. 7 Review Questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is wrong with the following command string: ls /etc/hosts >listofhostfile ? a. Nothing is wrong with the command. b. The ls command is one of the commands that cannot be used with redirection; you must use | to pipe instead. c. The file descriptor was not declared; unless 1 for Standard Ouput or 2 for Standard Error is indicated, the command will fail. d. The file listofhostfile will always only contain Standard Error as a file descriptor was not declared.

Nothing is wrong with the command.

A for construct is a loop construct that processes a specified list of objects. As a result, it is executed as long as there are remaining objects to process. True or False?

True

The alias command can be used to make a shortcut to a single command. True or False?

True

You have redirected Standard Error to a file called Errors. You view the contents of this file afterward and notice that there are six error messages. After repeating the procedure, you notice that there are only two error messages in this file. Why? a. The system generated different Standard Ouput. b. After you open the file and view the contents, the contents are lost. c. You did not append the Standard Error to the Error file and as a result, it was overwritten when the command was run a second time. d. You must specify a new file each and every time you redirect as the system creates the specified file by default.

You did not append the Standard Error to the Error file and as a result, it was overwritten when the command was run a second time.

What would be the effect of using the alias command to make an alias for the date command named cat in honor of your favorite pet? a. It cannot be done as there already is a command cat on the system. b. It cannot be done as there already is an environment variable cat associated with the cat command. c. There is no effect until the alias is imported as it is a user-declared variable. d. When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead.

When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead.

The current value for the HOME variable is displayed by which of the following commands? (Choose all that apply.) a. echo /HOME/ b. echo ~ c. echo ls HOME d. echo HOME=

echo ~ echo $HOME

Before a user-defined variable can be used by processes that run in subshells, that variable must be: a. validated by running the env command b. imported c. exported d. redirected to the BASH shell

exported

Every if construct begins with if and must be terminated with? a. endif b. end c. fi d. stop

fi

Which construct can be used in a shell script to read Standard Input and place it in a variable? a. sum b. verify c. read d. test

read

Which command could you use to see a list of all environment and user-defined shell variables as well as their current values? a. env b. ls /var c. echo d. set

set

Which of the following operators reverses the meaning of a test statement? a. -o b. ! c. #! d. -a

!

Which of the following files is always executed immediately after any user logs in to a Linux system and receives a BASH shell? a. ~/.bash_login b. ~/.profile c. ~/.bash_profile d. /etc/profile

/etc/profile

How do you indicate a comment line in a shell script? a. Begin the line with #!. b. There are no comment lines in a shell script. c. Begin the line with !. d. Begin the line with #.

Begin the line with #.

The sed and awk commands are filter commands commonly used to format data within a pipe. True or False?

False (TEST TRUE)

What does >> accomplish when entered on the command line after a command? a. It redirects Standard Error and Standard Input to the same location. b. It redirects both Standard Error and Standard Ouput to the same location. c. It appends Standard Ouput to a file. d. It does not accomplish anything.

It appends Standard Output to a file.

Which of the following is not necessarily generated by every command on the system? (Choose all that apply.) a. Standard Ouput b. Standard Error c. Standard Input d. Standard Home

Standard Input

Because Standard Error and Standard Output represent the results of a command and Standard Input represents the input required for a command, only Standard Error and Standard Output can be redirected to/from a file. True or False?

False

Which of the following will display the message welcome home if the cd /home/user1 command is successfully executed?4 a. cd /home/user1 || cat "welcome home" b. echo "welcome home" && cd /home/user1 c. cd /home/user1 && echo "welcome home" d. cat "welcome home" || cd /home/user1

cd /home/user1 && echo "welcome home"

Which of the following file descriptor numbers represents stdout? a. 0 b. 2 c. 1 d. 3

1

Consider the following shell script: echo -e "What is your favorite color?--> \c" read REPLY if ["$REPLY" = "red" -o "$REPLY" = "blue"] then echo "The answer is red or blue." else echo "The answer is not red nor blue." fi What would be displayed if a user executes the program in question 20 and answered Blue when prompted? a. The answer is red or blue. The answer is not red nor blue. b. The code would cause an error. c. The answer is not red nor blue. d. The answer is red or blue.

The answer is not red nor blue


Ensembles d'études connexes

Introduction to Ethics Module 1-3

View Set

Marketing 200 Exam Part 2. Chapters 4,5,6,7

View Set

Breast Chapter 3: Anatomy and Physiology

View Set