TestOut LabSim 14.1.5 Questions

pdf

School

Eastern Gateway Community College *

*We aren’t endorsed by this school

Course

1680

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

11

Report

Uploaded by MateCaribouMaster661

11/15/23, 12 : 42 AM Page 1 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us 14.1.5 Practice Questions Candidate: Levi Cloakey (Lcloakey) Date: 11/15/2023 12:42:29 am • Time Spent: 03:16 Score: 90% Passing Score: 80%
11/15/23, 12 : 42 AM Page 2 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 1: Correct Which of the following are valid ways to assign a variable a value in a bash script? (Select two.) variable1=Hello num1 := 7; type string variable1=Hello declare -i num1=4 num1==5 Explanation variable1=Hello and declare -i num1=4 are both ways to assign a variable a value. Declare is used to type a variable as an integer (whole numbers only). Variables hold values that the script uses when running. These values can be either numbers or text. References 14.1.4 Scripting Facts 14.2.1 Bash Shell Environments and Shell Variables 14.2.2 Bash Shell Parameters and User Variables 14.2.5 User Variables and Shell Arithmetic 14.2.7 Shell Environments, Bash Variables and Parameters Facts q_script_assign_variable_lp6.question.fex Question 2: Correct
11/15/23, 12 : 42 AM Page 3 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us You have created the following Bash script: #!/bin/bash declare -i num1 declare -i num2 declare -i total num1=10 num2=2 total=num1-num2 echo $total exit 0 What will be displayed on the screen after running the script? 2 12 10 8 Explanation The script fi rst sets all three variables ( num1 , num2 , and total ) as integers. Then num1 and num2 are assigned the numbers (integers) 10 and 2, respectively. The total variable is then set to equal 10-2 , which is 8 . The echo command then displays the value of the $total variable on the screen, which is now set to 8 . References 2.1.3 Shell Commands 14.1.1 Bash Scripting Overview 14.1.3 Executing and Sourcing a Script 14.1.4 Scripting Facts q_script_declare_total_lp6.question.fex
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
11/15/23, 12 : 42 AM Page 4 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 3: Correct Which of the following commands in a Bash script will display "Farewell, Jason" on the screen? variable2 = Farewell declare -i ", Jason" $variable2 variable2=Farewell echo $variable2 ", Jason" variable2 = Farewell echo $variable2 ", Jason" variable2 = Farewell echo ", Jason" $variable2 Explanation The following commands will display "Farewell, Jason" on the screen: variable2=Jason echo $variable2 ", Jason" Placing spaces around the equal sign (=) will normally cause an error because the script tries to run the command variable2, which by default does not exist. The following commands will display ", JasonFarewell": variable2 = Farewell echo ", Jason" $variable2 The declare -i command is used to type a variable as an integer. References 2.1.3 Shell Commands 14.1.1 Bash Scripting Overview 14.1.3 Executing and Sourcing a Script
11/15/23, 12 : 42 AM Page 5 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us 14.1.4 Scripting Facts q_script_echo_farewell_jason_lp6.question.fex Question 4: Correct Which of the following commands do you need to enter to end a Bash shell script? "exit 0" exit 0 exit=0 # exit 0 Explanation You need to enter exit 0 to end a Bash shell script. # exit 0 would be a comment in the script, and would not end the processing. There should be no quotation marks ( " " ) surrounding the exit 0 command. exit=0 sets an exit variable to zero ( 0 ). References 14.1.4 Scripting Facts q_script_exit_0_end_lp6.question.fex
11/15/23, 12 : 42 AM Page 6 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 5: Correct 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 775 /scripts/dailytasks chmod u=x,g=x /scripts/dailytasks chmod u=rwx,go=rx /scripts/dailytasks chmod 577 /scripts/dailytasks Explanation chmod u=rwx,go=rx /scripts/dailytasks sets the permissions for the owner to be able to read, write, and execute the script. Both group and other are assigned read and execute permissions. chmod 577 /scripts/dailytasks would not give owner write permissions but would give group and other write permissions. chmod u=x,g=x /scripts/dailytasks would only give execute permissions to owner and group. chmod 775 /scripts/dailytasks would give write permissions to group. References 14.1.4 Scripting Facts q_script_permissions_lp6.question.fex
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
11/15/23, 12 : 42 AM Page 7 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 6: Correct Which of the following commands creates a variable and prompts the user to type in text? echo read declare -i pwd Explanation The read command creates a variable and prompts the user to type in text. It assigns the value the user types to the variable. By default, the user input is treated as a text string. The echo command displays information on the screen. The pwd command displays the present working directory. The declare -i command is used to type a variable as an integer. References 14.1.1 Bash Scripting Overview 14.1.4 Scripting Facts q_script_read_command_lp6.question.fex
11/15/23, 12 : 42 AM Page 8 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 7: Incorrect What would you enter at the command prompt to run a listdocs script stored in the current directory? /listdocs ./listdocs Explanation You would enter the ./listdocs command to run the script if it resides in the current directory. ( ./ indicates the present working directory.) References 14.1.4 Scripting Facts q_script_run_current_directory_lp6.question.fex
11/15/23, 12 : 42 AM Page 9 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096-…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 8: Correct Which of the following shell declarations should you enter on the fi rst line of a script for a system that uses the Bash shell? /bin/tsh #!/bin/bash /bin/bash #!/bin/csh Explanation #!/bin/bash is the shell declaration that you should enter on the fi rst line of a Bash script. #! is referred to as a shebang or hashbang and is followed by the path to the shell. /bin/bash is the path to the shell and is not the correct syntax for a shell script. /bin/tsh is the path to the trusted shell, tsh. #!/bin/csh would be used if the C shell was being used instead of the bash shell. References 14.1.4 Scripting Facts q_script_shell_declaration_lp6.question.fex
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
11/15/23, 12 : 42 AM Page 10 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 9: Correct 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.) system network processing bounce user standard real Explanation The time command output shows three values as follows: real is the time from the moment the Enter key was pressed until the moment the command is completed. user is the amount of CPU time spent in user mode. system is the amount of CPU time spent in kernel mode. All other listed values are not displayed using the time command (network, processing, bounce, and standard). References 14.1.4 Scripting Facts q_script_time_values_lp6.question.fex
11/15/23, 12 : 42 AM Page 11 of 11 https://labsimapp.testout.com/v6_0_575/exam-engine.html/72145096…n/31308678/783da08f-b2ef-464f-8624-23fec01f7276/end ? locale=en-us Question 10: Correct 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 !! This is a Bash script # This is a Bash script $ This is a Bash script Explanation Comments begin with a number sign (#). The shell ignores these lines when running the script. Comments help communicate how the script was constructed and what it is designed to do. // will return the error "Is a directory." $ and !! will both return the error "Command not found." References 14.1.4 Scripting Facts q_script_valid_comment_lp6.question.fex Copyright © 2023 TestOut Corporation All rights reserved.