As owner of a Macbook Pro, I sometimes make the sad decision to switch back to OS X from GNU/Linux because of many issues that will not be listed here. The first thing I miss when using the Terminal and various scripts is the fact that the default path for the home directory in Mac OS X is
/Users/username. Many scripts that I use search for files and directories using a full path (e.g.
Bash has the special character ~ for referring to the user’s home directory; Python has os.path.expanduser(“~”). Today I found issues for some R scripts that I am using for my thesis.
Honestly, I can not remember all the commands to refer to the Home directory from any programming language, especially if I am sure that the scripts will always used by me on my machine.
We will now see how to symlink our Home directory under /home, for better compatibility when switching back to OS X from GNU/Linux.
The /home directory exists in OS X but it is not writable because of the presence of a service which is able to mount directories under given paths. /home is reserved by its configuration file. If you do not need such services (I have never needed them), we can disable them just for the /home path, in order to be able to write into it.
Open the file /etc/auto_master with your favorite text editor and comment the /home line, so it will look like as follows:
# Automounter master map
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
#/home auto_home -nobrowse,hidefromfinder
Reboot your Mac. Then, open a terminal and do the following, where username is your username
sudo ln -s /Users/username /home/username
We are finished. /home/username is now an alias of /Users/username. You now ensure compatibility with previously, poorly written scripts and programs.