Bash Scripting and Automation: Practice Questions and Answers, Exams of Advanced Education

A series of practice questions and answers related to bash scripting and automation. It covers topics such as variable assignment, script execution, command usage, and git commands. The questions are designed to test understanding of key concepts and practical skills in scripting and automation, making it a valuable resource for students and professionals looking to enhance their knowledge in this area. It includes questions on topics such as orchestration, infrastructure as code (iac), and industry-standard management systems.

Typology: Exams

2025/2026

Available from 09/23/2025

solution-master
solution-master 🇺🇸

3.3

(28)

11K documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Scripting and Automation Chapter 14
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 commands in a Bash script will display "Farewell,
Jason" on the screen? - variable2=Farewell
echo $variable2 ", Jason"
Which of the following commands do you need to enter to end a Bash
shell script? - exit 0
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
Which of the following commands creates a variable and prompts the user
to type in text? - read
What would you enter at the command prompt to run a listdocs script
stored in the current directory? - /listdocs
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Bash Scripting and Automation: Practice Questions and Answers and more Exams Advanced Education in PDF only on Docsity!

Scripting and Automation Chapter 14 Which of the following are valid ways to assign a variable a value in a bash script? (Select two.) - 1. variable1=Hello

  1. declare -i num1= 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 commands in a Bash script will display "Farewell, Jason" on the screen? - variable2=Farewell echo $variable2 ", Jason" Which of the following commands do you need to enter to end a Bash shell script? - exit 0 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 Which of the following commands creates a variable and prompts the user to type in text? - read What would you enter at the command prompt to run a listdocs script stored in the current directory? - /listdocs

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 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

  1. real
  2. user 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 What command would you enter to assign the output of the date command to the firstmonday variable? - firstmonday=${date -- date="first Monday") 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

Which of the following commands can you use to delete a variable? - unset 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]" Which of the following are required when creating a case construct? - 1. Close each case with two semi-colons.

  1. Case structures must be closed using esac. 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. 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 $? 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 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! 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 Which of the following statements is true about the command myscript < mydata.txt? - myscript receives input (stdin) from mydata.txt. 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: #!/bin/bash declare -i count=5until [ $count -lt 3 ]doecho count $countcount=count-1done

Which of the following commands can you use to configure these properties? - git config Which of the following files can you configure to ignore certain file types from being committed to the local Git repository? - .gitignore 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 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

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.

  1. A proprietary software application is installed on each device. 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 orchestration attributes are typically configured? (Select two.) - 1. Start and stop time
  3. User name, title, and employee ID for user orchestration An orchestration workflow that creates computers might need which of the following data? (Select two.) - 1. Hostname
  4. Network configuration An orchestration workflow that creates a user might need which of the following data? (Select two.) - 1. Title
  5. Employee ID Which of the following would you use to automate configuration, coordination, and management of your computer systems and software? - Orchestration Which of the following BEST describes Infrastructure as Code (IaC)? - The process of managing and provisioning computer datacenters.