Day 5
Session Summary β Functions, System Scripts & Git Basics Timeline
00:00 β 01:02 | Previous Session Recap
-
Trainer checks practice of shell scripting commands
-
Importance of practicing fundamentals
-
Reminder about loops covered earlier
Functions in Shell Scripting
01:02 β 02:46 | Introduction to Functions
-
Script execution line by line
-
Need for functions in large scripts
-
Example: backup and push to S3
02:46 β 05:41 | DRY Principle (Do Not Repeat Yourself)
-
Avoid repeating the same logic
-
Encapsulating features into functions
-
Calling functions when needed
05:41 β 07:53 | Creating and Calling a Function
-
Function syntax in shell script
-
Passing arguments to functions
-
Example: greeting script
07:53 β 09:37 | Function Arguments and Multiple Calls
-
Using
$1for first argument -
Calling function multiple times
-
Dynamic output with different inputs
09:37 β 11:31 | Return Codes in Shell Scripts
-
return 0for success -
return 1for failure -
Checking command status using
$?
Arrays and Looping Concepts
11:31 β 14:41 | Arrays in Shell Script
-
Defining arrays
-
Accessing elements with index
-
Printing specific elements
14:41 β 16:17 | Looping Through Array Elements
-
Iterating through array
-
Printing each element sequentially
-
Counting total elements
Positional Arguments
16:17 β 20:02 | Script Arguments Explained
-
$0as script name -
$1,$2as input arguments -
Example of passing values to script
20:02 β 24:36 | Real-World Use Case of Arguments
-
Multiple AWS accounts scenario
-
One script handling different accounts
-
Using arguments to make scripts dynamic
Exit Codes & Debugging
24:36 β 25:59 | Common Exit Codes
-
0= success -
1= general error -
Importance of handling exit status
25:59 β 26:22 | Script Debugging
-
Enabling debug mode:
-
set -x
-
-
Disabling debug:
-
set +x
-
-
Use case in large scripts
Practical Shell Script Examples
26:22 β 28:20 | System Report Script Overview
-
Script for system health reporting
-
Automation using cron
-
Sending reports via email
28:20 β 29:27 | Date and Uptime Commands
-
Using
datecommand -
Using
uptimefor system running time
29:27 β 31:14 | Memory Monitoring with free and awk
-
Using
free -h -
Extracting values with
awk -
Text processing concept
31:14 β 34:23 | Disk Usage with df and awk
-
Using
df -h -
Selecting specific rows and columns
-
Understanding
NRinawk
34:23 β 36:12 | Process Monitoring Script
-
Using
ps aux -
Sorting by memory usage
-
Showing top processes
Automation Script Examples
36:12 β 37:31 | Backup Automation Script
-
Checking directory existence
-
Creating directory if missing
-
Compressing files using
tar
37:31 β 40:10 | User Management Automation Script
-
Creating multiple users from file
-
Checking root privileges
-
Skipping existing users
-
Setting passwords automatically
Transition to Git
40:10 β 41:53 | Linux Topics Completed & Git Introduction
-
Completion of basic Linux and scripting topics
-
Transition to Git module
-
Question about Git familiarity
Git Fundamentals
41:53 β 44:27 | What is Git and Why Itβs Needed
-
Collaboration between developers
-
Tracking changes in files
-
Identifying who made changes
44:27 β 46:20 | Git Workflow Overview
-
Working directory
-
Staging area
-
Local repository
-
Remote repository (intro)
46:20 β 48:49 | Initializing a Git Repository
-
git init -
Creating files
-
Checking status with
git status
48:49 β 49:44 | Staging and Committing Changes
-
git add -
git commit -m -
Moving changes to local repository
49:44 β 52:21 | Tracking Changes and Commit History
-
Modifying files
-
Viewing status
-
Using
git logto see commit history
Session Wrap-Up
52:21 β End | Next Steps & Practice Instructions
-
More Git topics in next session:
-
Remote repos
-
Push, pull, checkout
-
Branching
-
Rebase and merge
-
GitHub Actions (CI/CD)
-
-
Practice shell scripting and
awk -
Session closing