This course is 3 days long but for students without extensive command line experience, additional topics can be added to provide background. See the topics marked with Note, below.
Individuals requiring a mastery of the command line interface to the UNIX operating system. These individual are interested in automating common tasks, from processing log files or controlling boot time scripts to installing and deploying in-house applications. This includes system administrators, programmers, and power users.
Concepts
What is UNIX?
What is Linux?
Open Source vs. Free Software vs. Public Domain
Linux Components
A Historical Overview
Linux Features
Linux Programming Support
UNIX/Linux Basics Note
Accessing the System
Issuing Commands
Control Keys
Command Syntax
Online Documentation
Changing Your Password
Logging Out
Using Files and Directories Note
Characteristics of Linux Files
File System Hierarchy
Directories
Working With Directories
Listing Directory Contents
More Directory Listing Examples
Linux System Directories
Special Files
Manipulating Files
Managing Files
Permissions
Permission Examples
Permission-setting Shorthand
The umask
Command
Bash Shell Basics
Linux Components
I/O Redirection
Examples of Redirection
Using Pipes
Wildcards For Filenames
Command Substitution
Variable Substitution
Introducing Shell Scripts
Quoting To Prevent Interpretation
Examples of Quoting
Command Parsing Order
Special Shell Scripts
Process Management
Process Structure
Monitoring Running Processes
Process Creation
Shell Script Execution
Process Priorities
Modifying the NICE Bias
Background Processes and nohup
Killing Processes
Regular Expressions Note
Background
The grep
Command
Simple metacharacters
Advanced metacharacters
Extended metacharacters
The sed
Command
Greedy Matching in sed
An Example of awk
Data Tools, Part I Note
tee
The cat
Command
head
and tail
expand
and unexpand
cut
and paste
The find
Command
Bash Scripts: Background
Why Shell Programming?
Steps to Creating a Script
Menu Building -- Example Using select
Comments in Shell Scripts
Using Single-Value Variables
Working With Arrays
Parameter Expansion Modifiers
How to Correctly Display Error Messages
Performing Arithmetic (let
and (( ))
)
Using expr
For String Matching
Interactive Scripts (the read
Command)
Bash Scripts: Flow Control
The if
Command
Test Operations (test
, [ ]
, and [[ ]]
)
The while
Loop
The for
Loop
Changing the Script Parameters (set
)
Loop Control (break
and continue
)
The case
Command
Exiting a Shell Script
Menu Building -- Complete Example
Bash Scripts: User Interaction (as time permits)
Using getopts
For Handling Command Line Options
The trap
Command
Setting Runtime Options in the Bash Shell
Bash Scripts: Efficiency (as time permits)
Subshells and IO Redirection (( )
, { }
, and exec
)
Conditional Execution (&&
and ||
)
Temporary Files With mktemp
Floating Point Arithmetic
HERE Documents
Shell Functions
Appendix -- Using Bash Interactively
Bash Shell Background
Automatic Configuration
Command History
Command Prompt Customization
Command Line Editing
Other Set Options
Aliases (Command Macros)
Environment Variables
Example Startup Scripts
Appendix -- Data Tools, Part II
Using xargs
for Efficiency
Finding Differences -- diff
Side-by-Side Differences -- sdiff
Character Translation -- tr
Sorting Text Files -- sort
Relational Joins -- join
Note | Optional topic. Students with very strong command line experience may not need these topics. Contact us for details. |
Upon completion of this course, the student will be able to write Bash Shell scripts using the following features and more:
IO redirection, pipes, and command and variable substitution,
Passing parameters to shell scripts and interpreting their meaning,
Controlling the program flow using conditional logic and loops,
Catch and interpret Control-C and other asynchronous events, and
Apply debugging techniques to quickly locate coding errors.
Shell scripting is equal parts of running commands and processing the results generated by those commands. In it's normal configuration, this course covers the most important of the text processing commands that are frequently used in efficient shell scripts, and mixes in the built-in control functions of the shell to make them fast and effective. Each chapter includes discussion of when to use each feature, so that students gain an understanding of what works best in a particular situation. Best practices are described throughout the course with rules of thumb in each chapter. (Removing the optional topics may be feasible for very experienced students, but is not recommended.)
Students are invited to bring their current ideas and questions to the classroom for discussion. Case studies, lecture, group problem solving, and online laboratories will be used. Students will be encouraged to enhance their skills utilizing the techniques presented through classroom problem solving and controlled online workshops.
Completion of an Introduction to UNIX/Linux or similar course, and six months of command line experience on a UNIX/UNIX-like operating system. See below for a quick quiz to determine if you're ready for this fast-paced course.
Programming skills are not required, but are helpful.
Are you ready for this course? If you can't immediately answer the following questions (no more than ten seconds of time to think about each answer!), then you should consider taking an Introduction to UNIX/Linux course first and practicing your command line skills prior to attending this course.
The ls
command normally displays the contents of the directory provided on the command line. What option turns OFF the display of a directory's contents? (For example, if the -l
option was included, the output would consist of one line of data with a "d
" in column zero.)
The cat
command is normally used to display the contents of a file, but it can also add line numbers to the output, display tabs as ^I
characters, add end-of-line markers, and other functions. Name at least two valid option letters to the cat
command and describe what they do.
The tail
command is a staple of the UNIX environment. It can be executed with the -n
option followed by a positive or negative number. What do these numbers represent and what is the difference between using a plus sign prefix and a minus sign prefix on the number?
Describe what the following command does in 25 words or less (for this one you're allowed more than ten seconds!). You're allowed to guess at what data is being extracted from the ps
output:
ps -eaf | cut -c56- | tail -n +2 | sort -u
Which of these command groups, if any, produce errors or meaningless results (you get ten seconds per command group):
ps -eaf | sort -k 1.56
ls -l /var/spool/at > /tmp/frank | wc -l
echo "%r" > format
date +$(cat format)
echo "+%r" > format
var=$(date $(cat format))
If you didn't get at least three of the above questions correct immediately, you're probably not ready for this course.
The answers are:
-d
and --directory
cause the information in the directory inode itself to be displayed, not the inodes contained within the directory.
-n
, -t
, -e
, and -v
are valid options (among others). These options add line numbers, display tabs as ^I
characters, display end-on-line as $
characters, and cause other normally invisible characters to be printed (such as formfeed being printed as ^L
), respectively.
Number of lines. A positive number starts printing at a position that is counted forward from the beginning of the file and a negative number starts printing at a position that is counted backwards from the end of the file.
Creates an alphabetical list of command lines running on the system (removing duplicates). This assumes that ps -f
prints the command line beginning in column 56.
A, C, and D are fine. B has the problem (it produces an error in some versions of the shell and prints 0
in other versions).