
Explore the purpose of shell scripting, including the shebang, creating a script file, logging, and automating tasks with cron or anacron, plus an exercise on memory swap and disk utilization.
Learn to chain multiple commands in a single line versus running them from a script file. See why script files matter in production environments with practical terminal examples like pwd, who am I, date, and ls.
Create and run a bash script by writing a first_script.sh with a shebang line, comments, and echoes; save, chmod +x, and execute with ./first_script.sh.
Create a script that collects memory, swap, and disk utilization using free -h, grep, and df -h, and appends formatted results to a performance log with inline comments.
Build a bash script to monitor ram, swap, and disk usage, appending results to a performance log file with comments and clear formatting.
Learn how bash scripts stack commands in a single file to automate tasks and run on schedules with cron expressions, using the shebang line and hash comments.
Explore variables in bash by assigning values, referencing with a dollar sign, and using parameter expansion to access environment and user variables like hostname, user, home, uid, and path.
Create a bash script leveraging environment variables to display hostname, current user, UID, and home directory. Learn nano editing, shebang, echo commands, and making the script executable.
Create and reference user variables in Bash to temporarily store data and reference it with dollar expansion; contrast with environment variables and follow no-space assignments using lowercase names.
Master command substitution in bash by assigning a command's output to a variable using backticks or $(...), and illustrate parameter expansion with date and file listings.
Write a shell script using command substitution to list all files and folders in /usr/bin, including hidden ones, and save the long output to log.$today with an mdt suffix.
Create a bash script that uses command substitution to assign today’s date, lists all files (including hidden) in /usr/bin, and redirects the output to a dated log file.
Learn arithmetic expansion in shell scripting, using $((...)) or $[...] to perform integer calculations like addition, subtraction, multiplication, and division with whole numbers, including operator precedence and variable usage.
Explore arithmetic expansion in bash scripts by declaring variables, performing integer calculations with parentheses, and outputting results with echo, noting integer-only results and the upcoming bash calculator for decimals.
Explore the batch calculator as a floating point solution to decimal calculations, using scale to control precision and bc to run expressions in scripts via command substitution.
Use the bash calculator (bc) via command substitution, assign output to variables, and echo expressions to bc with scale for precise decimals in scripts. Two scripts demonstrate the approach.
Calculate the number of days between January 1 and May 1, 2023 in bash using epoch time, converting seconds since 1970 to days with a shell script.
Learn how positional parameters pass command line arguments to bash scripts, access them with $1, $2, and beyond, and perform arithmetic using parameter expansion.
Learn how to handle many command-line arguments in Bash by accessing the 10th and 11th parameters with braces like ${10} and ${11}, performing a product, and printing results.
Learn to use special parameters in Bash, including $0 to reveal the script name, $# to count arguments, and ${!#} to display the last parameter, with hands-on terminal examples.
Learn how to grab all command parameters with $@ and $*, compare word splitting, preserve whitespace by quoting with double quotes, and create files via scripts.
Explore how the bash read command prompts users with -p, stores input in variables, supports multiple variables, and reads from standard input or files through practical scripting examples.
Learn to use the bash read command to collect user input, apply a timeout with the -t option, hide input with -s, and show prompts with -p in scripts.
Learn how the split command in Linux creates a numbered menu, assigns the chosen option to a variable, and uses a data list with do and done to drive selection.
Master chaining commands on a single line using list operators such as semicolon, and, or, including the ternary operator to control sequential and conditional execution based on exit status.
Chain commands with semicolons, echo hello world, list directories with ls, and use the logical and and or operators while tracking exit statuses.
Master integer comparisons in bash with the test command, learning exit status zero for true and one for false, using square brackets and list operators to chain tests.
Learn to compare strings with the test command in Bash, using -n and -z for length, and = or != for equality, noting case sensitivity.
Learn to test existing files and directories on Linux using the test command with options E, F, D, R, W, X, and S, and interpret exit status 0 or 1.
Explore the bash if-then statement: its syntax, exit status logic (zero means true), then fi blocks, and practical examples using test expressions and echo.
Learn to use an if statement with grep to check for a user in /etc/passwd, and if found, display messages and list the user's home and desktop directory contents.
Explore how the bash if-then-else structure evaluates commands, using zero exit status for then and non-zero for else. Learn to implement else blocks with practical examples and error handling.
Edit a script to add an else block that handles non-existent users by using grep to test for a username, executing then commands on success and else commands on failure.
Build a script that compares three files using an if-then-else statement to check if their contents match. If they match, remove two files; otherwise, preserve all three.
Discover how the if-elif-else construct evaluates multiple conditions using test expressions that return zero for true. It executes the corresponding code blocks or an else fallback when none are true.
Create a bash script that prompts for a guest name with read, uses if/elif/else to match Steve, Kunal, Chris, or Mahesh, and echoes tailored welcome or error messages.
Master how case statements streamline bash scripts by matching multiple values of a single variable with patterns separated by the bar operator, plus asterisk catch-all and esac.
Verify a file's type by extension with a bash script. Read a file name, extract the extension, and classify as image or text using a case statement.
Explore bash while loops by testing a condition and executing commands as long as the test returns a zero exit status, printing 1 to 10 and 10 to 1.
Master getopts to define options and arguments in bash scripts using an opt string and colon, then handle input with a while loop, case statement, and use optarg for arguments.
Create a getopts-based script handling options a, b, and c with required arguments, stored in option and processed by a case statement.
Learn how read while loops use the read command as the test to read a file line by line and execute code for each line between do and done.
Master bash arrays to store multiple values, access elements and indices, add or remove elements, and modify array contents, using numeric or alphanumeric data.
Learn how the readarray command converts standard input into an array, turning each line of a text file into an element; use -t to suppress trailing newlines.
Master for loops in bash by iterating over array elements and executing a command for each item. Demonstrate how a script declares an array and echoes every element.
Demonstrates creating 100 files, brace expansion, reading them into an array with readarray, and iterating with a for loop and retry logic, including a file existence check.
Explore automating script execution on predefined schedules with at command, cron, and anacron. Learn to use at -f, -m, and atq, and understand the at daemon managing the job queue.
Learn to use the at command to schedule scripts, suppress emails with -m, specify files with -f, and set run times from now to specific dates; manage jobs by IDs.
Master cron scheduling to run scripts regularly, using cron tables to define minutes, hours, day of month, month, and day of week with crontab.
Create and schedule a basic bash script with a shebang, using cron tab to run every minute, echoing a line to schedule.txt and appending each execution.
Explore the existing cron directories—hourly, daily, weekly, and monthly—and place scripts to run at predefined frequencies via the crontab schedule.
Master cron expressions to schedule scripts and test timings on cron websites like crontab.guru. See examples such as every minute and 4:15 a.m. on the first day of the month.
Explore how Anacron overcomes cron's missed-run limitation by executing pending jobs after reboot, using its own schedule table with period, delay, identifier, and command for weekly tasks.
Compare at, cron, and anacron scheduling mechanisms to decide when to run scripts: at runs once, cron runs regular jobs, and anacron handles missed tasks after startup.
Sign up for an AWS free tier account to deploy and access a remote Linux server, verify your email and payment details, and test commands after signup.
Discover how EC2 provides a resizable compute capacity in the AWS cloud via instances and instance types, with AMIs for OS and security groups for SSH access.
Launch and configure an Ubuntu EC2 instance in AWS, selecting a free-tier t2.micro, Ubuntu 22.04 AMI, and a key pair, with security groups enabling SSH, HTTP, and HTTPS from anywhere.
Connect to an ubuntu EC2 instance via SSH using a PEM key, set permissions with chmod 400, and authenticate as ubuntu@public IPv4 address to run updates.
Learn to securely copy files between a local desktop and a remote server using scp, including authenticating with a key, specifying source and destination paths, and performing reverse transfers.
Terminate the instance to remove an unused server from your dashboard, a best practice to avoid lingering costs, knowing this action cannot be undone. Sign out after termination.
Welcome to "Bash Mastery: Scripting Your Way to Command-Line Excellence" — your gateway to mastering the art of automating tasks and streamlining your workflow with Bash scripting! Whether you're a seasoned developer or just getting started in the world of programming, this comprehensive video course is designed to equip you with the skills needed to harness the full potential of the Bash shell.
In this course, we will embark on a journey through the fundamentals of Bash scripting, guiding you step by step from the basics to advanced concepts. You'll learn how to write efficient and effective scripts to automate repetitive tasks, manage files and directories, manipulate data, and even interact with external programs. Each lesson is crafted to provide hands-on experience, ensuring that you not only understand the theory but also gain practical proficiency in Bash scripting.
Here's what you can expect to explore:
1. Introduction to Bash: Familiarize yourself with the Bash environment, understand basic commands, and navigate the shell with ease.
2. Scripting Fundamentals: Dive into the core concepts of scripting, including variables, conditionals, loops, and functions. Build a solid foundation for creating robust Bash scripts.
3. Automation and Task Scheduling: Explore the art of automation by creating scripts that handle routine tasks and schedule them for seamless execution.
4. Error Handling and Debugging: Master the techniques of error handling and debugging to create resilient scripts that stand up to real-world challenges.
5. Advanced Topics: Delve into advanced Bash scripting concepts, including arrays, readarray, getopts, while loops, read-while loops and for loops.
By the end of this course, you'll not only be proficient in Bash scripting but will also have the confidence to apply your newfound skills in real-world scenarios. So, let's embark on this journey together and unlock the full potential of Bash scripting! Get ready to become a Bash master!