🐚

Introduction to Bash Scripting Basics

May 6, 2025

Bash Scripting Lecture Notes

Introduction

  • Bash scripting is essential for anyone looking to become a hacker, cloud engineer, or IT professional.
  • Learning bash scripting enables faster automation of tasks such as hacking networks or creating virtual machines (VMs).
  • Bash is a valuable skill for employability.

Episode 1 Overview

  • Introduction to bash scripting series.
  • Objective: From basic understanding to creating complex scripts.

What is Bash?

  • Bash stands for Bourne Again Shell.
  • Created as an improvement over the original shell from the 1970s, developed in 1989.
  • Bash is the command line in Linux; it interfaces with the Linux OS.
  • Functions as a powerful programming/scripting language.

Starting Bash Scripting

  • Linux Environment: Essential for practicing bash scripting.
    • Use Linode (cloud service) for quick Linux deployment.
    • Offers $100 credit for new users, costs about 1 penny per hour.
    • Can use WSL2 on Windows or existing Linux installations as alternatives.
  • Setting Up Linode: Create a Linux VM using Ubuntu 20.04.
    • Use SSH to connect.

First Bash Script: "Hi Mom"

  • Command Line Basics: Inside the bash shell.
    • Check current shell with which $SHELL.

Writing the Script

  • Use nano as a text editor: nano hi_mom.sh
  • Script Content: #!/bin/bash echo "Hi Mom"
  • Exiting Nano:
    • Ctrl + X, then Y to save, Enter to confirm the filename.

Running the Script

  • Execute Script: bash hi_mom.sh
  • Automating: Add sleep commands and more echo statements to simulate conversation.
    • Example:
    echo "Hi Mom" sleep 3 echo "Oh wow" sleep 3 echo "Can't believe that" echo "Bye, love you too"

Permissions and Executables

  • Run Scripts Without bash Prefix: ./hi_mom.sh
    • Initial attempt may fail due to permission denied error.
  • Change Permissions: Use chmod +x hi_mom.sh to make the script executable.
  • Verify Permissions: ls -l shows permissions.

Further Improvements

  • Running with New Permissions: ./hi_mom.sh should now run.

Conclusion

  • Bash scripts automate command line tasks.
  • Future series episodes will delve deeper into bash scripting.
  • Encourage engagement with YouTube channel (likes, comments, subscribes).

Additional Notes

  • Remember to delete the VM after usage to avoid charges.
  • Continual learning: next episodes will build on this foundation.