How to Execute .sh Files on Windows: Easy Methods for Beginners
Blog
Olivia Brown  

How to Execute .sh Files on Windows: Easy Methods for Beginners

So you’ve come across a mysterious file ending in .sh on your Windows computer. You double-click it and… nothing happens. What is this sorcery? Don’t worry — it’s not magic. It’s just a shell script. And yes, you can run it on Windows. Let’s dive in and learn how — the easy and fun way!

What is a .sh File Anyway?

A .sh file is a shell script. Think of it like a recipe for your computer. It contains step-by-step instructions (commands) that Linux and Unix systems understand.

But wait — Windows doesn’t speak that language out of the box. That’s why we need a little help.

Option 1: Use Windows Subsystem for Linux (WSL)

This is the most popular way to run .sh files on Windows.

Here’s how to do it:

  1. Press Windows key + S and type “Turn Windows features on or off”.
  2. Scroll down and check “Windows Subsystem for Linux”.
  3. Click OK and let Windows do its thing.
  4. Restart your PC.
  5. Go to the Microsoft Store and search for Ubuntu (or any Linux distro you like).
  6. Install it and launch it. You now have Linux on your Windows!

Once it’s set up:

cd /mnt/c/Users/YourUsername/path/to/your/file
./yourscript.sh

Tip: Replace YourUsername with your actual Windows username and update the path.

Option 2: Use Git Bash (So Simple!)

If WSL feels too advanced, Git Bash is here to save the day.

Follow these steps:

  1. Go to git-scm.com.
  2. Download and install Git for Windows.
  3. Right-click a folder with your .sh file.
  4. Select “Git Bash Here”.

Now just run:

./yourscript.sh

That’s it. Your shell script is alive! 🎉

Option 3: Use a Virtual Machine (for the Curious Folks)

This one is a little more involved, but also cool if you want a full Linux experience.

Try this:

  • Download a VM player like VirtualBox.
  • Install a Linux ISO (Ubuntu is beginner-friendly).
  • Make a virtual machine and boot into Linux.
  • Move your .sh file into the VM and run it just like on a real Linux machine.

Yep, you now run Linux inside Windows like a digital wizard.

Things to Remember

  • Don’t double-click .sh files on Windows. It won’t work as expected.
  • Use the terminal to run these scripts the right way.
  • Make scripts executable by running this command in Linux or Git Bash:
chmod +x yourscript.sh

Bonus: Write Your Own .sh Script!

Want to try something fun? Create your first script!

Do this:

  1. Open a text editor (Notepad works fine).
  2. Type these lines:
#!/bin/bash
echo "Hello, Windows running Linux Shell!"
  1. Save it as hello.sh.
  2. Run it using one of the methods above!

Look at you, scripting like a pro!

Final Thoughts

Running .sh files on Windows is a piece of cake once you know the tricks. You don’t need to be a coding ninja. Just pick the method that feels easiest, and 💥 boom — you’re automating things like a boss.

So go ahead, execute those scripts, and impress your friends with your cool new tech skills!