Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:38:05+00:00 2026-06-10T23:38:05+00:00

I was writing a simple shell script and found out that my shell script

  • 0

I was writing a simple shell script and found out that my shell script doesn’t require shebang line

#!/bin/sh

If I give execute permissions to my script and execute using ./myscript.sh. It runs fine.

I am using bash shell and /bin/sh is actually pointing to bash.

lrwxrwxrwx 1 root root /bin/sh -> bash

I know that shebang line is used to tell shell which interpreter to use for your rest of the script.

If I miss shebang line in perl, give execute permissions and run ./myscript.pl, it doesn’t work.

What’s actually happening here? If I use ./, When is shebang line actually needed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:38:06+00:00Added an answer on June 10, 2026 at 11:38 pm

    shebang line is needed in the file and only if it’s meant to be run as executable (as opposed to sh file.sh invocation. It is not actually needed by script, it is for the system to know how to find interpreter.

    EDIT: Sorry for misreading the question. If the shebang line is missing or not recognized, /bin/sh is used. But I prefer being explicit about the interpreter.

    Note, that this behavior is not universal, IIRC, only some exec* family function do that (not to mention different platforms), so that’s another reason to be explicit here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple unix shell script: #!/bin/bash # abort the script if
I am writing a simple shell script that fetches output from one command and
I am currently writing my own shell program. This simple shell can just execute
I am writing a simple shell script which changes the mac address of the
i've been writing a simple text to speech php script that works with festvox,
I'm writing a shell script that outputs all untranslated strings from gettext .po file,
I'm writing a very simple shell scripts that would looked at the log of
I am writing a simple shell script which requires a root privilege. Using the
I am writing a shell (bash) script and I'm trying to figure out an
I am writing a very simple comparison in shell bash script, but I never

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.