Scripting and Automation Chapter 14

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The list of characters on the left are special parameters that are set and maintained by the Bash shell. From the list on the left, drag the special parameter to the correct description on the right.

!: The process ID of the last background job. @: The position parameters as an array. 0: The name of the shell or shell script. #: The number of positional parameters. ?: The exit status of the last executed command.

When creating a Bash script, it is important to document the purpose of the script. Which of the following is a valid comment?

# This is a Bash script

Which of the following shell declarations should you enter on the first line of a script for a system that uses the Bash shell?

#!/bin/bash

Which of the following files can you configure to ignore certain file types from being committed to the local Git repository?

.gitignore

What would you enter at the command prompt to run a listdocs script stored in the current directory?

/listdocs

Which of the following are key differences between agent-based orchestration and agentless orchestration? (Select two.)

1. Agentless orchestration does not require a proprietary software agent to be installed on the managed hosts. 2. Agent-based requires that proprietary software is installed on each device you wish to monitor.

Which of the following are required when creating a case construct?

1. Close each case with two semi-colons. 2. Case structures must be closed using esac.

An orchestration workflow that creates computers might need which of the following data? (Select two.)

1. Hostname 2. Network configuration

Orchestration is the automated configuration, coordination, and management of computer systems and software. Orchestration takes advantage of several tasks that are usually automated to create a more complex workflow. Which of the following workflow needs can be satisfied by orchestration? (Select four.)

1. Server provisioning 2. Inventory 3. Configuration management 4. Automated builds and code deployments

Which of the following orchestration attributes are typically configured? (Select two.)

1. Start and stop time 2. User name, title, and employee ID for user orchestration

Which of the following are unique characteristics of using an agent for orchestration implementation? (Select two.)

1. The agent can be programmed to monitor systems. 2. A proprietary software application is installed on each device.

An orchestration workflow that creates a user might need which of the following data? (Select two.)

1. Title 2. Employee ID

Which of the following industry-standard management systems can be used for agentless orchestration? (Select four.)

1. WMI and WinRM 2. SSH 3. CIM 4. SNMP

You are working with a bash script, and there are multiple variables being used. Which of the following commands can be used to determine which commands are environment variables and which are shell variables? (Select two.)

1. set 2. printenv

You can use the time command to determine how long a given command takes to run. The output of the time command displays three values. Which of the following are the time values displayed by the time command? (Select three.)

1. system 2. real 3. user

Which of the following are valid ways to assign a variable a value in a bash script? (Select two.)

1. variable1=Hello 2. declare -i num1=4

You have created the following Bash script: #!/bin/bashdeclare -i num1declare -i num2declare -i totalnum1=10num2=2total=num1-num2echo $totalexit 0 What will be displayed on the screen after running the script?

8

Which of the following describes the function of the export command?

Converts shell variables to environment variables.

Which of the following is a significant benefit of using an orchestration workflow?

It frees up time for IT team members to take on more important projects.

Which of the following would you use to automate configuration, coordination, and management of your computer systems and software?

Orchestration

Given the following bash script: #!/bin/bashmynumber=5guess=0echo -e "I am thinking of a number from 1 to 10\n"read -p "Enter guess: " guessif (( guess == mynumber ))thenecho "That is correct!"elif (( guess != mynumber )); thenecho "Sorry, that is not my number!"fi Which of the following would be displayed if the number 12 is entered as the guess?

Sorry, that is not my number!

Which of the following BEST describes Infrastructure as Code (IaC)?

The process of managing and provisioning computer datacenters.

Given the command ls > myfiles which of the following describes the results?

The stdout of the ls command is redirected to the myfiles file.

Given the following bash script, what is the output if the user enters Kali? #!/bin/bashecho 'Which Linux distribution do you like? 'read distro case $distro inubuntu)echo "Ubuntu is based on Debian.";;centos|rhel)echo "CentOS and RHEL are RPM based distributions.";;windows)echo "That is not a Linux distribution.";; *)echo "This is an unknown Linux Distribution.";;esac

This is an unknown Linux distribution.

You are writing a bash script that lists the contents of a file. You would like to have any stderr messages sent to a file. Which of the following commands will write the error message to a projects.err file?

cat projects 2> projects.err

Troy, a system administrator, created a script to automate some daily administrative tasks. Which of the following commands would make Troy's script, /scripts/dailytasks, executable by everyone but writable only by its owner?

chmod u=rwx,go=rx /scripts/dailytasks

Given the following bash script: #!/bin/bash declare -i count=5until [ $count -lt 3 ]doecho count $countcount=count-1done Which of the following shows the output from this script?

count 5 count 4 count 3

While writing a shell script, you want to perform some arithmetic operations. Which of the following commands is used to create an integer variable?

declare -i variablename

You want to create a variable called marketing that has a value of TestOut. You want this variable to be available each time a new shell environment is spawned as a process. Which of the following commands will meet your requirements?

declare -x marketing=TestOut

A script named myscript contains the following command line: echo $1 $2 $3 The following command is typed in an interactive shell. myscript dog cat bird frog Which of the following will be displayed in the interactive shell?

dog cat bird

You have created the following array in the statearray variable: declare -a statearray=(Nevada Utah California Arizona Texas) Which of the following commands will display the phrase Life elevated - Utah?

echo "Life elevated - $statearray[2]"

Anna, a technician, executes a command to display the contents of a file and receives the following output: [user@linux ~]$ cat myfile.txtat: myfile.txt: No such file or directory Which of the following commands would Anna enter to find out the exit code that was returned by this command?

echo $?

You have created a breakfast variable with a value of "yogurt and granola." What command would you enter to only display "granola" from the shell command prompt?

echo ${breakfast:11}

Which of the following commands do you need to enter to end a Bash shell script?

exit 0

What command would you enter to assign the output of the date command to the firstmonday variable?

firstmonday=${date -- date="first Monday")

A script developer is working on some new features for administering Linux servers and wants to add the features without changing the master branch. Which of the following is the BEST command to use?

git branch

A technician wants to obtain the ABRT repository from a git online service. Which of the following commands should be used?

git clone [email protected]:abrt/abrt.git

Cindy, a technician, created a Perl script named server-info.pl that is used for gathering server information. Cindy wants to add the file to the repository and has executed the command git add server-info.pl. Which of the following commands should Cindy execute NEXT?

git commit -m "Adding server-info.pl script"

After installing Git and before the first commit is made, the user.name and user.email properties need to be configured. Which of the following commands can you use to configure these properties?

git config

Which of the following is the BEST command for showing the commit history of a repository?

git log

Which of the following is the BEST command to use for joining a branch to a master?

git merge

Alberto, a system administrator, is working with another system administrator, Leroy, to update the bash scripts used on various servers. The bash scripts are stored in a Git repository. Alberto updated a script that may have also been updated by Leroy. Which of the following commands SHOULD Alberto execute before he commits his changes to the repository?

git pull

Lydia, a developer, recently made changes to some files and wants to update the changes on the master branch. Which of the following is the BEST command to use for this purpose?

git push

When a Git repository is created using git init, Git creates a directory named .git. This directory contains all the information necessary for that repository to work correctly. Which of the following directories contain the scripts that are run during each Git phase?

hooks

Given the following bash script, #!/bin/bashfor i in $(ls)doecho item: $idone Which of the following shows a possible output if the script is executed from Bill's home directory?

item: Desktop item: Documents item: Downloads

Which of the following statements is true about the command myscript < mydata.txt?

myscript receives input (stdin) from mydata.txt.

Given the following command sequence: echo 'blue orange green brown' | while read a b c d; do echo output: $b $c $a $d; done Which of the following is the correct output?

orange green blue brown

Which of the following commands creates a variable and prompts the user to type in text?

read

Which of the following commands can you use to delete a variable?

unset

Which of the following commands in a Bash script will display "Farewell, Jason" on the screen?

variable2=Farewell echo $variable2 ", Jason"


संबंधित स्टडी सेट्स

Visualization And Categorization

View Set

International Relations Chapter 2

View Set

Chapter 33- Lewis Coronary Artery Disease and Acute Coronary Syndrome

View Set

Chapter 3: Drug Regulation, Development, Names, and Information Study Guide

View Set

Macro Chapters 13, 14, 15, 16 & 18 TopHat

View Set