THE FOLLOWING COMPTIA LINUX+ EXAM OBJECTIVES ARE COVERED IN THIS CHAPTER: You are writing a shell script using bash and need to print the contents of a variable. Which of the following commands can be used to do so? Which of the following packages provides orchestration for Linux in an agentless manner? Which of the following commands can be used to execute a command with a customized environment? Which of the following commands, when used with Which of the following best describes the concept of infrastructure as code? Which of the following commands changes a file called Which command can be used to add functions and variables to the current shell? Which of the following is the correct method for invoking the bash shell for a script, typically found as the first line of the script? You need to send output from a command to a log file. Overwriting the contents of the log file is acceptable. Which of the following characters is used to redirect output in such a way as to fulfill this scenario? You need to create a new empty git repository called Which of the following terms is used in orchestration and automation scenarios to refer to the collection of devices being managed? You need to print output from a bash script such that single quotes appear in the outputted string. Which character should be used as an escape sequence in order to get the single quotes into the output? Which exit code indicates success for a bash script? Which of the following commands produces the output Which of the following characters or character sequences begins a comment in a bash script? Which, if any, file extension is required in order for a bash script to execute? After fetching changes for a previously cloned git repository, which git command is used to incorporate those changes into the local copy? Which of the following best describes the role of an agent in software orchestration? Being able to deploy additional servers in response to high demand or load is an example of which type of automation? Which command can be used to indicate a local variable within a bash script? Which git command is used to retrieve a repository from a remote server? You need to echo the name of the script back to the user for usage or help output. Which positional parameter can be used for this purpose? Which of the following commands can be used to print the contents of the current shell environment? You are writing a You need to create a bash script that will loop continually and perform some commands within the loop. Which of the following lines will accomplish this task? Which of the following commands changes the location to which You need to declare a variable as part of the environment prior to running a bash script. Which of the following commands accomplishes this? Which of the following commands displays the current path in bash? Which character sequence is used to execute a command within a subshell in a bash script? You need to make a change to the configuration of the SSH daemon across your infrastructure. Being able to do so from a central server is an example of which type of automation? Which option is used with the Within a bash script, you need to run two commands, but only run the second command if the first succeeds. Which of the following metacharacters can be used to accomplish this task? You need to redirect the output from a command and append that output to a file. Which of the following character sequences accomplishes this task? You need to obtain a directory listing of all files and directories except those that begin with the letter p. Which of the following commands accomplishes this task? Which of the following files is used within a git repository in order to indicate files and file patterns that should not be versioned? You need to iterate through a directory listing and perform an operation on certain files within it. To accomplish this task, you will be using a bash script and a looping construct. Which looping construct is most appropriate for this purpose? You are debugging a bash script written by a different system administrator. Within the script, you see a command surrounded by backquotes, or Which You are committing code to a git repository and need to include a message on the command line. Which option enables this behavior? Compiling software when a developer commits code to a certain branch in a repository is an example of which type of automation? You are working with a MySQL database and need to read in several SQL commands from a file and send them into the MySQL CLI for execution. You will be using STDIN redirection for this. Which of the following commands is correct, assuming a filename of You are collaborating on a coding project using git as the source code management tool. Teammates are saying that they cannot see your code, although you have been committing code regularly. Which of the following is most likely the problem? Which option to the Which character sequence is used to indicate the default case within a Which character sequence indicates the end of an What is the name of the default branch in a git repository? You need to use the output from a command as input for another command. Which character facilitates this scenario? Which Which option to the Determining the version of software installed on each client node is an example of collecting information for which collection in an automated infrastructure? You need to redirect STDERR from a command into a file to capture the errors. Which character sequence can be used for this purpose? You need to make a change to your git environment because your email address has changed. Which of the following commands ensures that your new email address will be used for all subsequent commits? Which shell built-in command is used to display a list of read-only variables? Assume that you’re using the bash shell and want to prevent output redirects from accidentally overwriting existing files. Which command and option can be used to invoke this behavior? You have received a file that does not have a file extension. Which command can you run to help determine what type of file it might be? Which of the following commands will display the last 50 lines of your command history when using bash, including commands from the current session? When using bash, how would you execute the last command starting with a certain string, even if that command was not the last one that you typed? Which shell built-in command can be used to determine the location from which a given command will be run? Which command is used to read and execute commands from a file in the bash shell? You need a command to be executed on logout for all users. Within which file should this be placed (assuming all users are using bash)? Which of the following commands removes an environment variable that has been set? When setting the shebang line of a shell script, which of the following commands will help to determine the location of the interpreter automatically? Which of the following best describes the Which variable within a bash script is used to access the first command-line parameter? Which of the following commands will print a list of six numbers beginning at 0? Which of the following commands will execute a script and then exit the shell? Which command within a shell script awaits user input and places that input into a variable? What characters are used to mark a sequence of commands as a function within a shell script? Which character sequence is used to terminate a Which option to Which characters are used to denote the beginning and end of the test portion of a When using the Which environment variable is used when changing directory with the tilde character, such as You would like to examine the entries for a single file through the Which of the following best describes attributes of an inventory within an automated infrastructure? Which operator should be used when comparing integers to determine if one is equal to another in a bash script? You would like to run several commands in succession but not have the output sent into the next command. Which of the following metacharacters will accomplish this task? Which escape sequence is used to denote the alert or bell? Which of the following is a valid variable declaration in a bash script, setting the variable Which of the following commands will obtain the date in seconds since the epoch and place it into a variable called Which sequence is used to mark the beginning and end of the commands to execute within a Which option to the Which environment variable controls the format of dates and times, such as a 12-hour or 24-hour formatted clock? Which option to You are running a shell script from within your SSH session. Which key combination can be used to terminate the script? Which of the following conditionals in a bash script will test if the variable Which of the following commands adds Which option to Which environment variable can be used to change the default path for a new git repository created with Which character sequence is used to add a horizontal tab using You need to exclude a build file, called Which file-globbing sequence will match all files that begin with an uppercase A or an uppercase F? Assuming a remote name of Which character sequence displays the number of command-line arguments that were passed to a bash script? Which environment variable can be set if you wish to automatically log users out of their shell after a certain period of inactivity? You are debugging a bash script and notice a line that contains: When cloning a repository with When working in a virtual server environment, which column within If you need to temporarily reconfigure all locale variables and settings for a given session, which environment variable can be used? A set of commands to execute on a client node is an example of which type of infrastructure automation? Which character sequence is used to indicate the end of an individual clause within a Which of the following commands removes a currently defined aliased command? Which of the following tests will determine if a file exists in the context of a shell script? Which of the following values for the Which option to the Which character sequence should be used if you need to redirect STDERR to a file and append to the file? When working with infrastructure as code, you have received a file with a Which of the following best describes the result of the command Which shell built-in can be used to move positional parameters down, where You are using Which of the following pairs indicates the beginning and end of an Which exit code is used to indicate a general error within a bash script? When scripting for build automation, you need to run a configure script prior to running the Assuming that a file has been previously added and committed to git, which option to the Which locale-related environment variable is used for currency-related localization? Which of the following lines added to Which of the following creates an array in a bash script? Which test within a shell script Assuming that a space-separated list of values has been defined as Which keyword(s) is/are used to begin an alternate condition within a bash script? Within which directory does git store a local copy of the repository metadata? You need to redirect both STDERR and STDOUT to a file. Which of the following character sequences accomplishes this task? Within a bash script, you need to run two commands, but only run the second command if the first fails. Which of the following metacharacters can be used to accomplish this task? Which of the following commands creates a new branch called Which of the following best describes the difference between a Which statement can be used in a bash script to determine if variable Which of the following protocols is typically used for agentless infrastructure orchestration? Which of the following character sequences expands or interpolates a variable called
export
env
set
printenv
echo
#!/bin/bash
chmod
stderr
stdin
stdout
while
until
case
clone
push
pull
commit
merge
branch
log
init
config
.gitignore
.git/
echo
lf
sp
varpt
set
env
run
crun
git
, retrieves the latest objects from a repository and attempts to incorporate those changes into the local working copy of the repository?
fetch
pull
retr
get
script.sh
such that it can be executed by the owner of the file and no one else?
chmod 700 script.sh
chown +x script.sh
chmod script.sh +x
chmod
777 script.sh
source
echo
en
src
#!/BASH
#!bash
#!/bash
#!/bin/bash
|
<
>
&
repo
. Which of the following sequences accomplishes this task?
mkdir repo
; cd repo
; git init --bare
mkdir repo
; git init repo/
git init repo –md
git create repo/
/
’
"
sit sat set
?
echo s{i,a,e}t
echo s(i,a,e)t
echo s[i,a,e]t
echo s/i,a,e/t
/*
//
#
’
.sh
.bash
.bat
put
push
merge
inc
localvar
ll
local
%local%
clone
checkout
co
retr
$me
$1
$myname
$0
echoenv
printenv
showenv
envvar
while
loop in a bash script and need to compare two string values. Which operator is used for this purpose?
-ne
=
equal
eq
if [ $exit -eq "exit" ]
while true; do
for ($i = 0, $i++)
continue until ($exit)
HEAD
is pointing with git?
git point
git checkout
git change
git load
dec
create
export
get
echo PATH
echo
$PATH
echo $CURPATH
ext $PATH
$()
subs()
$%
$(~
env
command in order to remove a variable from the environment?
-r
-u
-n
-d
<>
&
&&
|
>
>>
|
^
ls -l !p
ls -l [!p]
ls -l [^p]
ls -l [^p]*
novers
.gitignore
gitignore.txt
gitnover
until
do
for
foreach
`
. What will be the result of surrounding the command with backquotes?
$()
command substitution was used./dev/null
.git
command displays a short history of commits along with the commit ID?
showhist
list
log
hist
-m
-h
-f
-l
customers.sql
?
mysql < customers.sql
mysql | customers.sql
mysql > customers.sql
mysql >< customers.sql
git push
to send the code to the server.-h
flag.chmod
command performs a recursive change?
-re
-R
-c
-v
case
statement in a bash script?
()
*.*
**
*)
if
conditional in a bash script?
}
fi
end
endif
source
main
primary
master
>
|
!
`
git
command shows the current state of the working copy of a repository?
git list
git status
git state
git view
echo
command suppresses the ending newline character that is normally included?
-a
-n
-d
-y
>
%2>
2>
%%>
git config user.email
git change email
git config email.addr
git config email.address
ro
readonly
env-ro
ro-env
setoutput -f
overwrite=no
overwrite -n
set -C
grep
telnet
file
export
bashhist 50
history 50
cat .bash_history
tail -f .bash_history
!
and then the string to search for.?
and then the string to search for.
type
when
find
help
run
execute
source
func
~/.bash_logout
/etc/bash.bash_logout
/home/.bash_logout
/etc/bash_logout
profile --unset
env -u
set -u
import
#!/usr/bin/env bash
#!/bin/bash
#!env
/bin/int bash
PS1
environment variable?
PS1
is used to set the location of the PostScript
command.PS1
is used to define the default shell prompt for bash.PS1
is used as a per-system variable.PS1
is user-defined and does not have a default value or setting.
$ARG
$0
$1
$ARG0
list 0-5
seq 0 1 5
echo 0-5
seq 0 1 6
run
source
./
exec
exec
get
read
prompt
case
statement in a bash script?
end
done
esac
caseend
declare
displays output in a way that could then be used as input to another command?
-o
-n
-p
-m
while
loop in a shell script?
test
built-in with one argument, what will be the return if its argument is not null
?
false
true
unknown
-1
cd ~
?
HOMEDIR
HOMEPATH
HOME
MAILPATH
git commit
history. Which command should be used for this purpose, assuming a filename of nhl_scores.php
?
git log --history nhl_scores.php
git log --follow nhl_scores.php
git history nhl_scores.php
git commit-history nhl_scores.php
-ro
===
-eq
-fe
&
>
;
|
a
c
d
NUM
equal to 1?
NUM = 1
$NUM = 1
NUM= 1
NUM=1
DATE
within a shell script?
DATE="$(date +%s)"
DATE="date"
DATE="$(date)";
DATE="$date %s"
for
loop in a shell script?
{ }
do
and done
declare
command will create a variable that is read-only?
-r
-ro
-p
-x
LOCALE_DATE
DATE_FORMAT
LC_TIME
LC_DATE
netstat
displays interface information in a table-like format that might be suitable for use with scripting?
-i
-r
-t
-l
DAY
is equal to SUNDAY
?
if ($DAY == "SUNDAY")
if ($DAY -eq "SUNDAY")
if [[ $DAY == "SUNDAY" ]]
if [ DAY = "SUNDAY" ]
~/code/bin
to the path?
PATH=~/code/bin:$PATH
PATH=/code/bin:$PATH
PATH=/home/code/bin:$PATH
PATH=PATH:~/code/bin
git merge
can be used to attempt to roll back a merge that has conflicts?
--rollback
--abort
--rewind
--restart
git init
?
GIT_DIR
GIT_HOME
GIT_DEST
GIT_LOC
echo
with a bash script?
h
a
f
build.o
, from being tracked by git. Which character sequence can be used in the .gitignore
file to exclude or ignore that file in all directories?
build.o
/build.o
**/build.o
build.*
[AF]*
[af]*
*AF*
AF*
origin
, which git
command can be used to obtain additional information about the remote?
git show origin
git remote show origin
git show remotes
git remote list
$NUM
$CLA
$+
$#
TIMEOUT
TMOUT
TO
IDLETIME
echo $NUM #sending $NUM to output
. What will be the result of this line when executed?
NUM
variable.git clone
, you need to change the name of the remote so that it is not called origin
. Which option can be added to git clone
to accomplish this task?
--origin
--remote
--name
--remote-name
iostat
output shows the amount (percentage) of time spent in an involuntary wait scenario due to the hypervisor?
proc
wait
user
steal
LC_LIST
LC_GLOBAL
LC_ALL
ALL_LOCALE
case
statement in a bash script?
//
’eol
;;
<
remove
rm
unalias
delete
-a
-e
-m
-i
LANG
environment variable will configure the system to bypass locale translations where possible?
LANG=COMPAT
LANG=NONE
LANG=C
LANG=END
git config
command shows all of the configuration parameters that have been set?
--list
--show
-u
--display
2>
2>>
&>>
1>>
.yml
extension. What is the likely format for the contents of this file?
cat /etc/passwd | cut -d: -f1 > users.txt
?
users.txt
.users.txt
.users.txt
.users.txt
.$2
becomes $1
, $3
becomes $2
, and so on?
move
rev
shift
dec
git pull
to obtain changes to a shared repository. Which option should you add to git pull
in order to prevent autocommit so that you can look at the results of the merge first?
--pre-merge
--no-auto
--nc
--no-commit
until
loop in a bash script?
do
; done
start
; stop
beg
; end
until
; litnu
make
command. Which of the following will execute the configure script, assuming that it’s in the same directory as the script invoking it?
configure
./configure
../configure
/configure
git commit
command can be used to automatically add and commit the file?
-a
-b
-c
-d
LC_MONE
LC_CURRENCY
LC_MONETARY
LC_CURR
.profile
in a user’s home directory will set their time zone to Central time?
TZ=/Central ; export TZ
TIMEZONE=’America/Chicago’ ; export TIMEZONE
set TZ=/Central
TZ=’America/Chicago’; export TZ
ARRAY=(val1 val2)
ARRAY = "val1 val2"
ARRAY_PUSH($ARRAY,"val1","val2");
ARRAY{0} = "val1"
while
loop will examine one value to see if it is less than another?
-less
-lessThan
-lt
-lthan
LIST="one two three four"
, which of the following for
loop constructs will iterate through the elements in the list?
for LIST
for VAR in LIST
for VAR in $LIST
for $LIST -> $VAR
if
else if
elif
elsif
.gitmeta
gitlocalmeta
.git
git
2>
2>&1
2+1
+2+1
<>
&
&&
||
project1
and points the HEAD
toward that branch?
git branch project1
git checkout project1
git checkout -b project1
git create project1 -H
while
and an until
loop in a bash script?
while
loop always executes once; an until
loop does not.until
loop always executes once; a while
loop does not.while
loop executes as long as a condition is true; an until
loop executes until the condition is false.until
loop executes until a condition is true; a while
loop executes until a condition is false.$num1
is greater than $num2
, assuming both variables contain integers?
if [ "$num1" -gt "$num2" ]
if [ "$num1" > "$num2" ]
if ($num1 -gta $num2)
if [ $num1 gt $num2 ]
VAR
within a bash script?
VAR
$(VAR}
${VAR}
*VAR*