- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- SU loosing $HOME parameter
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:01 PM
07-28-2004 08:01 PM
SU loosing $HOME parameter
Does anybody know if is it possible to retain the $HOME variable even after a su (or su -) command?
I mean:
1) I'm using the user "alpha" with home: /home/alpha
2) alpha makes "su beta"
3) I'd like that $HOME is still /home/alpha.
Same thing with $LOGNAME...can I have the same $LOGNAME even after a su or a su - ?
Thanks in advance.
PS Actually I make aplha write a file with his $HOME and Beta read this file overwriting his $HOME with the variabile in the file! ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:04 PM
07-28-2004 08:04 PM
Re: SU loosing $HOME parameter
To keep your current environment use:
#su
To set
#su -
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:13 PM
07-28-2004 08:13 PM
Re: SU loosing $HOME parameter
$ su
$ su -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:14 PM
07-28-2004 08:14 PM
Re: SU loosing $HOME parameter
I think that you make mistake typing
su beta
instead
su - beta
Try with last one it will solve your problem.
Regards,
Borislav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:21 PM
07-28-2004 08:21 PM
Re: SU loosing $HOME parameter
Always you can force any environmental variables, i.e:
#whoami
user1
#echo $HOME
/home/user1
#su - user2
#whoami
user2
#echo $HOME
/home/user2
#export HOME=/home/user1
#echo $HOME
/home/user1
#pwd
/home/user2
#cd
#pwd
/home/user2 <-- $HOME assignament works
#export LOGNAME=user1
You can change $LOGNAME, but you never will the new user assignament.
#echo $LOGNAME
user1
#whoami
user2
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:24 PM
07-28-2004 08:24 PM
Re: SU loosing $HOME parameter
su -
See su man page. It will give the difference between su with - and su without -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 08:55 PM
07-28-2004 08:55 PM
Re: SU loosing $HOME parameter
I knew that "SU - user" will get the new environment of the new user....but I want to become the new user while retaining the old environment.
If I make "su - user" I get the new environment and I loose the old correctly.
The solution is to export the variable (export LOGNAME, export HOME etc) but in shell script I don't know who is the firt user when I SU to the second.
I mean:
In the profile of the first user alpha I have:
su - beta
so...I become beta and I forget anything about alpha...so I can't get /home/alpha...whitout a crystal ball ;-)
Anyway, Thanks to everybody
Emanuele
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 10:16 PM
07-28-2004 10:16 PM
Re: SU loosing $HOME parameter
But not the $LOGNAME parameter. It will be there as same as in the first login upto you use su -
--- su man page ---
The previously defined HOME and ENV environment variables are removed. ( on su without - )
I have tested the $LOGNAME parameter.
node1> echo $LOGNAME
user1
node1> su node2
node2> echo $LOGNAME
user1
So only $HOME variable and shell variables which was set at prev. user login.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 10:47 PM
07-28-2004 10:47 PM
Re: SU loosing $HOME parameter
Then save the alpha environment user's settings before any change, i.e:
#whoami
alpha
#echo $HOME $LOGNAME
/home/alpha alpha
#env > old.env
#su - beta
#echo $HOME $LOGNAME
/home/beta beta
#OLD_HOME=`grep ^HOME= old.env|awk -F"=" '{ print $2 }'`
#OLD_LOGNAME=`grep ^LOGNAME= old.env|awk -F"=" '{ print $2 }'`
#echo $OLD_HOME $OLD_LOGNAME
/home/alpha alpha
#export HOME=$OLD_HOME
#export LOGNAME=$OLD_LOGNAME
#echo $HOME $LOGNAME
/home/alpha alpha
Rgds.