Feb 7, 2012

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 /Users/username. Many scripts that I use search for files and directories using a full path (e.g. /home/username/Projects/project/usefuldata/data.csv.
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:

Reboot your Mac. Then, open a terminal and do the following, where username is your username

We are finished. /home/username is now an alias of /Users/username. You now ensure compatibility with previously, poorly written scripts and programs.

written by dgraziotin

Dr. Daniel Graziotin received his PhD in computer science, software engineering at the Free University of Bozen-Bolzano, Italy. His research interests include human aspects in empirical software engineering with psychological measurements, Web engineering, and open science. He researches, publishes, and reviews for venues in software engineering, human-computer interaction, and psychology. Daniel is the founder of the psychoempirical software engineering discipline and guidelines. He is associate editor at the Journal of Open Research Software, academic editor at the Research Ideas and Outcomes (RIO) journal, and academic editor at the Open Communications in Computer Science journal. He is the local coordinator of the Italian Open science local group for the Open Knowledge Foundation. He is a member of ACM, SIGSOFT, and IEEE.

Leave a comment