Introduction to Linux II – Chapter 02 Exam Answers 100% PDF file

How to find: Press “Ctrl + F” in the browser and fill in whatever wording is in the question to find that question/answer. If the question is not here, find it in Questions Bank.

NOTE: If you have the new question on this test, please comment Question and Multiple-Choice list in form below this article. We will update answers for you in the shortest time. Thank you! We truly value your contribution to the website.

1. Which of the following steps is NOT performed while creating a shell script?

  • Create a file with commands
  • Make the file executable
  • Login as root on the server console
  • Put #!/bin/bash as the first line

2. The first line in a shell script reads:#!/bin/bashWhat does it signify?

  • It is a comment
  • The executable (shell) to use to run the script
  • Name of the editor used to create the file
  • The script requires root login

3. The command bash script_file can be used to directly execute a shell script. True or False?

  • True
  • False

4. Which of the following is placed before a script name to execute it from the current directory?

  • #!
  • !!
  • ./
  • //

5. Instead of specifying the current directory, it is better to place the script in a location that is included in the __________ variable.

  • SCRIPTS
  • ENV
  • GLOBAL
  • PATH

6. An ideal place for a regular user (not a super user), to place their shell scripts would be:

  • /sbin
  • /home/john/bin
  • /usr/local/sbin
  • /bin

7. Use of SETUID permission on scripts is the best way to specify permissions. True or False?

  • True
  • False

8. A user has written a few scripts for private use. Which of the following commands should be used so that no one else has execute permission?

  • chmod u-rx script_file
  • chmod u+x script_file
  • chmod -R 755 script_file
  • chmod a+x script_file

9. Which of the following commands will produce the same result as start=`date`?

  • start=date
  • start=%date%
  • start=$(date)
  • start=(date)

10. The __________ statement can be used to gather information from the user running the script.

  • read
  • for
  • seq
  • if

11. The command read –p will capture the current position of the mouse pointer. True or False?

  • True
  • False

12. Conditional statements CANNOT be used to determine which of the following?

  • System runlevel
  • If the file exists
  • If two strings match or not
  • If two numeric values match

13. When will the condition test –n STRING be true?

  • If the length of STRING is nonzero
  • If the length of STRING is zero
  • Never
  • Always

14. In shell scripts, the conditional statement if must always end with:

  • then
  • elif
  • fi
  • False condition

15. The return status from a command is 1. What does this indicate?

  • Calculation done by the command yields the result 1
  • Command is still running in the background
  • Command executed successfully
  • Command did not execute successfully

16. A user jamie already exists in the system. The command grep jamie /etc/passwd displays one user record. Running the echo $? command immediately after the grep command would result in what output?

  • 5
  • 1
  • 2
  • 0

17. Which of the following will NOT handle bad user input properly:

  • Checking the value of the $? variable using an if statement
  • Checking the validity of user input before passing it on to the command
  • Checking the return value of a command directly in the conditional part of the if statement
  • Checking the command’s Standard Output

18. A user wants an email sent when his shell script is executed successfully. Which of the following commands in the script can do this?

  • mail root
  • echo $mail
  • mail brad
  • cron job will send an email by default

19. The __________ statement is most useful in performing an operation on multiple items.

  • read
  • for *
  • test
  • many

20. What will the following statement do?
for name in `cat /root/users`

  • Get into an infinite loop
  • Assign to the name variable each value in the specified file
  • Run for two values cat and /root/users
  • Report an error

21. The output of the command seq 10 10 30 will be:

  • 50
  • 10 10 30
  • 10 20 30
  • 3

22. The ___________ command is used to print a sequence of numbers.

  • seq
  • series
  • num
  • list

23. The statement if [ -d file ] will be true, if the file:

  • Is executable
  • Exists
  • Is writable
  • Is a directory

24. Which of the following file test statement conditions is NOTcorrect?

  • -d filename tests if the file is in the current directory
  • -x filename tests a file to determine if it is executable
  • -w filename tests a file to determine if it is writable
  • -e filename tests if the file exist

25. A user wants to execute a script called test1_script. What type of permission does she need on the test1_script file?

  • Read and execute
  • Read and write
  • Read only
  • Write only

26. Command substitution can be used to insert the output of a command as another command’s argument. True or False?

  • True
  • False

Download PDF File below:

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x