Solved

Set default environment for root

Posted on 2008-10-01
7
1,079 Views
Last Modified: 2013-12-27
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?
0
Comment
Question by:ixarissysadmin
7 Comments
 
LVL 13

Expert Comment

by:Rowley
ID: 22614324
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
0
 

Author Comment

by:ixarissysadmin
ID: 22615224
i did unhash SUPATH in that file and set it as i need, but nothing  changed.
0
 
LVL 61

Expert Comment

by:gheist
ID: 22617267
Do yo have .profile in roots home directory ( / ) ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Expert Comment

by:omarfarid
ID: 22620510
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.
0
 
LVL 2

Expert Comment

by:kishored2004
ID: 22621636
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
0
 

Author Comment

by:ixarissysadmin
ID: 22623555
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.
0
 
LVL 13

Accepted Solution

by:
Rowley earned 500 total points
ID: 22623783
Have you remembered to comment out the PATH and SUPATH lines in /etc/default/su and set these up as desired? Works as expected for me...
# id

uid=0(root) gid=0(root)

# echo $PATH

/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/ucb

# su 

# echo $PATH

/usr/sbin:/usr/bin

# grep SUPATH /etc/default/su

# SUPATH sets the initial shell PATH variable for root

# SUPATH=/usr/sbin:/usr/bin

# vi /etc/default/su

# grep SUPATH /etc/default/su

# SUPATH sets the initial shell PATH variable for root

SUPATH=/usr/sbin:/usr/bin:/home

# su 

# echo $PATH

/usr/sbin:/usr/bin:/home

# ls -l /etc/default/su

-rw-r--r--   1 root     sys         1618 Oct  2 13:59 /etc/default/su

# uname -a

SunOS unknown 5.11 snv_97 i86pc i386 i86pc

# su - admin

Sun Microsystems Inc.   SunOS 5.11      snv_97  November 2008

-bash-3.2$ echo $PATH

/usr/bin:

-bash-3.2$ su admin

Password: 

bash-3.2$ echo $PATH

/usr/bin:

bash-3.2$ exit

exit

# vi /etc/default/su

# grep ^PATH /etc/default/su

PATH=/usr/bin:/home:

# su admin 

# echo $PATH

/usr/sbin:/usr/bin:/home

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cant install flashplugins for firefox in freebsd 8 9 44
Unix / Linux grid computing 5 147
Generate FIPS 140-2 Public Key on Unix 5 66
reinstall 1 70
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now