A user brian is configured to use the bash shell. His home directory is /export/home/brian, and
contains a .profile and a .bashrc file.
In the -profile, there are these lines:
genius =ritchie
export genius
In the .bashrc us this line:
genius=kernighan
In /etc/profile are these lines:
genius=thompson
export genius
When brian logs in and asks for the value of genius, what will he find, and why?
A.
genius will be ritchie, because that was the value exported in .profile.
B.
genius will be kernighan, because .bashrc executes after .profile.
C.
genius will be ritchie because variable settings in .profile take precedence over variable settings
in .bashrc.
D.
genius will be ritchie because .profile executes after .bashrc.
E.
genius will be thompson because /etc/profile system settings always override local settings.
B
B is correct.
C (unless .bashrc is sourced form .profile , which default installation is not)
bob@sol11:~$ grep genius= /etc/profile .profile .bashrc
/etc/profile:genius=thompson
.profile:genius=ritche
.bashrc:genius=genius
bob@sol11:~$ echo $genius
ritche
bob@sol11:~$
do it locally
its B
The answer is A because the question just asks what happens if he asks for the value after logging in. Then bash only reads up to .profile and .bashrc is not read at all. If he would use an interactive shell that is not a login shell and ask for the value then he would get kerningham since .bashrc is read. Try it by logging through ssh and by the graphical interface, opening a terminal and asking for the value and you will see the difference.
Source: Oracle Solaris 11 System Administartion, Bill Calkins, page 471
Correct Answer is “C”
I go with C after I test it
A is wrong because you will ritche without export the genius
E & B are wrong because after test you will get genius=ritche
D wrong if you do #genius in .profile you will get nothing which mean .bashrc will no store any value
even C not too clear to me but is the best answer to me