Prerequisites: basic linux and network knowledge
Duration: 4 days

(Note: original course name: Linux bash usage and scripting in server and network environment, v1.0)

Audience: users who want to upgrade their knowledge in linux bash usage and scripting using standard tools to perform automation of everyday tasks  in server and/or networking environment. We noticed that although users often work in linux environment, they do not have adequate knowledge to fully use and understand bash possibilities and to create own scripts to automate tasks.

Description:
Solid linux usage knowledge became more and more important today. We can run containers, virtual machines, interact with kubernetes or Openstack, use ssh for connection to hosts/routers/fireewalls with some interaction or just run some bussines application. Many of tasks are often initiated from command line in bash and in many cases one task can provide input to other task, e.g running command on router via ssh and local processing of output to gain some info as input to next task. Many of tasks can be automated by creating bash scripts and in those bash scripts we often use standard line processing tools like sed, awk etc. Also we may need to pass procedure like waiting for some prompt to enter information like user authentication ( e.g. router connection), application interaction etc. This can be also automated using other tools like expect.

Bash scripting is right and quick approach when we have ready command line tools that we need to “glue” with moderate internal script logic and script size. For more complex programs python or perl programming can be better but for simple scripts bash scripting is sufficient and often used.

This course/workshop is theoretical+practical approach to linux bash usage and scripting.

 

Course outline:

Introduction

Interactive use, bash scripts, sourcing

Linux concepts related to bash

Linux – program, arguments, exit code, environment
Program invocation and arguments from bash
Program exit code
Environment
How programs-processes are started from other processes
Stdin, stdout, stderr and redirection basics
Bash pipe and underlying implementation

Bash expansions

Filename expansion
Tilde expansion
Brace expansion
Variables-parameters expansion

Variables-content or variable manipulation
Script or function arguments
Environment variables
Echo
Printf
Read
Test
If
Inline if – running command if previous command fails or succeeds
Inverting exit status
Command substitution, seq, expr
Arithmetic Expansion and evaluation
For
While
Case
Debugging
Redirections
Grouping and subshell
Combination of pipes, subshell or grouping and redirect
File descriptors creating, duplicating, closing
Process substitution
Arrays
Functions

Local variables

Signals, trap
Exiting on error
Pipefail
Detailed processing of exit and error events
Getopts
Alias
Noop
Running bash commands over ssh
Bash startup files
Tools – file content

Tool – cat
Tool – tail
Tool – head
Tool – wc
Tool – tee
Tool – cut

Tools – general

Tool – find
Tool – xargs

Tools – file processing and regex

Tool- grep
Tool- sed
Tool- awk
Tool- sort

Tools – expect

Labs:  Beside elementary labs like e.g. how to execute command and analyze output, number of more examples like e.g: determine live stations in subnet using ping and analyzing arp table, creating menus with command executions (” for e.g. login restricted access”), automated login to the router analyzing response and sending commands,etc. Idea is that participant should be able to create own scripts at the end of the course so lot of time will be dedicated to participants to create scrtipts and to comment problems or alternatives.