Back to DevOps Series
B.) BASH  (Bourne Again SHell):

B.) BASH (Bourne Again SHell):

notion image

1. What is Bash?

Bash = Bourne Again SHell
It is like the upgraded version of sh — faster, smarter, and filled with modern features.
Think of it like this:
  • sh = Old Nokia phone
  • bash = Modern Android phone
    • (more features, smoother to use)
Bash is the default shell on most Linux systems.

2. Why is Bash so popular?

Because it gives you:
  • Auto-complete (press TAB)
  • Command history (press ↑)
  • Colourful prompt
  • Arrays
  • Functions
  • Better scripting features
  • Easier for daily use
  • Works everywhere (almost)
This is why most Linux users use bash daily.

3. Where is Bash located?

Usually at: /bin/bash
Many scripts start with:
#!/bin/bash
→ This means “Run this using the Bash shell.”

5. Your First Bash Script

Create a file: hello.sh
#!/bin/bash
echo "Hello from bash!"
Run it:
chmod +x hello.sh
./hello.sh
Output:
Hello from bash!

7. Bash Prompt (PS1) — Why You See Colored Text

The colorful part of your terminal
atul@host:~/folder$
is controlled by bash.
It shows:
  • your username
  • your computer name
  • your current folder
You can even customize the color.

8. When should YOU use Bash?

  • For daily terminal usage
Easiest and most comfortable.
  • For writing scripts with loops, arrays, logic
More powerful than sh.
  • For DevOps, automation, servers, tools

9. Story to Remember Bash Forever

Story to Remember Bash (Short):
If sh is the grandfather, then Bash is the smart grandson — fast, modern, remembers everything, and helps you quickly while still respecting sh.
👉 Bash = sh + superpowers. That’s why everyone uses it today.
 
 

 

Home work (Must go though these Features) For getting a basic Idea :

6. Bash Features You Will Actually Use :

Here are only the most useful features — explained simply.

1. Variables

name="Atul"
echo $name

2. Arrays (sh cannot do this)

fruits=("apple" "mango" "banana")
echo ${fruits[1]}   # mango

3. If condition

if [ $name = "Atul" ]; then
  echo "Hi Atul"
else
  echo "Not Atul"
fi

4. For loop

for i in 1 2 3; do
  echo $i
done

5. Command history

Press:
↑ arrow key
to see old commands.

6. Auto-completion

Type:
cd Doc
Now press TAB → becomes:
cd Documents/