Smart questions
Smart answers
Smart people
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 now!
  • 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.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

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

inunix (TechnicalUser) (OP)
13 Jul 06 3:55
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.
KenCunningham (TechnicalUser)
13 Jul 06 4:00
What does env | pg show you?
inunix (TechnicalUser) (OP)
13 Jul 06 4:42
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...
KenCunningham (TechnicalUser)
13 Jul 06 4:47
What does echo $SHELL give back, ie which shell are you using? It's possible that another file is used rather than .profile.
beav123 (TechnicalUser)
13 Jul 06 5:31
try running
set
will give you settings
I thought you have to edit /etc/profile ?
mrn (MIS)
13 Jul 06 5:35
/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.

inunix (TechnicalUser) (OP)
13 Jul 06 5:43
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.
inunix (TechnicalUser) (OP)
13 Jul 06 5:50
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...?
p5wizard (IS/IT--Management)
13 Jul 06 5:54
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

inunix (TechnicalUser) (OP)
13 Jul 06 6:26
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.?
khalidaaa (TechnicalUser)
13 Jul 06 6:32
What does the (ls -al .profile) show?

Could you please paste the content of .profile?

Regards,
Khalid
KenCunningham (TechnicalUser)
13 Jul 06 6:34
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)?
mrn (MIS)
13 Jul 06 6:41
cd to /
. ./.profile

what happens?

Mike

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

inunix (TechnicalUser) (OP)
13 Jul 06 6:52
# 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

mrn (MIS)
13 Jul 06 8:12
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.

KenCunningham (TechnicalUser)
13 Jul 06 9:21
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.
mrn (MIS)
13 Jul 06 9:35
Don't know Ken I try it and report back.

Mike

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

mrn (MIS)
13 Jul 06 9:45
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!

Back To Forum

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