How to add the /home/user folder in OS X, Linux style

H

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:

#
# 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.

/home/username

is now an alias of

/Users/username

. You now ensure compatibility with previously, poorly written scripts and programs.

About the author

dgraziotin

Dr. Daniel Graziotin is a senior researcher (Akademischer Rat) at the University of Stuttgart, Germany. His research interests include human, behavioral, and psychological aspects of empirical software engineering, studies of science, and open science. He is associate editor at the Journal of Open Research Software and academic editor at the Research Ideas and Outcomes (RIO) journal. Daniel was awarded an Alexander von Humboldt Fellowship for postdoctoral researchers in 2017, the European Design Award (bronze) in 2016, and the Data Journalism Award in 2015. He received his Ph.D. in computer science at the Free University of Bozen-Bolzano, Italy.

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Author

dgraziotin

Dr. Daniel Graziotin is a senior researcher (Akademischer Rat) at the University of Stuttgart, Germany. His research interests include human, behavioral, and psychological aspects of empirical software engineering, studies of science, and open science. He is associate editor at the Journal of Open Research Software and academic editor at the Research Ideas and Outcomes (RIO) journal. Daniel was awarded an Alexander von Humboldt Fellowship for postdoctoral researchers in 2017, the European Design Award (bronze) in 2016, and the Data Journalism Award in 2015. He received his Ph.D. in computer science at the Free University of Bozen-Bolzano, Italy.