Breaking
April 13, 2025

Tracing the #!: How the Linux Kernel Handles the Shebang Maya Posch | usagoldmines.com

One of the delights in Bash, zsh, or whichever shell tickles your fancy in your OSS distribution of choice, is the ease of which you can use scripts. These can be shell scripts, or use the Perl, Python or another interpreter, as defined by the shebang (#!) at the beginning of the script. This signature is followed by the path to the interpret, which can be /bin/sh for maximum compatibility across OSes, but how does this actually work? As [Bruno Croci] found while digging into this question, it is not the shell that interprets the shebang, but the kernel.

It’s easy enough to find out the basic execution sequence using strace after you run an executable shell script with said shebang in place. The first point is in execve, a syscall that gets one straight into the Linux kernel (fs/exec.c). Here the ‘binary program’ is analyzed for its executable format, which for the shell script gets us to binfmt_script.c. Incidentally the binfmt_misc.c source file provides an interesting detour as it concerns magic byte sequences to do something similar as a shebang.

As a bonus [Bruno] also digs into the difference between executing a script with shebang or running it in a shell (e.g. sh script.sh), before wrapping up with a look at where the execute permission on a shebang-ed shell script is checked.

 

This articles is written by : Nermeen Nabil Khear Abdelmalak

All rights reserved to : USAGOLDMIES . www.usagoldmines.com

You can Enjoy surfing our website categories and read more content in many fields you may like .

Why USAGoldMines ?

USAGoldMines is a comprehensive website offering the latest in financial, crypto, and technical news. With specialized sections for each category, it provides readers with up-to-date market insights, investment trends, and technological advancements, making it a valuable resource for investors and enthusiasts in the fast-paced financial world.

Recent:

Learning Linux Kernel Modules Using COM Binary Support Maya Posch | usagoldmines.com

A 17th Century Music Computer Al Williams | usagoldmines.com

The Incomplete JSON Pretty Printer (Brought To You By Vibes) Donald Papp | usagoldmines.com

Hacking a Cheap Rechargeable Lamp With Non-Standard USB-C Connector Maya Posch | usagoldmines.com

Vibe Check: False Packages a New LLM Security Risk? Tyler August | usagoldmines.com

JPMorgan Chase Refuses To Reimburse $440,000 After Customer’s Account Hammered With Illicit Withdraw...

DIY Soldering Tweezers, Extra Thrifty Donald Papp | usagoldmines.com

Biting Off More Than I Can Chew Elliot Williams | usagoldmines.com

Bank of America Discloses Data Breach After Customers’ Documents Disappear, Says Names, Addresses, A...

Tiny Pogo Robot Gets Wings, Does Flips Donald Papp | usagoldmines.com

Repairing Classic Sound Cards Jenny List | usagoldmines.com

Creating a Somatosensory Pathway From Human Stem Cells Maya Posch | usagoldmines.com

Bank of America Handing $2,850,000 To Customers in Settlement Over Alleged Illegal Fees and Account ...

Gemini 2.0 + Robotics = Slam Dunk? John Elliot V | usagoldmines.com

A Mouse, No Hands! Jenny List | usagoldmines.com

Hackaday Podcast Episode 316: Soft Robots, Linux the Hard Way, Cellphones into SBCs, and the Circuit...

GPS Broken? Try TV! Al Williams | usagoldmines.com

Audio Effects Applied to Text Al Williams | usagoldmines.com

This Week in Security: AI Spam, SAP, and Ivanti Jonathan Bennett | usagoldmines.com

The Jupiter Ace Remembered Al Williams | usagoldmines.com

Brush Up on Your Trade Craft With This Tiny FM Bug Dan Maloney | usagoldmines.com

Farewell Economy 7, a Casualty of the Long Wave Switch-Off Jenny List | usagoldmines.com

Using Integer Addition to Approximate Float Multiplication Maya Posch | usagoldmines.com

Windows on ARM on Arm Bryan Cockfield | usagoldmines.com

A New Mechanical Keyboard for an Old Computer Bryan Cockfield | usagoldmines.com

Improving Magnetoplasmadynamic Ion Thrusters With Superconductors Maya Posch | usagoldmines.com

Ask Hackaday: What’s a Sun-Like Star? Al Williams | usagoldmines.com

Clever Engineering Leaves Appliance Useless Tom Nardi | usagoldmines.com

Everyone’s Talking GPMI, Should you? Jenny List | usagoldmines.com

Making Liquid Oxygen: Far From Easy but Worth the Effort Dan Maloney | usagoldmines.com

Ask Hackaday: Vibe Coding Jenny List | usagoldmines.com

Ask Hackaday: Vibe Coding Jenny List | usagoldmines.com

Going to the Top with a Raspberry Pi Elevator Al Williams | usagoldmines.com

FLOSS Weekly Episode 828: Incus Inception Jonathan Bennett | usagoldmines.com

Self-Hosting a Cluster on Old Phones Bryan Cockfield | usagoldmines.com

You Shouldn’t Build an X-Ray Machine, But You Could Al Williams | usagoldmines.com

In 2025, The Philly Maker Faire Finds Its Groove Tom Nardi | usagoldmines.com

Forget Propellers, Embrace Tentacle-based Locomotion Donald Papp | usagoldmines.com

Better Bearings Take the Wobble Out of Premium Scroll Wheel Dan Maloney | usagoldmines.com

Salamander Robot is Squishy Al Williams | usagoldmines.com

Dozens of Solenoids Turn Vintage Typewriter into a Printer Dan Maloney | usagoldmines.com

ASCII to Mainframe Al Williams | usagoldmines.com

Designing A Tone Control Properly Jenny List | usagoldmines.com

The Computers of EPCOT Al Williams | usagoldmines.com

FreeDOS 1.4 Released Maya Posch | usagoldmines.com

Turning Old Cellphones into SBCs Elliot Williams | usagoldmines.com

LayerLapse Simplifies 3D Printer Time-lapse Shots Tom Nardi | usagoldmines.com

Printed Robotic Arm Pumps Up With Brushless Motors Tom Nardi | usagoldmines.com

The 1980s Computer, French Style Jenny List | usagoldmines.com

Simple Antenna Makes for Better ESP32-C3 WiFi Dan Maloney | usagoldmines.com

Atomic Clock Trades Receiver for an ESP8266 Tom Nardi | usagoldmines.com

Buyer Beware: Cheap Power Strips Hold Hidden Horrors Dan Maloney | usagoldmines.com

A Tiny Tape Synth Jenny List | usagoldmines.com

London Police Team Up With International Law Firm After Elderly Victim Defrauded for $2,580,000 Rhod...

Keebin’ with Kristina: the One Where We Embrace the Jank Kristina Panos | usagoldmines.com

Fiber Laser Gives DIY PCBs a Professional Finish Tom Nardi | usagoldmines.com

Why USB-C Splitters Can Cause Magic Smoke Release Maya Posch | usagoldmines.com

Which Browser Should I Use In 2025? Jenny List | usagoldmines.com

Tracking the ISS Made Easy Elliot Williams | usagoldmines.com

A Tale Of Nuclear Shenanigans From Down Under Jenny List | usagoldmines.com

Pluto’s Not a Planet, But It Is a Spectrum Analyzer Al Williams | usagoldmines.com

Command and Conquer Ported to the Pi Pico 2 Tom Nardi | usagoldmines.com

Hackers Hammer Android and iPhone Users As Bank Account Attacks Surge 258% in One Year: Kaspersky Ma...

Reverse Engineering the IBM PC110, One PCB at a Time Tom Nardi | usagoldmines.com

An Amstrad PCW Receives A Bit Of Love Jenny List | usagoldmines.com

Emulating iPhone on QEMU Al Williams | usagoldmines.com

Celebrating 30 Years of Windows 95 at VCF Adam Fabio | usagoldmines.com

A Low F Number Lens, From Scratch Jenny List | usagoldmines.com

Ben Eater vs. Microsoft BASIC Elliot Williams | usagoldmines.com

$4,400 Drained From Bank of America Account After Owner Is Violently Robbed of His Unlocked Phone – ...

Inside an Edison Phonograph Al Williams | usagoldmines.com

How Shrinking Feature Size Made Modern Wireless Work Elliot Williams | usagoldmines.com

How a Tiny Relay Became a USB Swiss Army Knife Heidi Ulrich | usagoldmines.com

Wells Fargo Ordered To Pay $832,000,000 in Damages After Jury Finds Lender Mismanaged and Charged Un...

If You’re 3D Scanning, You’ll Want a Way To Work with Point Clouds Donald Papp | usagoldmines.com

Chase and PayPal Scam Drains $30,000 From Victims’ Bank Accounts: Report Daily Hodl Staff | usagoldm...

A Look Inside MacPaint Al Williams | usagoldmines.com

Disney’s Bipedal, BDX-Series Droid Gets the DIY Treatment Donald Papp | usagoldmines.com

8 Pins For Linux Jenny List | usagoldmines.com

Lockdown Remote Control Project is Free and Open Elliot Williams | usagoldmines.com

The Transputer in your Browser Al Williams | usagoldmines.com

Thousands of Americans’ Personal Information Exposed By Banking Giant Capital One, Alleges New Class...

First PCB with the Smallest MCU? Elliot Williams | usagoldmines.com

Vintage Computer Festival East This Weekend Elliot Williams | usagoldmines.com

Supercon 2024: Quick High-Feature Boards With The Circuit Graver Lewin Day | usagoldmines.com

3D Print (and Play!) The Super Mario Tune as a Fidget Toy Donald Papp | usagoldmines.com

Hackaday Podcast Episode 315: Conductive String Theory, Decloudified Music Players, and Wild Printin...

This Week in Security: Target Coinbase, Leaking Call Records, and Microsoft Hotpatching Jonathan Ben...

Keep Bears at Bay with the Crackle of 280,000 Volts Lewin Day | usagoldmines.com

A Portable Electronics Workstation Al Williams | usagoldmines.com

Playstacean Evolves The PSOne Into The Crab It Was Always Meant to Be Navarre Bartz | usagoldmines.c...

A Proper OS For The Sega Genesis/Megadrive Jenny List | usagoldmines.com

The Weird Way A DEC Alpha Boots Jenny List | usagoldmines.com

Woman Loses $3,000,000 in Crypto Pig Butchering Scam After Fake Platform Showed 80% Profits: Report ...

Teardown of a Scam Ultrasonic Cleaner Maya Posch | usagoldmines.com

Australia’s Silliac Computer Al Williams | usagoldmines.com

FBI Recovers $8,000,000+ of Investor Funds Stolen by CEO of Collapsed Heartland Tri-State Bank in Cr...

Ditto That Kristina Panos | usagoldmines.com

MIT Wants You to Secure Your Hardware Designs Al Williams | usagoldmines.com

Remembering Betty Webb: Bletchley Park & Pentagon Code Breaker Maya Posch | usagoldmines.com

Leave a Reply