how to add the /home/user folder in os x, linux style
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
. 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.
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.
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
path, in order to be able to write into it.
Open the file
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 /Network/Servers -fstab /- -static
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.
is now an alias of
. You now ensure compatibility with previously, poorly written scripts and programs.
I do not use a commenting system anymore, but I would be glad to read your feedback. Feel free to contact me.