1832857 Members
3057 Online
110048 Solutions
New Discussion

Login profile

 
SOLVED
Go to solution
O'lnes
Regular Advisor

Login profile

If I login as a gerenal user , and then run 'su' to login as root, which .profile will run?
( eg. if i directly login as root , it will run /.profile) Thank.
Andy
4 REPLIES 4
Tom Geudens
Honored Contributor

Re: Login profile

Hi,
This is explained in detail in the manpages of su. Note that there is a difference between "su" and "su -". If you want the "normal" environment, use "su -".

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Stefan Farrelly
Honored Contributor

Re: Login profile

If you do> su root
Then it wont run any .profile at all. If you do> su - root it will run roots homedir .profile (normally / but sometime people put it elsewhere like /root_home/)
Im from Palmerston North, New Zealand, but somehow ended up in London...
Ceesjan van Hattum
Esteemed Contributor
Solution

Re: Login profile

If you login as user, then ~user/.profile (i.e. $HOME/.profile).

If you do 'su', no extra .profile is taken.

If you do 'su -', the ~root/.profile is taken (i.e. $HOME/.profile, where $HOME is home of root).
So,.. if $HOME of root = '/', then /.profile is taken at direct login AND at 'su -'.
The '-' means: take environment of user.

Regards,
Ceesjan
Sean OB_1
Honored Contributor

Re: Login profile

If you issue "su" only no profile will run.

If you issue "su -" the .profile in root's home directory will run.

"su -" emulates a new log in to the system.