Starting with Cygwin 1.7.34, the recommended way to do this is to add a custom db_home
setting to /etc/nsswitch.conf
. A common wish when doing this is to make your Cygwin home directory equal to your Windows user profile directory. This setting will do that:
db_home: windows
Or, equivalently:
db_home: /%H
You need to use the latter form if you want some variation on this scheme, such as to segregate your Cygwin home files into a subdirectory of your Windows user profile directory:
db_home: /%H/cygwin
There are several other alternative schemes for the windows
option plus several other %
tokens you can use instead of %H
or in addition to it. See the nsswitch.conf
syntax description in the Cygwin User Guide for details.
If you installed Cygwin prior to 1.7.34 or have run its mkpasswd
utility so that you have an /etc/passwd
file, you can change your Cygwin home directory by editing your user’s entry in that file. Your home directory is the second-to-last element on your user’s line in /etc/passwd
.¹
Whichever way you do it, this causes the HOME
environment variable to be set during shell startup.²
See this FAQ item for more on the topic.
Footnotes:
- Consider moving
/etc/passwd
and/etc/group
out of the way in order to use the new SAM/AD-based mechanism instead. - While it is possible to simply set
%HOME%
via the Control Panel, it is officially discouraged. Not only does it unceremoniously override the above mechanisms, it doesn’t always work, such as when running shell scripts viacron
.