Exam 102-500 All QuestionsBrowse all questions from this exam
Question 78

What is true regarding the statement beginning with #! that is found in the first line of script? (Choose two.)

    Correct Answer: C, E

    The statement beginning with #!, known as a shebang, specifies the path and arguments of the interpreter used to run the script. This allows the operating system to know which interpreter to use for executing the script. Additionally, while the shebang line is crucial for indicating the interpreter path, once this is processed by the operating system, the interpreter itself treats the shebang line as a comment and ignores it during execution.

Discussion
CuriousLinuxCatOptions: CE

I agree with C and E. C - The shebang does define the path (and if you choose, optional arguments) to the interpreter to run the script. E - It is true that if you place a #, it is ignored by the interpreter. However, before the interpretation takes place, something else happens before that. "The unix kernel's program loader is responsible for doing this. When exec() is called, it asks the kernel to load the program from the file at its argument. It will then check the first 16 bits of the file to see what executable format it has. If it finds that these bits are #! it will use the rest of the first line of the file to find which program it should launch, and it provides the name of the file it was trying to launch (the script) as the last argument to the interpreter program. The interpreter then runs as normal, and treats the #! as a comment line." https://stackoverflow.com/questions/3009192/how-does-the-shebang-work

feidhlimxOptions: BC

The question asks "What is true regarding the statement beginning with #! ..." E is incorrect, as the statement itself is not a comment ignored by the script interpreter! B. it triggers the installation of the script"™s interpreter. C. It specifies the path and the arguments of the interpreter used to run the script. ... are the correct answers here

LazylinuxOptions: BC

I would go for BC in the exam here is snippet... Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments. Blank lines are also ignored.. This means #! is exempted from the rule and hence BC is answer for sure...i cannot see how E can be right at all as questions clearly says the FIRST LINE ONLY it did NOT mention any other lines Read here: https://learning.lpi.org/en/learning-materials/102-500/105/105.2/105.2_01/#:~:text=the%20default%20interpreter,are%20also%20ignored.

lucaverceOptions: BC

E is wrong: the first line -ONLY THE FIRST LINE- expect a hash bang sign (also called "shebang") to tell wich kind of shell we'll intend to use and its path. Absolutely it is NOT a comment. So C for sure. B is correct for the same, because the #! in the first line trigger the script interpreter, the word "installation" is ambiguous, maybe a trick or a type mistake.

SScottOptions: BC

Fairly sure a typo is present. Replace installation with parsing and B makes more sense than a simple REM # in E

SScott

This question is poorly worded. LPIC is placing emphasis on the # comment as well. Changing my answer to C and E. https://learning.lpi.org/en/learning-materials/102-500/105/105.2/105.2_01/#:~:text=the%20default%20interpreter,are%20also%20ignored.

Lazylinux

I think U read it WRONG...here is snippet... Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments. Blank lines are also ignored.. This means #! is exempted from the rule and hence BC is answer for sure...i cannot see how E can be right at all as questions clearly says the FIRST LINE ONLY it did NOT mention any other lines

kleverOptions: BC

In linux # is treated as a command but #! has a special meaning so E cannot be correct

marencoOptions: BC

It's B and C, the reason is #! is the shebang, so if you want to ignore it you need to use just # that's why it is not the C, just after the characters #! (known as shebang). In a script with instructions for the Bash shell, the first line should be #!/bin/bash. By indicating this line, the interpreter for all the instructions in the file will be /bin/bash. Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments. Blank lines are also ignored. #!/bin/bash # A very simple script

lbellicOptions: BC

assuming that #! in this case is the shebang and not a part of a comment. B C i think is correct

aciko11Options: CE

"The first line is the shebang and defines what program is going to interpret the script: #!/bin/bash. Curiously enough, that program is bash itself." https://learning.lpi.org/en/learning-materials/102-500/105/105.1/105.1_03/ A - Is WRONG since the exlamation mark wont prevent the script from being executed B - Is WRONG since it wont trigger the installation of the interpreter C - It is CORRECT since the shebang specifies the path of the interpreter and the arguments used (the script will be passed implicitly as first argument and you can specify arguments yourself) D - It is WRONG since it does not define the encoding E - It is CORRECT. The selected interpreter (e.g. bash, python) will ignore that line and treat is as a comment, it will not get ignored by the kernel when you execute the script, but the interpreter itself will ignore it

SeifotoOptions: BC

The first line of the script should include a path to the Bash shell executable. The #! tells the system that this first line is intended to provide this path. Typically a pound sign # character is used to comment a line, but when placed at the beginning of the first line and followed by an exclamation mark ! character, it is used to tell the system which executable to use to run the program. So I think the correct answers are B & C.

AbbribasOptions: BC

The #! (shebang) line is indeed not a comment; it is used to specify the path to the interpreter that should be used to execute the script. So, option E is incorrect in this context. The correct options are: B. It triggers the installation of the script's interpreter. C. It specifies the path and the arguments of the interpreter used to run the script.

blk_542Options: BC

B is true, even though is wrongly redacted: instead of "installation" it should be "initialization" C is true, actually redundant with B. E is not true becuase yes, all lines beginning # are considered comments AFTER that initial #! https://learning.lpi.org/en/learning-materials/102-500/105/105.2/105.2_01/ "the first line should be #!/bin/bash. By indicating this line, the interpreter for all the instructions in the file will be /bin/bash. Except for the first line, all other lines starting with the hash character # will be ignored"

Adam_HOptions: BC

"What is true regarding the statement beginning with #! that is found in the first line of script? (Choose two.)" Everyone seems to agree that C is correct. It can't be D, it doesn't have anything to do with the character encoding. A is also out, because the shebang doesn't prevent the script from being executed. E is completely wrong. Not only is the statement sarting with #! in the first line not ignored by the script interpreter, it's what informs the system that the file is actually a script and what interpreter it should use for the script! B isn't quite right because it doesn't trigger the installation of the script's interpreter (it actually triggers the running of the script interpreter), but it's the most-correct answer of the options listed.

Adam_H

"How an interpreter reads a script file varies and there are distinct ways of doing so in a Bash shell session, but the default interpreter for a script file will be the one indicated in the first line of the script, just after the characters #! (known as shebang). In a script with instructions for the Bash shell, the first line should be #!/bin/bash. By indicating this line, the interpreter for all the instructions in the file will be /bin/bash. Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments." {source: LPIC-1 (102) (Version 5.0), page 88}

amindiashviliOptions: CE

C and E are correct.

TedMOptions: CE

C and E are correct answers

alitosdavilaOptions: CE

https://en.wikipedia.org/wiki/Shebang_(Unix) The shebang line is usually ignored by the interpreter, because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments still may ignore the shebang line in recognition of its purpose

Robert12Options: BC

While it formally looks like a comment, the fact that it's the very first two bytes of a file marks the whole file as a text file and as a script. The script will be passed to the executable mentioned on the first line after the shebang.