Deck 7: Working With the Bash Shell
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
Play
Full screen (f)
Deck 7: Working With the Bash Shell
1
You can use the sed command to remove unwanted lines of text.
True
2
What permissions are required to execute a shell script in a manner similar to any other executable program on the system?
A) read
B) write and read
C) execute
D) read and execute
A) read
B) write and read
C) execute
D) read and execute
D
3
The ability to extract, manipulate, and format text using pattern action statements belongs to which command below?
A) sed
B) grep
C) awk
D) nl
A) sed
B) grep
C) awk
D) nl
C
4
What number represents the stdin file descriptor?
A) 0
B) 1
C) 2
D) 3
A) 0
B) 1
C) 2
D) 3
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
What character is used to delimit most Linux configuration files?
A) tab
B) colon
C) space
D) semicolon
A) tab
B) colon
C) space
D) semicolon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
Given the syntax command && command, the command on the left of the && construct is executed only if the command on the right of the && construct completed successfully.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
You are limited to using one pipe | metacharacter on the command line to pipe information from one command to another command.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
Select the escape sequence that is used for a form feed:
A) \n
B) \f
C) /f
D) /n
A) \n
B) \f
C) /f
D) /n
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
A list of all exported environment and user-defined variables in a shell can be viewed with what command below?
A) env
B) set
C) setenv
D) getenv
A) env
B) set
C) setenv
D) getenv
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
The standard output and standard error from a terminal screen within the BASH shell can be redirected to a file on the filesystem using what shell metacharacter, followed by the absolute or relative pathname of the file?
A) #
B) <
C) >
D) |
A) #
B) <
C) >
D) |
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
Select the metacharacter that can be used to send the standard output of one command to another command as standard input:
A) <
B) |
C) >
D) #
A) <
B) |
C) >
D) #
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
What number represents the stderr file descriptor?
A) 0
B) 1
C) 2
D) 3
A) 0
B) 1
C) 2
D) 3
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
The default BASH shell prompt is set by an environment variable. What command can be used to view this variable?
A) ls $PWD
B) echo #PWD
C) echo $PS1
D) ls #PS1
A) ls $PWD
B) echo #PWD
C) echo $PS1
D) ls #PS1
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
The environment variables that are set by default and their current values can be viewed with what command?
A) env
B) get
C) set
D) setenv
A) env
B) get
C) set
D) setenv
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Which command can be used to count the number lines, words, and characters in a file?
A) pr
B) nl
C) tr
D) wc
A) pr
B) nl
C) tr
D) wc
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
In order to redirect a file to the standard input of a command, what metacharacter should be used?
A) >
B) #
C) |
D) <
A) >
B) #
C) |
D) <
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
What environment file is always executed immediately after login for all users on the system, and sets most environment variables, such as HOME and PATH?
A) ˜/.bash_profile
B) ˜/.bash_login
C) /etc/profile
D) ˜/.profile
A) ˜/.bash_profile
B) ˜/.bash_login
C) /etc/profile
D) ˜/.profile
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
To prevent a file from being cleared by the BASH shell and append output to the existing output, you can specify three > metacharacters alongside the file descriptor.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
What command can be used to replace characters in a file sent via Standard Input?
A) tr
B) rt
C) ts
D) st
A) tr
B) rt
C) ts
D) st
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
Any command that can be executed on the command line can also be placed inside any environment file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The first line in a shell script, which defines the shell that will be used to interpret the commands in the script file.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The first line in a shell script, which defines the shell that will be used to interpret the commands in the script file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
The ____________________ environment variable contains a list of directories to search for executable programs.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Explain the while construct, and demonstrate how it can be used.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Select the escape sequence that starts a new line when used with echo:
A) \\
B) \a
C) \n
D) \r
A) \\
B) \a
C) \n
D) \r
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
Detail shell scripts and explain how they are used and executed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A special construct used in a shell script to alter the flow of the program based on the outcome of a command or contents of a variable. Common decision constructs include if, case, &&, and ||.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A special construct used in a shell script to alter the flow of the program based on the outcome of a command or contents of a variable. Common decision constructs include if, case, &&, and ||.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
Select the test statement that can be used to determine if A is numerically greater than B:
A) [ A -g B ]
B) [ A -ge B ]
C) [ A -gt B ]
D) [ A +eq B ]
A) [ A -g B ]
B) [ A -ge B ]
C) [ A -gt B ]
D) [ A +eq B ]
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
Provide information on decision constructs, and explain how to use the most common type of decision construct.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A special construct used in a shell script to execute commands repetitively. Common decision constructs include for and while.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A special construct used in a shell script to execute commands repetitively. Common decision constructs include for and while.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
The ____________________ command takes user input from stdin and places it in a variable specified by an argument.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
Describe what file descriptors are, and then list three that can be used within the BASH shell, and discuss how they can be used.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Describe shell variables, and explain environment and user-defined variables.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Most commands that are run by the shell are run in a separate ____________________, which is created by the current shell.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A case construct must be ended by ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
What character combination at the start of a shell script are referred to as a hashpling, and allow for the specification of the shell that interprets the contents of the script?
A) @!
B) #!
C) //
D) ->
A) @!
B) #!
C) //
D) ->
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A file descriptor that represents information input to a command during execution.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A file descriptor that represents information input to a command during execution.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
What construct is intended for use in processing a list of objects, such as files, directories, users, printers, and so on?
A) for
B) while
C) case
D) switch
A) for
B) while
C) case
D) switch
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
What operator below is known as the NOT operator?
A) -o
B) -a
C) !
D) %
A) -o
B) -a
C) !
D) %
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A variable that is altered by loop constructs to ensure that commands are not executed indefinitely.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A variable that is altered by loop constructs to ensure that commands are not executed indefinitely.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
Any command that can take standard input and transform it into standard output is called a(n) ____________________ command.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
In an if construct, what statements are optional?
A) fi
B) elif
C) else
D) then
A) fi
B) elif
C) else
D) then
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Select the two escape sequences that represent a horizontal tab and a vertical tab, respectively:
A) \V
B) \t
C) \v
D) \b
A) \V
B) \t
C) \v
D) \b
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The numeric labels used to define command input and command output.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The numeric labels used to define command input and command output.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The process of changing the default locations of Standard Input, Standard Output, and Standard Error.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The process of changing the default locations of Standard Input, Standard Output, and Standard Error.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
What two BASH environment variables represent the current working directory, and the absolute pathname of the current shell, respectively?
A) PWD
B) CWD
C) PATH
D) SHELL
A) PWD
B) CWD
C) PATH
D) SHELL
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The variables that store information commonly accessed by the system or programs executing on the system; together, these variables form the user environment.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
The variables that store information commonly accessed by the system or programs executing on the system; together, these variables form the user environment.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
Select the two commands below that will provide the number of lines in a file, and the number of characters in a file, respectively:
A) count -c
B) pr -d
C) wc -l
D) wc -c
A) count -c
B) pr -d
C) wc -l
D) wc -c
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
What two files below are the first two BASH environment files to be executed?
A) /etc/profile
B) /etc/bashrc
C) ˜/.bashrc
D) ˜/.bash_profile
A) /etc/profile
B) /etc/bashrc
C) ˜/.bashrc
D) ˜/.bash_profile
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A file descriptor that represents any error messages generated by a command.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A file descriptor that represents any error messages generated by a command.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Match each correct item with the statement below.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A file descriptor that represents the desired output from a command.
a.counter variable
b.decision construct
c.environment variables
d.file descriptors
e.hashpling
f.loop construct
g.redirection
h.Standard Error (stderr)
i.Standard Input (stdin)
j.Standard Output (stdout)
A file descriptor that represents the desired output from a command.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck