Link to home
Start Free TrialLog in
Avatar of ixarissysadmin
ixarissysadminFlag for Malta

asked on

Set default environment for root

I've set /etc/passwd so that /bin/bash is my shell for both the normal user as well as root. I've set up /etc/profile with a number of parameters i need (ex PATH, umask, PS1). When i log in with my user, i am assiging those settings. If i 'su -', i am also assigned those env settings.

However, if i just 'su' i lose them and get a default PATH of /usr/sbin:/usr/bin. interestingly, umask setting stays put.

Any ideas what's going on here?
Avatar of Rowley
Rowley
Flag of United Kingdom of Great Britain and Northern Ireland image

From the su manpage:

If the first argument to su is a dash (-), the environment will be changed to what would be expected if the user actually logged in as the specified user. Otherwise, the environment is passed along, with the exception of $PATH,  which is controlled by PATH and SUPATH in /etc/default/su.

http://docs.sun.com/app/docs/doc/816-5166/su-1m?a=view
Avatar of ixarissysadmin

ASKER

i did unhash SUPATH in that file and set it as i need, but nothing  changed.
Do yo have .profile in roots home directory ( / ) ?
Avatar of omarfarid
when you do su - then the system will simulate full root login and read /etc/profile , /.profile , etc. while su alone will just switch the userid to root with the same env.
Avatar of kishored2004
kishored2004

the - in the su command is optional. If you want to have the environment of the user you are switching to you would use the su -.Just doing an su will only give you the privileges of the user without importing any environment variables.

Check for /.bash_profile
no i don't have  a /.profile; nor a /.bash_profile

when i just 'su' my PATH changes to the default as stated above, whereas i want to change it.
ASKER CERTIFIED SOLUTION
Avatar of Rowley
Rowley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial