Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 102-500 topic 1 question 78 discussion

Actual exam question from LPI's 102-500
Question #: 78
Topic #: 1
[All 102-500 Questions]

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

  • A. It prevents the scripts from being executed until the ! is removed.
  • 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.
  • D. It defines the character encoding of the script.
  • E. It is a comment that is ignored by the script interpreter.
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
feidhlimx
Highly Voted 1 year, 11 months ago
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
upvoted 8 times
...
CuriousLinuxCat
Highly Voted 2 years, 8 months ago
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
upvoted 7 times
...
Abbribas
Most Recent 3 months, 1 week ago
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.
upvoted 1 times
...
aciko11
9 months ago
"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
upvoted 2 times
...
blk_542
10 months, 3 weeks ago
Selected Answer: 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"
upvoted 1 times
...
Adam_H
1 year, 2 months ago
Selected Answer: 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.
upvoted 1 times
Adam_H
1 year, 2 months ago
"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}
upvoted 1 times
...
...
klever
1 year, 3 months ago
In linux # is treated as a command but #! has a special meaning so E cannot be correct
upvoted 3 times
...
amindiashvili
1 year, 11 months ago
C and E are correct.
upvoted 1 times
...
lucaverce
1 year, 11 months ago
Selected Answer: 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.
upvoted 4 times
...
TedM
2 years ago
Selected Answer: CE
C and E are correct answers
upvoted 1 times
...
Lazylinux
2 years ago
Selected Answer: 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.
upvoted 5 times
...
alitosdavila
2 years ago
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
upvoted 1 times
...
SScott
2 years, 1 month ago
Selected Answer: BC
Fairly sure a typo is present. Replace installation with parsing and B makes more sense than a simple REM # in E
upvoted 4 times
SScott
2 years, 1 month ago
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.
upvoted 1 times
Lazylinux
2 years ago
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
upvoted 3 times
...
...
...
marenco
2 years, 1 month ago
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
upvoted 3 times
...
lbellic
2 years, 1 month ago
Selected Answer: BC
assuming that #! in this case is the shebang and not a part of a comment. B C i think is correct
upvoted 3 times
...
Robert12
2 years, 1 month ago
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.
upvoted 1 times
...
Robert12
2 years, 1 month ago
interpreter is generally an absolute path to an executable program.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...