INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

environment variables settings for root account

Share

environment variables settings for root account

environment variables settings for root account

(OP)
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.

RE: environment variables settings for root account

What does env | pg show you?

RE: environment variables settings for root account

(OP)
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...

RE: environment variables settings for root account

What does echo $SHELL give back, ie which shell are you using? It's possible that another file is used rather than .profile.

RE: environment variables settings for root account

try running
set
will give you settings
I thought you have to edit /etc/profile ?

RE: environment variables settings for root account

/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.

RE: environment variables settings for root account

(OP)
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.

RE: environment variables settings for root account

(OP)
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...?

RE: environment variables settings for root account

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

RE: environment variables settings for root account

(OP)
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.?

RE: environment variables settings for root account

What does the (ls -al .profile) show?

Could you please paste the content of .profile?

Regards,
Khalid

RE: environment variables settings for root account

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)?

RE: environment variables settings for root account

cd to /
. ./.profile

what happens?

Mike

Unix *is* user friendly. It's just selective about who its friends are.

RE: environment variables settings for root account

(OP)
# 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

RE: environment variables settings for root account

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.

RE: environment variables settings for root account

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.

RE: environment variables settings for root account

Don't know Ken I try it and report back.

Mike

Unix *is* user friendly. It's just selective about who its friends are.

RE: environment variables settings for root account

Ken you are correct just needs read for owner (400)

Mike

Unix *is* user friendly. It's just selective about who its friends are.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close