Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

environment variables settings for root account

Status
Not open for further replies.

inunix

Technical User
Jul 30, 2002
53
0
0
US
How to make certain environment variables available for root on startup..?

Though I've the .profile created under the root's home directory ie / , looks like this file has not been used for some reasons.. because when I type echo $VAR, i'm not getting anything... Please advice.
 
env|pg - list lot of values.. but whatever I set in .profile is missing...
# env|pg
_=/usr/bin/env
MANPATH=/usr/dt/man:/usr/share/man
SESSIONTYPE=dt
DTDATABASESEARCHPATH=//.dt/types,/etc/dt/appconfig/types/%L,/etc/dt/appconfig/types/C,/usr/dt/appconfig/types/%L,/usr/dt/appconfig/types/C
LANG=en_US
LOGIN=root
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/dt/bin:/usr/bin/X11:/sbin:/usr/java131/jre/bin:/usr/java131/bin


like this there are many...
 
What does echo $SHELL give back, ie which shell are you using? It's possible that another file is used rather than .profile.
 
try running
set
will give you settings
I thought you have to edit /etc/profile ?
 
/etc/profile is a global profile that's run for all users. No good if you just want to make changes for root.

Are you using command line login or GUI?



Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
it is /usr/bin/ksh and

also when I run
# . .profile
/usr/bin/ksh: .profile: not found.

Also someone told that I need to add this file in passwd file.. if so where exactly I should add this.
 
This is what I found for root in /etc/passwd file
root:!:0:0::/:/usr/bin/ksh

How to add the .profile here so that it will execute automatically on login...?
 
Have you set a different home dir for root? Use

lsuser -a home root

to find out the home dir.

Did you export the set variables in /.profile?

Also you could set up a special if-then-fi part in /etc/profile

ID=$(whoami)
if [ "${ID}" = 'root' ]
then
VAR=value
export VAR
...
fi

Also, if you want to try stuff in /.profile manually, then use the following

. /.profile

By default, the current dir is not in the search ${PATH}, hence the error: .profile: not found ...


HTH,

p5wizard
 
The home dir for the root is /.

I don't want to alter the /etc/profile; I just wanted the root session to use values from .profile on every login.

How should I enable this.?
 
What does the (ls -al .profile) show?

Could you please paste the content of .profile?

Regards,
Khalid
 
It should (as far as I know) be picked up by default. I take it the permissions are correct? Mine are -rw-r--r-- is that helps. As p5 says, did you export the variables? What is the syntax you're using (one example, say)?
 
cd to /
. ./.profile

what happens?

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
# ls -l .profile
-rwxr-x--x 1 root system 815 Jul 06 19:36 .profile

# . /.profile -> this work fine; i mean after this i can get the environment variables values; but this is enalbled only for that session; so everytime i should manullay execute this; instead i want this to be executed like for other user accounts.

this is how I've kept the env vars inside the .profile
DOCAPP_BASE=/usr/java131
export DOCAPP_BASE
JAVA_HOME=$DOCAPP_BASE/jdk
export JAVA_HOME
LC_ALL=C export LC_ALL

 
Nothing to do with the problem your having but I'd change the permissions to 740 (Not a good idea to allow anyone to execute roots .profile )

From what you've told us the .profile should work as you expect (execute on login). Can you post the contents of your .profile just in case there are any funnies in it.

Also worth a try mv .profile .profile.old

vi .profile

enter

echo "Profile has run"

:wq

chown root:system .profile
chmod 740 .profile

Sign out & back in

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
Mike - just out of interest - I wonder whether it has to be executable at all (see my earlier posts), since it seems to be read on login rather than executed. But that may be just my faulty understanding.
 
Don't know Ken I try it and report back.

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
Ken you are correct just needs read for owner (400)

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top