Linux+ Guide, Linux certification 3rd edition chapter 7

Ace your homework & exams now with Quizwiz!

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

a. 1

*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. When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead. b. It cannot be done as there already is a command cat on the system. c. It cannot be done as there already is an environment variable cat associated with the cat command. d. There is no effect until the alias is imported as it is a user-declared variable.

a. 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 ~ b. echo HOME= c. echo $HOME d. echo ls HOME

a. echo ~ b. echo $HOME

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

b. exported

*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 this program and answered Blue when prompted? a. The answer is red or blue. The answer is not red or blue b. The answer is red or blue c. The answer is not red nor blue d. The code would cause an error

c. The answer is not red nor blue

*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

*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

*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. set c. echo d. ls /var

b. set

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

d. Begin the line with #

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

True

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

a. fi

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

a. read

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

b. !

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

b. /etc/profile

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

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

*Which is not necessarily generated by every command on the system? (Choose all that apply) Standard Error Standard Input Standard Output Standard Deviation

Standard Input Standard Deviation

*You have redirected standard error to a file called errors, you view the contents of this file afterward and notice the there are six error messages, after repeating the procedure you notice that there are two error messages in this file, why? a. You must specify a new file each and every time you redirect as the system creates the specified file by default b. You did not append the standard error to the file errorfile, and as a result it was overwritten when the command was run a second time

b. You did not append the standard error to the file errorfile, and as a result it was overwritten when the command was run a second time

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

c. It appends Standard Output to a file.

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

c. nothing is wrong with the command


Related study sets

Ch 20: Peripheral Vascular System and Lymphatic System (2 sets)

View Set

How to Use Investigating Technology

View Set

Monopolistic competition and Oligopoly

View Set

Chapter 15: Organization Culture

View Set