Summary

Summary

In this chapter, we examined how to create shell initialization scripts, by examining how to set environment variables and execute commonly used script commands. In addition, we reviewed some basic shell script patterns, which can be used within .profile (and other shell scripts) to perform a wide variety of repetitive actions.

Questions

1. 

What is the name of the Bourne shell initialization script?

  1. .cshrc

  2. .login

  3. .profile

  4. .init

 C. The name of the Bourne shell initialization script is .profile .

2. 

What is the name of the site-wide skeleton file for the Bourne shell initialization file?

  1. /etc/skel/local.cshrc

  2. /etc/skel/local.login

  3. /etc/skel/local.profile

  4. /etc/skel/local.init

 C. The name of the site-wide skeleton file for the Bourne shell initialization file is /etc/skel/local.profile .

3. 

What command would be used to set the value of the environment variable TERM to be vt220?”

  1. TERM=vt220

  2. TERM=‘vt220’

  3. TERM=vt220

  4. setenv TERM=‘vt220’

 A.  TERM=vt220 will set the environment variable for the terminal type to vt220.

4. 

What escape string is used to print an ASCII beep character in a shell prompt?

  1. \a

  2. \d

  3. \h

  4. \H

 A. The ASCII beep character is \a .

5. 

What escape string is used to print a date string in a shell prompt?

  1. \a

  2. \d

  3. \h

  4. \H

 B. The date string is represented by \d .

6. 

What escape string is used to print the full hostname in a shell prompt?

  1. \a

  2. \d

  3. \h

  4. \H

 D. The shell prompt is set by \H .

7. 

What escape string is used to print a short hostname in a shell prompt?

  1. \a

  2. \d

  3. \h

  4. \H

 C. The short hostname is represented by \h .

8. 

What command is used to source another shell script while maintaining all environment settings?

  1. source

  2. sh

  3. .

  4. ./

 C. The source command is   . `.

9. 

What command would be used to display the string “Status OK” while .profile was being executed during shell initialization?

  1. println "Status OK"

  2. printf "Status OK"

  3. echo "Status OK"

  4. cat "Status OK" >> /dev/null

 C. The command echo  `Status  OK` will display the `Status  OK` string.

10. 

What parameter is used with the test command to determine whether a file is a special block file?

  1. -b

  2. -block

  3. -blockfile

  4. -bf

 A. The  b option is used to test for special block files.

Answers

1. 

C. The name of the Bourne shell initialization script is .profile.

2. 

C. The name of the site-wide skeleton file for the Bourne shell initialization file is /etc/skel/local.profile.

3. 

A. TERM=vt220 will set the environment variable for the terminal type to vt220.

4. 

A. The ASCII beep character is \a.

5. 

B. The date string is represented by \d.

6. 

D. The shell prompt is set by \H.

7. 

C. The short hostname is represented by \h.

8. 

C. The source command is “.".

9. 

C. The command echo "Status OK" will display the "Status OK" string.

10. 

A. The –b option is used to test for special block files.



Part I: Solaris 9 Operating Environment, Exam I