Back to DevOps Series
A. ) Bourne Shell (sh)

A. ) Bourne Shell (sh)

1. What is the Bourne Shell (sh)?

Think of sh as the oldest grandfather of all shells in Linux/Unix.
  • It is very simple , stable , available on almost every Unix system
  • It is recommended for scripting because it works everywhere
So imagine a very old Nokia phone not fancy, but never fails. That’s sh.
It doesn’t have fancy features, no colours, no autosuggestions — just works.

2. Why do we still use sh today?

Because:
  • Every system understands sh
No matter whether you use Ubuntu, macOS, or a server from 1990 sh will run.
  • Perfect for scripts
Many system scripts start with:
Loading...
This tells the OS:
➡ “Run this script using the simple, standard shell.”

✔ Most portable

Other shells (bash, zsh, fish) have extra features.
But sh scripts run everywhere.

3. Where is sh located?

Most commonly→ /bin/sh.
This file points to the shell program.
 

4. How does sh behave?

sh is basic:

  • No auto-completion, coloured fancy prompts , shortcuts.
  • Very small set of features :
    • Command execution
    • Variable assignment
    • Command substitution
    • Input / output redirection
    • Pipes
    • Conditional statements (if, else)
    • Loops (for, while) etc.
It is mainly meant for running scripts, not for interactive use.

5. How to write your first sh script

Let’s write a very simple script:

hello.sh

Loading...

Steps to run:

1️⃣ Make file executable
Loading...
2️⃣ Run it
Loading...
✔ Output:
Loading...

6. When should YOU use sh?

Use sh when:
✔ You're writing a script that should run on ANY machine
✔ You want maximum compatibility
✔ You don’t need advanced features like arrays, functions with names, etc.
Don’t use it for daily terminal usage bash/zsh is better for daily work.

  • To Keep in Mind:
    • Imagine sh is the grandfather of all shells — simple, slow, stable, and respected by every OS.
      When you use #!/bin/sh, you’re basically saying:
      👉 “Grandpa, handle this. You never fail.”
 

 

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

What can sh do? (Basic commands you should know)

1. Print something

Loading...

2. Variables

Loading...

3. Simple if

Loading...

4. Simple loop

Loading...

5. Running commands

Loading...