Operating System - HP-UX
1753853 Members
7884 Online
108808 Solutions
New Discussion юеВ

Re: How do I get su command to look at /etc/profile

 
SOLVED
Go to solution
Tim O'Connell
Regular Advisor

How do I get su command to look at /etc/profile

I'm on HPUX11. When I su from an ordinary user to become root (su, ENTER, password,ENTER) , it doesn't appear to run /etc/profile. I have some aliases set up there which don't appear to get run. Is ther a way of getting su to look at /etc/profile , root's profile or a profile of its own so than I can enable these aliases. This isn't vital - just handy for me in admin.

Thanks,

Tim
5 REPLIES 5
Steven E. Protter
Exalted Contributor
Solution

Re: How do I get su command to look at /etc/profile

You dont

Change su username

to

su - username


That will read /etc/profile $HOME/.profile and anything referenced therein.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
RAC_1
Honored Contributor

Re: How do I get su command to look at /etc/profile

you need "su - user_name"
man su for details.
There is no substitute to HARDWORK
Rajeev Tyagi
Valued Contributor

Re: How do I get su command to look at /etc/profile

To run /etc/profile and root's profile you have to use
#su -

Patrick Wallek
Honored Contributor

Re: How do I get su command to look at /etc/profile

# man su

Will give you all the detail you need.

In a nutshell:

If you specify the '-' (su - ) then su treats the new user as if you just logged in and all environments get processed.

If you don't specify the '-' then a subshell of you current shell is invoked and nothing gets read.
Tim O'Connell
Regular Advisor

Re: How do I get su command to look at /etc/profile

Many thanks,

Points awarded.

Tim