Fetching latest headlines…
The day I realized the shebang matters
NORTH AMERICA
🇺🇸 United StatesMay 9, 2026

The day I realized the shebang matters

0 views0 likes0 comments
Originally published byDev.to

First I ran:

chmod +x hello.py
./hello.py

and got:

Permission denied

I thought the 755 bit was enough, but the real issue was the shebang line.

If the first line of a script doesn't point to a valid interpreter, the kernel tries to execute the file directly and fails with permission denied.

The fix? Add a proper shebang:

!/usr/bin/env python3

or point to the exact path:

!/usr/bin/python3

Then run chmod +x hello.py again.

Now it works.
Lesson: Always double-check the shebang, especially when moving scripts between machines.

Have you run into this before?

Comments (0)

Sign in to join the discussion

Be the first to comment!