Exam 101-500 All QuestionsBrowse all questions from this exam
Question 40

From a Bash shell, which of the following commands directly execute the instructions from the file /usr/local/bin/runme.sh without starting a subshell?

(Choose two.)

    Correct Answer: A, D

    In Bash, the commands 'source' and '.' are used to execute a script in the current shell. 'source /usr/local/bin/runme.sh' reads and executes the instructions from the script in the current shell, meaning any changes to the environment by the script persist after the script finishes. Similarly, '. /usr/local/bin/runme.sh' does the same thing; the dot (.) is an alternative to the 'source' command in Bash. Both do not start a new subshell, ensuring the script runs within the current shell environment.

Discussion
NegatorOptions: AD

Create a script that outputs the shell level environmental variable using "echo $SHLVL". When you execute this script using source or dot (.) it will display 1 showing that the script was executed in the current shell. When you execute the script using full path it will show 2, showing that the script was executed in a subshell.

CuriousLinuxCatOptions: AD

A and D is correct. source and . tested on Ubuntu.

ilputtoOptions: AD

the correct one is A and D. source <script> and . ./<script> are equivalent

VendoOptions: AD

When a script is run using source it runs within the existing shell, any variables created or modified by the script will remain available after the script completes. source is a synonym for dot/period '.' in bash. Be careful! ./ and source are not quite the same. ./script runs the script as an executable file, launching a new shell to run it https://ss64.com/bash/source.html

jsteven845Options: AD

A and D

mrironOptions: AD

A and D are correct, assuming there is a space after (.) point for D . B is wrong , because it execute in the kind shell not in current shell

deewetdvjbmnjkjytfdszxcOptions: AD

Isn't A+B?

Aleksandre

Maybe something changed here. Correct answer is A and B tried on arch linux. running bash script using absolute path does not creates subshell (does not increments $SHLVL variable)

NinymoOptions: AD

Answer: AD

MchoetiOptions: AD

right A and D

MIUOptions: AD

A and D are correct. When you try, just copy and paste from the question. You guys sometimes typo when you try then on your environment....

snota45

it is A & C

Vano1

The correct answer is A, B. Verified on CentOS7.

Vano1

D is correct if between . (dot) and /usr/loca/bin/runme.sh is a space. This question have 3 correct answer or I don't understand something.

Vano1

After some researchers, I choose A and D.