Click Here to take the test. (You need an account. It's free)

 

1. When using a case statement within a shell script, which sequence denotes the ending of the case/switch statement?

  • caseend
  • esac
  • endcase
  • }

2. Which of the following commands will execute a script and then exit the shell?

  • run
  • source
  • ./
  • exec

3. Which option to the export built-in command makes names available as functions to child processes?

  • -m
  • -e
  • -w
  • -f

4. Which character sequence is used to provide a default case when used within a case statement in a shell script?

  • default
  • =)
  • —>
  • *)

5. Which sequence is used to mark the beginning and end of the commands to execute within a for loop in a shell script?

  • Curly braces: { }
  • The keywords do and done
  • Semicolons: ;
  • Tabs

6. When sourcing a file in Bash, which chmod command would be necessary to provide the minimum privileges in order for the file to be sourced correctly, assuming that your current user owns the file?

  • chmod 600
  • chmod 755
  • chmod 777
  • chmod 400

7. You are working with a shell script called listusers and the script does not execute with the error "permission denied". What could be the possible cause of this issue?

  • The script should have an .sh extension.
  • The script contains a syntax error.
  • The script does not have its execute permission set correctly.
  • The script is named with lowercase letters.

8. Which character sequences denote an alternate command to execute if the preceding command does not exit successfully?

  • &&
  • -
  • ||
  • EL

9. You have created an alias but it is gone the next time you log in. Which of the following best explains this scenario?

  • The alias was not placed into an initialization script.
  • The alias was invalid.
  • The command is not valid for which the alias was created.
  • The alias created an invalid symlink.

10. Which file test is used to determine if you are the owner of the file being tested?

  • -m
  • -k
  • -w
  • -O

11. Which environment variable contains the username of the currently logged-in user?

  • LOGNAME
  • LOGIN
  • LOGGEDIN
  • LOGINUSER

12. Within which directory should you place files to have them automatically copied to a user’s home directory when the user is created?

  • /etc/userhome
  • /etc/templateuser
  • /etc/skel
  • /home/skel

13. Which option to the readonly command marks a function as being read-only?

  • -a
  • -r
  • -f
  • -p

14. You have created a README file and placed it into /etc/skei so that users get the file in their home directories. The file is missing from some home directories on the system. Which of the following best explains this scenario?

  • The file is not copied automatically for existing users.
  • The file is too big for a user’s home directory.
  • The file already exists.
  • The file needs a file extension.

15. Which file test operator is used to determine if the file is a symbolic link?

  • -h
  • -p
  • -S
  • -t

16. Which operator is used to test if a value is greater than or equal to something in a Bash script?

  • !=
  • >=
  • =>
  • >>

17. Which sequence of characters will execute two commands but only if the first command exits successfully?

  • -
  • &*
  • &&
  • &

18. Which find command will locate all files where the users have the execute bit set?

  • find ./ -type f -perm 700
  • find / -type f -perm -u+x
  • find / -type f -perm 777
  • find / -type f -perm -execuser

19. Which of the following best describes the PSI 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.

20. Which variable within a Bash script is used to access the first command-line parameter?

  • $ARG
  • $CMD
  • $1
  • $ARG0

21. Which option to the export built-in command displays the list of exported variables?

  • -p
  • -a
  • -t
  • -d

22. Which of the following commands will obtain the date in seconds since the epoch and place it into a variable called DATE within a shell script?

  • DATE="$(date +%s)"
  • DATE="date"
  • DATE="$(date)";
  • DATE="$date %s"

23. Which keyword declares a block of code to be a function in a Bash script?

  • function
  • repeat
  • func
  • block

24. Which environment variable can be set if you want to automatically log users out of their shell after a certain period of inactivity?

  • TIMEOUT
  • TMOUT
  • TO
  • IDLETIME

25. You have a file containing bash functions. Which command can be used to add these functions to the current environment?

  • function
  • include
  • require
  • source

26. Which of the following tests the return value from the previous command to see if the command was successful?

  • if [ $? -eq 0 ];
  • if [ $? = 0 ];
  • if ($PREV == 0) {
  • if [ $RETV === 0 ];

27. You have specialized software that needs to be installed with an empty environment. Which option to the env command can be used to meet this requirement?

  • -e
  • -i
  • -f
  • -c

28. Which find command will locate all files named with an .sh extension?

  • find / -name "*.sh"
  • find / -name "*.sh" -type f
  • find / -name "*.sh" -type d
  • find ./ -name "*.sh"

29. Which of the following provides the end for an if conditional in a Bash script?

  • ex
  • }
  • ]
  • fi

30. Which command within a shell script awaits user input and places that input into a variable?

  • exec
  • get
  • read
  • prompt

31. Which command is used to read and execute commands from a file in the Bash shell?

  • run
  • execute
  • source
  • func

32. Which keyword(s) is/are used to begin an alternate condition within a Bash script?

  • if
  • else if
  • elif
  • elsif

33. Which of the following is valid syntax to create a variable named FILENAME in a Bash script and set it equal to the second command- line argument?

  • $FILENAME = $2
  • FILENAME=1
  • FILENAME = $(2)
  • FILENAME=$2

34. Which option of declare displays output in a way that could then be used as input to another command?

  • -o
  • -n
  • -p
  • -m

35. When using the test built-in with one argument, what will be returned if its argument is not null?

  • false
  • true
  • unknown
  • -1

36. Which of the following commands removes a currently defined aliased command?

  • remove
  • rm
  • unalias
  • delete

37. You have a Bash script that uses the following find command: find . -name ".git" -type d When another administrator uses the script, it does not find all of the indicated directories. Which of the following is the best explanation for this scenario?

  • The find command is tied to specific users.
  • The find command cannot find directories beginning with a dot.
  • The find command begins the search in the current directory.
  • The find command cannot find directories.

38. Which shell built-in command is used to display a list of read-only variables?

  • ro
  • readonly
  • env-ro
  • ro-env

39. Which option to the set command enables debugging output?

  • -d
  • +d
  • -x
  • +x

40. Which file test operator is used to determine if the file is not zero size?

  • -d
  • -e
  • -f
  • -s

41. Which option of the declare command will create a variable that is read-only?

  • -r
  • -ro
  • -p
  • -x

42. Which unset option can be used to remove a function from being defined?

  • -r
  • -a
  • -f
  • -g

43. You need to prompt the user to enter two values in a Bash script and capture them in variables VALI and VAL2, Which of the following commands can be used for this purpose?

  • read VAL1 VAL2
  • prompt VAL1 VAL2
  • VAL1=$0 VAL2=$1
  • (VAL1 VAL2) = prompt

44. Which mathematical operator is used for division within a Bash script?

  • \
  • /
  • *
  • //

45. Which characters are used to denote the beginning and end of the test portion of a while loop in a shell script?

  • Parentheses ( )
  • Curly braces { }
  • Square brackets [ ]
  • Double-quotes " "

46. Which of the following statements prepends the /usr/local/bin path to the path for a Bash shell?

  • $PATH=/usr/local/bin:$PATH
  • PATH=/usr/local/bin:$PATH
  • PATH=$PATH:/usr/local/bin
  • PATH=$PATH;/usr/local/bin

47. Which option to the seq command sets a delimiter of a space between the numbers 1 through 5?

  • seq -s ' ' 1 5
  • seq -d ' ' 1 5
  • seq 1 5
  • seq -m 1 5

48. You need to create a function that will be available each time that you log in to the system. Within which file should this function be placed?

  • .bash_profile
  • .rc
  • /etc/profile
  • .bash_run

49. You need to view the current environment variables in a single line rather than with newlines separating each variable. Which option to the env command can be used for this purpose?

  • -n
  • -0
  • -c
  • -e

50. Which of the following statements adds the /srv/bin path to the path for a Bash shell?

  • PATH=/srv/bin
  • PATH=$PATH:/srv/bin
  • PATH = /srv/bin
  • PATH=/srv/bin;$PATH

51. When using a while loop in Bash, which character sequence marks the end of the loop?

  • elihw
  • done
  • end
  • od

52. Which option to the unset command explicitly informs the command that the name given refers to a shell variable and not a function?

  • -a
  • -s
  • -v
  • -e

53. Which option to bash will cause the shell to be executed without reading the initialization files?

  • -no-rc
  • -no-init
  • -norc
  • -rc-none

54. Which of the following commands will print a list of 6 numbers beginning at 0 within a Bash script?

  • list 0-5
  • seq 0 1 5
  • echo 0-5
  • seq 0 1 6

55. You need to send an email to the superuser if a command is successful. Which of the following commands will send mail from a Bash script?

  • smtpsend
  • mailx
  • sendm
  • mailsend

56. Which of the following files is a systemwide initialization script for Bash?

  • /etc/bash.bashrc
  • /etc/bash.init
  • /etc/bash.cfg
  • /etc/bash/bash.init

57. Which option to the export built-in command removes a variable from being exported?

  • -m
  • -o
  • -r
  • -n

58. Which of the following commands removes an environment variable that has been set?

  • profile -unset
  • env -u
  • set -u
  • import

59. A command has the following listing obtained with ls - la: -rwsr-xr-x 1 john john 21 Oct 19 10:01 script.sh What does the s denote within the user permissions in the listing?

  • The suid bit has been set for this program.
  • This is a symlink.
  • The file will not be executable.
  • The file is a special system file.

60. Assuming that a space-separated list of values has been defined as 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

61. Which key sequence can be used to terminate a Bash script?

  • Ctrl+d
  • Ctrl+l
  • Ctrl+a
  • Ctrl+c

62. You are working with a user who is reporting that their environment does not have certain variables defined, but other users do have those same variables available within their environment on login. The issue was not corrected by having the user log out and then log in again, and you can see their successful login. What is the most likely explanation for this issue?

  • The user has logged in from the console.
  • The user is using a different shell.
  • The user has removed the environment variables manually.
  • The user is logging in to a different system.

63. Which chmod command grants the user execute permission on a script?

  • chmod user += exec
  • chmod u+x
  • chmod 644
  • chmod u+all

64. Which of the following tests will determine if a file exists and can be read by the user executing the test?

  • -e
  • -m
  • -a
  • -r

65. Assume that you have a variable called $FILEPATH within a Bash shell script. Which characters can be used to ensure that the variable will be interpolated correctly regardless of where the variable appears within the script?

  • Dollar sign: $FILEPATH
  • Curly braces: ${FILEPATH}
  • Parentheses: $(FILEPATH)
  • Square brackets: $[FILEPATH]

66. What is the order in which user configuration files are located on login to a Bash shell?

  • .bash_login, .profile, /etc/profile
  • .bash_profile, .bash_login, .profile
  • .profile, .bash_login, .bash_profile
  • .bash_login, .bash_profile, .profile

67. Which option enables debugging when used on the interpreter (#!) line within a Bash script?

  • -x
  • -d
  • -a
  • -f

68. When creating a shell script, which of the following commands is used to display the contents of variables?

  • var_dump
  • echo
  • ls
  • env

69. Which character sequence can be used for command substitution in Bash?

  • Backquotes: ' '
  • Single quotes: ‘ '
  • Double quotes: ""
  • Backslashes: \

70. Which of the following tests will determine if a file exists in the context of a shell script?

  • -a
  • -e
  • -m
  • -i

71. Which character or character sequence denotes the beginning of a while loop in a Bash script?

  • start
  • {
  • >>
  • do

72. Which looping construct is executed at least once in a Bash script?

  • while
  • for
  • until
  • case

73. You receive an exit code of 1 when working with the grep command in a Bash script. What does exit code 1 mean with grep?

  • Error
  • Success
  • Search pattern not found
  • Search pattern found

74. Which character or character sequence is equivalent to the source built-in in Bash?

  • <>
  • .
  • ->
  • %

75. According to the FHS, which of the following directories is used for local binaries?

  • /usr/local/bin
  • /usr/bin
  • /usr/sbin
  • /home/scripts

76. When setting the shebang line of a shell script, which of the following commands will help to determine the location of the interpreter automatically?

  • #!/usr/bin/env bash
  • #!/bin/bash
  • #!env
  • /bin/int bash

77. Which environment variable is used when changing directory with the tilde character, such as cd ~ ?

  • HOMEDIR
  • HOMEPATH
  • HOME
  • MAILPATH

78. 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)?

  • ~/.bash_logout
  • /etc/bash.bash_logout
  • /home/.bash_logout
  • /etc/bash_logout

79. Which test within a shell script whiie loop will examine one value to see if it is less than another?

  • -less
  • -lessThan
  • -It
  • -lthan

80. If a variable has been created using the set command, which command can be used to remove the variable?

  • remove
  • del
  • delete
  • unset

81. You are attempting to copy several files, but the cp command keeps asking for confirmation before overwriting. Which of the following best describes the most likely cause?

  • The cp command has been compiled to ask for confirmation.
  • The cp command always prompts for confirmation.
  • The cp command cannot be used for the purpose described.
  • The cp command has been aliased to include the -i option.

82. Which of the following files is executed with every interactive Bash shell invocation?

  • /etc/bash.d
  • /etc/bash.interactive
  • ~/.bash_inter
  • ~/.bashrc

83. Which of the file test operators is used to determine if a file is a directory?

  • -e
  • -d
  • -w
  • -a

84. Which of the following will output the number 5 as part of a Bash script?

  • echo 2+3
  • echo 2 + 3
  • echo $[2+3]
  • echo ${2+3}

85. Which of the following commands ensures that the -la options are used when the is command is executed without other options?

  • alias ls="ls -la"
  • ln -s is is -la
  • alias "ls -la" = ls
  • set ls

86. What characters are used to mark a sequence of commands as a function in a Bash script?

  • Parentheses to declare the function (optional) and curly braces to contain the commands
  • Curly braces to declare the function and parentheses to contain the commands
  • Square brackets to declare the function and curly braces to contain the commands
  • Runquotes to denote the function

87. Which variable is available to a Bash script and contains the name of the script itself?

  • $SCR
  • $SCRIPT
  • $CMD
  • $0

88. Which of the following creates an array in a Bash script?

  • ARRAY=(val1 val2)
  • ARRAY = "val1 val2"
  • ARRAY_PUSH($ARRAY,"val1","val2");
  • ARRAY{0} = "val1"

 

{jssocials}