LFCS · Question #555
An administrator is looking into a new script that they have just received from a senior administrator. In the very first line the administrator notices a #! followed by a path to a binary. Linux…
The correct answer is B. use that binary to interpret the script. The #! (shebang) line at the beginning of a script specifies the interpreter program that the operating system should use to execute the script.
Question
Options
- Aignore the script.
- Buse that binary to interpret the script.
- Cuse that binary to compile the script.
- Dbe replaced by that binary.
How the community answered
(16 responses)- B94% (15)
- C6% (1)
Why each option
The `#!` (shebang) line at the beginning of a script specifies the interpreter program that the operating system should use to execute the script.
Linux does not ignore scripts with a shebang line; instead, it uses the shebang to determine how to execute them.
When a script begins with `#!` followed by a path to a binary (e.g., `#!/bin/bash` or `#!/usr/bin/python3`), the Linux kernel reads this "shebang" line and executes the specified binary, passing the script file as an argument to that interpreter. This allows scripts to be run directly like executable binaries.
Interpreted scripts are executed line by line by an interpreter, not compiled into a separate executable binary.
The binary specified in the shebang is used to *interpret* the script, not to replace the operating system or any part of it.
Concept tested: Shebang line in Linux scripts
Source: https://www.tldp.org/LDP/abs/html/sha-bang.html
Topics
Community Discussion
No community discussion yet for this question.