What will he see, and why?

You have edited /etc/profile to include the lines:
dennis_says=hello
export dennie_says
You have also edited /etc/skel/local.profile to include the line:

dennis_says=world
You now create a new user account brian, and specify use of the bash shell. When brian logs in
and enters
echo $dennis_says
What will he see, and why?

You have edited /etc/profile to include the lines:
dennis_says=hello
export dennie_says
You have also edited /etc/skel/local.profile to include the line:

dennis_says=world
You now create a new user account brian, and specify use of the bash shell. When brian logs in
and enters
echo $dennis_says
What will he see, and why?

A.
world, because the local.profile entry will be executed last

B.
hello, because the global /etc/profile entry overrides the local.profile entry

C.
hello, because the local.profile entry is not automatically sourced on login

D.
hello, because the value specified in local.profile was not exported

E.
nothing, because the variable was not exported in local.profile

Explanation:
The $HOME/.profile file is an initialization file that is executed after the /etc/profile
when logging in to the Bourne or Korn shell. The file contains user preferences for variable
settings. If the ENV variable is set to .kshrc, the .kshrc file executes every time a new shell begins
execution. The $HOME/.profile is copied from the /etc/skel/local.profile file by the Administration
Tool when creating a new account.
Note: /etc/skel/local.profile
Per-system configuration file for
sh/ksh/ksh93/bash login sessions,
installed for new users



Leave a Reply 13

Your email address will not be published. Required fields are marked *


Murali

Murali

C is Correct

Jambass

Jambass

You have edited /etc/profile to include the lines:
dennis_says=hello
export dennie_says

it is?

or

You have edited /etc/profile to include the lines:
dennis_says=hello
export dennis_says

Bruno

Bruno

The correct D.
hello, because the value specified in local.profile was not exported

John

John

Bruno, this would be wrong because .profile would have to be the initialisation file name, not local.profile (this is a default user starter file template name)

Shadi Al-Moallemi

Shadi Al-Moallemi

Is it D, because the /$ HOME/.profile is copied from the /etc/skel/local.profile file ????

david

david

C is correct.

Shadi Al-Moallemi

Shadi Al-Moallemi

Could you please clarify more why it’s C, I have been confused.

Vinicius Torres

Vinicius Torres

D is not right.

I exported the variable, and the word showed was “hello”.

iietam

iietam

Correct C because bash and ksh93 use .profile not local.profile
The /etc/profile is read before .profile
So, .profile doesn’t contain dennis_says variable, but /etc/profile does.
The say “You have also edited /etc/skel/local.profile to include the line:dennis_says=world”, not that you have edited /etc/skel/.profile

Obviously export dennie_says is typo mistake, although it work if you comment out the export clause.

Reference:
https://docs.oracle.com/cd/E23824_01/html/821-1451/userconcept-23295.html

BSD Bandit

BSD Bandit

A, the command echo $dennis_says will return world