
Engage in a practical, lab‑driven introduction to bash shell scripting, from basics to automation, with theory, lab sessions, and industry projects.
Explore how the Linux shell serves as the interface between users and the kernel, gathers input from you, translates human readable commands into kernel readable instructions, and executes programs.
Discover how Linux shells act as interpreters, with bash as default and others like C-shell, Korn shell, and tcsh, accessible via SSH or terminal for commands like date and pwd.
Learn how shell scripting automates tasks by executing command sequences, enabling pre-validation, monitoring, backups, and efficient administration across multiple servers.
Introduce the bash shell, the Bourne again shell, as the default Linux shell and free Unix interpreter, noting its compatibility with Korn and C shells.
Learn how user home directories under /home are configured and managed by /etc/profile and per-user files like .bash_profile, .bashrc, and .bash_logout for login and interactive shells.
Create a normal user, log in, and verify the bash shell and login session; explore the home directory and the role of /etc/profile, /etc/bashrc, .bash_profile, and .bashrc in login order.
Compare .bash_profile and .bashrc to show how login shells versus interactive non-login shells execute different startup files and display user-specific versus global messages.
Learn to create a simple shell script using vi, add a shebang, test in a dry run, and grant executable permissions before deploying to production.
Master bash script debugging using debug mode (-x), set -x and +x, and syntax checks with set -n, while learning to run commands like date and uptime.
Learn how to define and read bash variables, including environment and system variables, assign values, perform arithmetic, and understand their local scope to a shell.
Explore environmental variables as values inherited by child shells, how to export them with export VAR=value, and how they differ from local variables in shell scripts.
Understand how Linux bash shell creates system variables, distinguish environmental and local variables, and view them with set and env commands, including prompts (PS1) and hist file settings.
Practice creating and manipulating shell variables, access with $var, and unset to clear before redefining. Use := to set a default when a variable is empty.
Create a simple Bash script using only echo commands to gather system information, including disk space, memory, uptime, load, and logged-in users, with proper variable rules and permissions.
Learn how quoting in bash controls variable expansion and special characters, including when to use double or single quotes to manage variables, wildcards, and command substitution.
Master escaping with the backslash in bash, decide between single and double quotes, and use echo -e to print literal characters, spaces, and tabs.
Learn to read user input from the keyboard using the read command in bash, assign it to variables, and use it in simple scripts that sum numbers and display prompts.
Explore the read command in bash with options like -t for timeout and -p for prompts, and practice secure input with -s to hide passwords in scripts scr3.sh and scr4.sh.
Explore how IFS, the internal field separator, splits a variable into sub variables and how the read command assigns city1, city2, and city3 from a list.
Master bash arithmetic using the built-in option and bc, applying the $(( expression )) syntax to add, subtract, multiply, divide, and use ++/-- in scripts.
Learn how to create and enforce integer variables in bash, using declare -i to assign numbers, and understanding how non-numeric input converts to zero.
Define constant variables in bash scripts using read only or declare -r to lock values such as ABC and DEF, ensuring they cannot be changed or deleted within the shell.
Explore path name expansion in bash using curly braces to generate sequences such as file1.txt to file10.txt. Practice in the lab to apply these concepts.
Master wildcards in bash by learning how the asterisk matches any string and the question mark matches a character. Use patterns to match .conf and .txt files, starting with r.
Learn to create and use aliases to shorten commands, view defined aliases, and set them permanently via bash profile or bashrc. Also learn how to remove or ignore aliases.
Learn to create a bash script that fetches network details, user information, load, memory, uptime, routing table, and DNS data from multiple servers, centralized on one server, with cron automation.
Learn to colorize bash script output using echo -e and escape sequences. Apply foreground and background color codes, reset with the closing sequence, and create clearer, readable scripts.
Join a lab on bash colors using echo -e to interpret escapes, applying foreground codes like 31 red, 32 green, 34 blue, and background 41 and 42, and underline 4m.
Create a bash automation script that prints system information, checks internet connectivity with ping and timeout, and colorizes output using escape sequences while capturing the operating system and server type.
Create a bash script that detects linux distribution with uname -s and release files like RedHat, CentOS, SuSE, Mandrake, and Debian, printing the result in color.
Edit and execute a bash automation script to display architecture, internal ip addresses, dns details, and server information using commands like uname, hostname, cat, and awk; plan centralized fetch.
Automate cross-server reporting by deploying a script on each server and a central fetch script that uses cron and scp to collect hostname-reports.txt into a centralized reports directory.
Explore conditional execution in bash: use the if command to test conditions, implement if/else and elif branches, and create practical scripts that respond to file existence or Sunday backups.
Learn how to write if-else logic in bash by evaluating boolean conditions, comparing numbers, and testing files with practical scripts that show true or false outcomes.
Practice bash scripting with if else. Learn to verify a password with silent input -s and use elif for odd, even, or zero checks.
Write a shell script that reads a number and uses if, elif, else with the modulus operator to classify it as zero, even, or odd. Practice conditional logic in bash.
Create a bash script that uses the test command for conditional execution, prompting for 100 and validating it. Show if and else handling and prepare for elif and more conditions.
Practice using the Bash test command with multiple conditions to validate age and assign eligibility and age groups, including under 20, 21–29, 30–39, and 40–49, using || and &&.
Learn how to check a command’s exit status in Linux, where zero means success and non-zero signals failure; use the $? variable to print it in shell scripts.
Explore a bash practice lab that uses exit status to verify file creation with touch, handles permission errors between root and normal users, and demonstrates error suppression through redirection.
Demonstrates a Bash script that prompts for a username, searches /etc/passwd with grep, and uses exit status to report if the user exists. Includes two methods to test status.
learn numeric and string comparisons in bash scripting using test conditions and operators such as -eq, -ge, -gt, -le, -lt, -ne and -z, with practical examples and if-elif-else flow.
Learn attributes comparison to check file or directory existence. Use attributes like -b, -c, -d, and -e to identify blocks, characters, and directories.
Explore how shell command line arguments pass variables to commands and scripts, learn about positional parameters like $0, $1, $2, and $# with practical examples.
Learn to handle command line arguments with positional parameters like $1, $2, and $9, use $# $@ and $* to print inputs, and adapt output with IFS.
Explore bash loops and the for loop, enabling you to execute commands repeatedly and read server lists, with a c-like syntax and practical file-based automation.
Explore practical for loop techniques in bash by iterating over a list of days and numbers, printing each value with echo, setting variables, and enabling execution with chmod +x.
Explore how a bash for loop iterates over a list of weekdays, using a counter i and echo to print each day with its index.
Master for loops in bash with c-like syntax, using initialization, condition, and updation; observe how double quotes affect variables and how echo prints i from 1 to 10.
Learn how to use a for loop to read a list of servers from a host file and SSH into each to check the SSH version, enabling passwordless automation.
Learn to write a bash for loop using command-line arguments and $#, $*, to check file existence with -f, report found or missing, and cat contents when present.
Create a bash chessboard using nested for loops and checks whether i + j is even or odd to print an 8x8 black and white board.
Master the while loop to execute commands repeatedly under a condition, and learn to read files line by line using IFS and read, including field separation and multiple fields.
Practice bash scripting with a while loop that counts from 1 to 10 and reads a text file line by line using IFS, read -r, and echo.
This lecture covers the infinite while loop in bash, an endlessly running loop until you press control c, using colon or true for the condition in menu-driven tools.
Explore how the bash case statement simplifies multi-level if-else logic by matching multiple patterns to a single variable, enabling a menu-driven automation tool with an infinite loop.
Create a menu driven bash automation tool using a case statement within an infinite while loop to run pre validation, ad hoc commands, and top 10 processes.
Design a menu driven automation tool using a case statement to orchestrate scripts from a central server via a host file, with pre validation and ad hoc commands.
Learn how to redirect output to a file or program in linux by understanding stdin, stdout, and stderr, and the file descriptors 0, 1, and 2.
Explore redirection of output using file descriptors in a practical lab session, directing standard output and standard error to files, with overwrite, append, and combined outputs.
Learn how pipelines connect commands with the pipe character, passing output as input between commands such as ls, less, wc -l, head, and tail, with redirect and tee.
Learn how to use the tee command in pipelines to capture command output in a file while feeding input to the next command, such as less.
Learn to assign user defined file descriptors in Bash using exec to redirect input and output by mapping fds (3 and up) to files, including creating and closing them.
Learn to create file descriptors for output and input in Linux bash, using numbers like 7 and 9 with redirections such as >&7 and <&9, including user defined descriptors.
Discover how a single file descriptor can handle both reading and writing in bash by creating fd 12 with exec. Use >&12 to write and read from it.
Explore how Linux creates and manages processes, assigns PIDs, and uses ps -a, ps -e, and ps -o to view process information such as PID, PPID, UID, and CPU usage.
Explore process management by distinguishing foreground and background processes; run foreground commands with keyboard input and learn to start background jobs with & or cron for multitasking.
Explore various process stats in Linux, including running, interruptible and uninterruptible sleeping, stopped, defunct, and zombie states, and examine disk I/O and paging between memory and swap.
Master process management with the ps command to view process ids and terminal types (tty and pts), adjust priorities using ps -ef, grep, vim, and renice.
Master linux process management with ps -ef, examine pid, ppid, cpu, and start time from tty or pts, and note that a question mark in tty signals no terminal.
Demonstrate foreground and background processes by building a while loop, tailing output, and using jobs, fg, bg, and control signals such as control c and control z to manage processes.
Define and use functions in Linux Bash shell scripting to modularize large scripts and avoid repetitive code, with examples like hello and is_user_root and arguments with $1.
Display defined functions with declare -f, view their source code, and learn to create, unset -f, and call functions in bash scripts.
Explore nested functions in bash by defining two functions and calling one from within the other, producing outputs like this is my first function and this is my second function.
Lab session demonstrates writing a bash function identify to determine if an argument is a file, directory, or symbolic link using -f, -d, -L, with argument checks.
Learn the difference between local and global variables in shell scripting, with examples showing how A, B, and C behave inside and outside functions.
Learn how the bash return command exits a function and provides a return value, contrast it with exit, and use echo $? to read the function's outcome.
Define and call a function named my_head in a menu-driven bash script to display an automated tasks message in red, so each run triggers the function.
Learn awk, a scripting language for pattern scanning and processing text, to manipulate fields and generate formatted reports, with practical labs on cutting columns, printing last fields, and using nf.
Explore practical awk pattern matching to search lines by word or multiple words, limit searches to specific columns, and perform numeric comparisons in the first column.
Use awk with a BEGIN block to print headers, then display fields $1 through $5, and insert tab characters \t to align columns, producing a formatted report.
Master awk postprocessing in linux shell scripting by printing file contents with print $0, prepending text with begin and appending a report with end, and using a test variable.
Learning is important but most important is how to explore it. This course is designed in such a way that you can learn as well as explore the entire course module with various industrial projects.
Practical approach to learn and explore the shell scripting with various industrial projects
Course Content
Introduction of Shell Programming
What is Bash Shell?
Types of Shell available in Linux
About Shell Scripting
Bash Shell Startup Scripts
User’s Home Directory - .bash_profile, .bashrc & .bash_logout
Shebang
Create a simple Shell Script
Setting up permissions on a script
Debug a Script
The Shell Variables & Environment
Bash Variables
Environmental Variables
System Variables
Assign values to shell variables
Customize the bash shell environments
set, env & export command
Rules for naming variable name
Simple Script using echo command
Quoting
There are three Type of quoting
The double quote (")
The single quote (')
The Backslash (\)
User's Input via Keyboard
Read Command
IFS
Practice Lab Session
Arithmetic Operations
Performing Arithmetic Operations
Create an integer Variable
Create the Constants Variable
Path name expansion
Wildcards [*], ?, [..] etc
Create & use aliases
Practice Lab Sessions
Industrial Project to Completely Automate the Pre-validation report
A Shell Script to collect required information from a server
The Bash Color
Writing Color Text
Various Color Codes for Foreground & Background Text
Lab Session on Bash Color
Script to fetch the system information i.e system_details
Schedule the script via cron
Final Script to fetch the environment report on a single click
Lab Session
Conditional Statements (Decision Making)
Overview of conditional execution
What is Condition?
Boolean value (True & False)
If else statement
Lab Session on if..else..
if..elif..else..fi statement
test command
Logical AND &&
Logical OR !!
The exit status of a command
Numeric Comparison
String Comparison
File Attributes Comparison
Shell Command line parameters
Positional parameters via special shell variable $1, $2, $3,...,$N.
Practice Lab Session
Bash Loops
Overview of loop statement
for loop statement
Lab on for loop
for loop using C like Syntax
for loop using command line arguments
Nested for loop statement
Chessboard using nested loop statement
While loop statement
Lab Session - read a text file line-by-line or using IFS
infinite while loop
case statement
Lab session on case statement
Create a simple menu driven program or automation tool Using Case Statement
Industrial Project
Discussed various scripts using for or while loop
Shell Redirection & Process Management
Input Output Redirection in Linux
Lab Session on redirection
Pipelines in Linux
tee command
file descriptor (fd) to file for output
file descriptor (fd) to file for input
file descriptor (fd) for reading & writing
Practice Lab Session
Overview of a Process
Foreground & background Process
Various Stats of a process
Lab Session
Functions
Defining functions
Displaying functions
Nested functions
Lab Session - writing functions
Calling functions
Local & global variables
Passing arguments into a function
return statement
Practice Lab Sessions
AWK
Introduction Awk
Pattern matching
User defined variables in awk
Awk pre-processing
Awk post-processing
Practice Lab Session
SED Stream Editor
Introduction
Replacing or substituting string.
Replacing the nth occurrence of a pattern in a line
Replacing all the occurrence of the pattern in a line
Changing the slash (/) delimiter
Using & as the matched string
Duplicating the replaced line with /p flag
Replacing string on a specific line number
Replacing string on a range of lines
Replace on a lines which matches a pattern
Deleting lines
Add a line after a match
Add a line before a match
Last Lecture