Linux chapter 7

Ace your homework & exams now with Quizwiz!

Which of the following variables could access the value "/etc" within the sample shell script, if the sample shell script was executed using the bash sample /var /etc /bin command? $0 $1 $2 $3

$2

Which of the following lines can be used to perform command substitution within a shell script? (Choose all that apply.) 'command' ${command} ${!command} $(command)

'command' , $(command)

What does &> accomplish when entered on the command line after a command? It redirects both stderr and stdout to the same location. It does not accomplish anything. It redirects stderr and stdin to the same location. It appends stdout to a file.

It redirects both stderr and stdout to the same location.

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

True

Which of the following operators reverses the meaning of a test statement? #! -o -a !

!

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

/etc/profile

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

Begin the line with #.

True or False: Because stderr and stdout represent the results of a command and stdin represents the input required for a command, only stderr and stdout can be redirected to/from a file.

False

Which environment variable is used to control the directories that are searched when a command is used with providing an absolute or relative reference? a. PATH b. PS1 c. DATE d. TIME

PATH

Consider the following shell script:What would be displayed if a user executes this shell script and answers Blue when prompted? The answer is red or blue. The answer is not red nor blue. The code would cause an error. The answer is red or blue. The answer is not red nor blue.

The answer is not red nor blue.

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

Both aliases and functions can be used to store commands that can be executed, but functions can also accept positional parameters. True or False?

True

True or False: You can combine redirection and piping, as long as input redirection occurs at the beginning of the pipe and output redirection occurs at the end of the pipe.

True

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

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

What escape character will add a vertical tab to the screen if issued within a script? a. \v b. /v c. -v d. /vert

\v

Which of the following will display the message welcome home if the cd /home/user1 command is successfully executed? cd /home/user1 && echo "welcome home" cat "welcome home" || cd /home/user1 cd /home/user1 || cat "welcome home" echo "welcome home" && cd /home/user1

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

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

echo ~, echo $HOME

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

exported

Every if construct begins with if and must be terminated with . end endif stop fi

fi

What command should be added to a shell script in order for the script to read information from the standard input? a. stdin b. stdout c. read d. display

read

Which construct can be used in a shell script to read stdin and place it in a variable? read sum verify test

read

Which filter command can be used to search and replace a certain string of text? a.sed b.grep c.awk d.pr

sed

Which command can be used to transform or change characters received from Standard Input? a.set b.tee c.tr d.read

tr

Which of the following constructs would you use to execute a command repetitively? a. if b. case c. while d. &&

while

Which metacharacter is used to pipe the results of one command to another? a. / b. * c. > d. |

|

You attempt to perform the git commit -m "Added listdir function" but the command fails. What are possible reasons for the failure? (Choose all that apply.) The user performing the commit has not set their Git user information. No files were added to the Git index beforehand. The user performing the commit is not running the command from within the Git repo directory. The master branch was not specified within the command itself.

The user performing the commit has not set their Git user information. No files were added to the Git index beforehand. The user performing the commit is not running the command from within the Git repo directory.

You have redirected stderr 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? After you open the file and view the contents, the contents are lost. The system generated different stdout. You did not append the stderr to the Error file, and, as a result, it was overwritten when the command was run a second time. You must specify a new file each time you redirect because the system creates the specified file by default.

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

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

set

1. What term is used to describe text that is input by a user typing on a keyboard and is used for command execution? a. stdinout b. stdin c. stdout d. stderr

stdin


Related study sets

PrepU Ch 29: Management of Patients with Nonmalignant Hematologic Disorders

View Set

Law and Legal Environment Exam 1

View Set

08 Intermediate: File I/O in C Programming

View Set

Managerial Accounting- Chapter 19

View Set

Political Science Final- Multiple Choice

View Set

Quiz: High Renaissance and Mannerism

View Set

Implementing chapter 17 Practice questions

View Set

Positive Crankcase Ventilation Valve and Secondary Air-Injection Systems Chapter 27 Part One

View Set

C175- Lesson 1 - Intro to Databases, Information and Data Quiz

View Set