Location of the root's home directory in macOS All Unix-like operating systems I've seen use /root as the home directory for the root account. What's the reason it was moved to /var/root in macOS? Can I change it to the usual /root?
I need to run some scripts on macOS which hardcode /root as the root's home directory. Also, I thought that /var was for variable data (spool, log files, etc.).
I think the problem is that you haven't really seen that many Unix-like operating systems. Traditionally with Unix-like operating systems, you would actually have the root user's home directory at /.

If you have worked with Linux or perhaps FreeBSD, you would expect the root user's home directory to be at /root - but it's not really "God-given".

There's plenty examples of Unix-like operating systems that use varying locations. For example on HP-UX systems you wouldn't blink an eye to find the home directory at /homeroot. Similarly on macOS it is at /var/root.

Regarding your assumption on the use of the /var folder: Traditionally there hasn't been any kind of hard consensus on what each of the traditional system folders are used for (for example /etc, /usr, /usr/local, /lib, /etc.). This might vary from operating system to operating system.

Usually you would say that the /var folder is for variable data - however that doesn't mean that it is limited to spool or log files, like you write. It means that the contents of the folder might change while using your system - in contrast to for example /bin, where traditionally you could assume that this folder could just be reinstalled from the original installation medium. In this sense the root user's home folders fits the description. You usually don't want it in /home or /Users as that could be a networked file system, and you traditionally wanted the root user to be able to always be able to login for system recovery.

On macOS you can change the location of the root user's home directory. For recovery purposes, change the location in /etc/passwd. For ordinary usage, change it in the Open Directory.

You can see the current settings with:

dscl . -read Users/root | grep NFSHomeDirectory


And change them with:

dscl . -change Users/root NFSHomeDirectory &lt;old&gt; &lt;new&gt;


where  and  are replaced with the relevant paths.