Re: How do I get su command to look at /etc/profile (18 Views)
Reply
Regular Advisor
Tim O'Connell
Posts: 112
Registered: ‎11-30-2003
Message 1 of 6 (18 Views)
Accepted Solution

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
Exalted Contributor
Steven E. Protter
Posts: 33,806
Registered: ‎08-15-2002
Message 2 of 6 (18 Views)

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
RAC_1
Posts: 5,920
Registered: ‎03-21-2002
Message 3 of 6 (18 Views)

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
Valued Contributor
Rajeev Tyagi
Posts: 89
Registered: ‎11-05-2000
Message 4 of 6 (18 Views)

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
Patrick Wallek
Posts: 13,774
Registered: ‎06-21-2000
Message 5 of 6 (18 Views)

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
Tim O'Connell
Posts: 112
Registered: ‎11-30-2003
Message 6 of 6 (18 Views)

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

Many thanks,

Points awarded.

Tim
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.