Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use different home directories for GUI and shell access UNIX
If you're like me and you regularly log into an OS X system from a remote location using Terminal, you most likely have a bunch of tools and scripts you regularly use. However, you also log on to the system using the GUI. When navigating the CLI, you don't want to see folders like 'Movies' and 'Library,' and when navigating the GUI, you don't want to see folders like bin and src.

So I figured I needed a way around that. Changing stuff using NetInfo, however, does not have the required effect. I consulted the experts on IRC, over at #macosx on EFnet and they threw me the ultra-simple solution of 'change your HOME environment variable.' Keep it simple, stupid. What you do is edit your .bashrc or (as in my case, .tcshrc) file to change the environment variable HOME to the new location, and then change to that directory. So:
setenv HOME /usr/home/gadg
cd $HOME
This will make me be in /usr/home/gadg. Referring to $HOME or ~ will point to /usr/home/gadg. However, referring to ~gadg will still point to /Users/gadg, as this is probably from the NetInfo database. Any improvements on this trick are more than welcome, of course!

[robg adds: I believe the bash version of the command is HOME=/usr/home/gadg; export HOME -- but I'm sure someone will correct me if I'm wrong!]
  • Currently 1.33 / 5
  You rated: 1 / 5 (3 votes cast)

Use different home directories for GUI and shell access | 4 comments | Create New Account
Click here to return to the 'Use different home directories for GUI and shell access' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use different home directories for GUI and shell access
Authored by: GlowingApple on Jan 03, '05 10:28:10AM
Rob, that looks right for Bash. I believe the command can also be shortened to just
export HOME=/usr/home/gadg
and it will have the same effect.


When Microsoft asks you, "Where do you want to go today?" tell them "Apple."

[ Reply to This | # ]

Use different home directories for GUI and shell access
Authored by: devwild on Jan 04, '05 12:54:32AM

Indeed, you can.

Alternative to this tip, you can also create a second user ("username-remote" perhaps) with the same UID. This allows you to set a seperate home directory and shell but have identical file access. This circumvents the ~username issue as well.

The drawback of course is double entry and (possibly) a second password to crack. The benefit is this user can also have a more secure password and with advanced configuration, have remote access while your GUI user does not. So, if you have a lazy password for your desktop login, it is not a vulnerability remotely.

This method is also used to allow root access to other people without giving them root passwords on some unix systems (the admins create a "root-username" account). Personally, I think it's silly and opening more holes, but others like the ability to strip someone's root access at a moment's notice and otherwise control access (but who's to say they didn't leave some other way to root your box? especially if they gave you reason to pull their rights)

Don't forget what you do if you go this route and always clean up after yourself.

[ Reply to This | # ]
A less invasive approach
Authored by: acdha on Jan 03, '05 02:27:41PM

Since I don't mind seeing Movies, Pictures, etc. when I'm using the command-line I simply use the SetFile utility (part of the developer tools) to make bin, lib, etc. invisible so the finder won't display them:

SetFile -a V bin lib man

[ Reply to This | # ]
Use different home directories for GUI and shell access
Authored by: gshenaut on Jan 04, '05 01:42:46PM

It's not clear to me why it's a problem to see /usr and so on in the finder. I sometimes have found it useful to use the finder in those directories. Perhaps it's a matter of aesthetics, in which case an alternate approach might be to give those directories the "darwin - hexley" icon, which would make it clear that those directories "belong" to darwin rather than to the GUI.

I tried this, and the only minor annoyance was that you have to first give yourself write permission on the target directories using whatever means you choose, and then put them back the way they were after adding the icon.

Greg Shenaut

[ Reply to This | # ]