Shell Programming for System Administrators

( SA-245 ) Instructor-led Training

 

     Course Description Back To Top

The Shell Programming for System Administrators course teaches students to read, write, and debug shell scripts. The course begins by covering simple scripts to automate frequently executed commands, continues by adding conditional logic, user interaction, loops, menus, traps, and functions to enhance the productivity and effectiveness of the user. This course is intended for System Administrators who have mastered the basic Solaris[tm] Operating Environment and who would like to read and understand the various boot scripts, and write their own scripts to automate their day-to-day tasks. This course explores in detail the Bourne and Korn shell scripting languages.

 
     Who Can Benefit Back To Top

The System Administrators can benefit from taking this course.

 
     Prerequisites Back To Top

To succeed fully in this course, students should be able to:

  • Use basic UNIX® commands such as rm, cp, man, more, mkdir, ps and chmod
  • Create and edit text files in vi or a text editor
  • Understand the system boot process and proper shutdown procedures
  • Create users, passwords and set file permissions
  • Understand device naming conventions to mount and unmount file systems
  • Use software package commands such as pkgadd, pkgrm, and pkginfo
  • These skills are typically acquired through attendance in SA-118 and SA-238

     
         Skills Gained Back To Top

    Upon completion of this course, you should be able to:

  • Develop and debug scripts
  • Use local and environmental variables, and shell metacharacters in scripts
  • Customize system-wide shell initialization files
  • Use regular expression characters with the grep, sed and nawk utilities
  • Write sed scripts to perform non-interactive editing tasks
  • Write nawk scripts to manipulate individual fields within a record
  • Write nawk scripts to write reports based upon an input file
  • Use the exit status of a command to determine if the command succeeded or failed
  • Access and process command-line arguments passed into a script
  • Develop a USEAGE message to display when a script is invoked incorrectly
  • Use flow control constructs such as branching and looping
  • Perform string manipulation and integer arithmetic on shell variables
  • Write a script that uses functions
  • Write a script that uses a trap to control the behavior of scripts upon receipt of a signal

         Related Courses Back To Top

  • Before: SA-118: Fundamentals of Solaris 8 Operating Environment for System Administrators
  • Before: SA-238: Solaris 8 Operating Environment System Administration I
  • After: SA-288: Solaris 8 Operating Environment System Administration II

     
         Course Content Back To Top

     

    Module 1: UNIX Shells and Shell Scripts


  • Describe the role of shells in the UNIX environment
  • Describe the standard shells
  • Define the components of a shell script
  • Write a simple shell script

    Module 2: Writing and Debugging Scripts


  • Start a script with #!
  • Put comments in a script
  • Put commands in a script
  • Change permissions on the script
  • Execute a script
  • Debug a script

    Module 3: The Shell Environment


  • Use Bourne and Korn shell variables
  • Assign values to shell variables
  • Display the value of shell variables
  • Make variables available to subprocesses using export
  • Display the value of environment variables
  • Unset shell and environment variables
  • Customize the user environment using the .profile file
  • Perform arithmetic operations
  • Create and use aliases
  • Display aliases and the values assigned to them
  • Define the built-in aliases
  • Customize the Bourne and Korn shell environments
  • Use the tilde expansion and command substitution features of the Korn shell

    Module 4: Regular Expressions and grep


  • Use and describe regular expression
  • Describe the grep command
  • Use the grep command to find patterns in a file
  • Use the regular expression characters with the grep command

    Module 5: The sed Editor


  • Use sed to perform non-interactive editing tasks
  • Use regular expression characters with the sed command

    Module 6: The nawk Programming Language


  • Use nawk commands from the command line
  • Write simple nawk programs to generate data reports from text files
  • Write simple nawk programs to generate numeric and text reports from text files

    Module 7: Conditionals


  • Use the exit status of a command as conditional control
  • Use the if statement to test a condition
  • Pass values using command line arguments (positional parameters) into a script
  • Create USAGE messages
  • Use conditional constructs if, then, elif, else, and fi
  • Use exit, let, and test statements ( [[]] , (()) )
  • Apply Boolean logic
  • Use the case statement

    Module 8: Interactive Scripts


  • Use the print and echo commands to display text
  • Use the read command to interactively assign data to a shell variable
  • Read user input into one or more variables, using one read command
  • Use special characters, with print and echo to make the displayed text more user-friendly
  • Create a here document
  • Use file descriptors to read from and write to multiple files

    Module 9: Loops


  • Write scripts that use for, while and until loops
  • Write a script using the select statement
  • Describe when to use loops within a script
  • Generate argument lists using command, variable, and filename substitution

    Module 10: Advanced Variables, Parameters and Argument Lists


  • Declare strings, integers, and array variables
  • Manipulate string variables
  • Change the values of the positional parameters using the set command within a script
  • Use Korn shell arrays
  • Set default values for parameters
  • Use the Korn shell built-in statements let, print, set, and typeset

    Module 11: Functions


  • Create user-defined functions in a shell script
  • Create, invoke, and display functions from the command line
  • Pass arguments into a function
  • Call functions from special (function) files that are saved in one or more function directories
  • Describe where functions are available for use

    Module 12: Traps


  • Describe how the trap statement works
  • Include trap statements in a script
  • Use the trap statement to catch signals and handle errors

    Appendix A: The getopts Statement


  • Use getopts to process script options

    Appendix B: Advanced nawk Programming


  • Use nawk variables to change the way an input file is interpreted and the way the output data is displayed
  • Process the arguments from an nawk command line
  • Use nawk built-in functions and create new (user-defined) functions
  • Use nawk program statements to make decisions and perform looping

    Appendix C: Addintional grep Functionality




    Appendix D: Additional sed Functionality




    Appendix E: Shell Metacharacters for Pattern Matching for File Names




    Appendix F: Shell Comparison




    Appendix G: UNIX Commands and Utilities

    To contact a Sun Educational Services Representative: Address: UBRM12-175, 500 Eldorado Blvd., Broomfield, CO 80021, Phone: (800) 422-8020, (303) 464-4097 or fax (303) 464-4490.

    Note: information on this page has informational purposes only and is taken from the official web site of Sun Microsystems, Inc. See also the legal disclaimer