System Administration
Showing results for 
Search instead for 
Do you mean 

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

SOLVED
Go to Solution
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
Exalted Contributor Exalted Contributor

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
Honored Contributor 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
Highlighted
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 -

Honored Contributor 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.
Regular Advisor

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

Many thanks,

Points awarded.

Tim