Subscribe to feed Viewing entries tagged Cygwin

Cygwin home directories

Posted by Terry Moore
Terry Moore
User is currently offline
on Saturday, 04 July 2015
in Useful Tips

I recently installed some new tools from a third party, and had to update my Cygwin installation.  There is no official version of the overall release (see the FAQ); but I was running a release from November 2014, or so, and I updated today (July 4).

After the update, my Cygwin home directory had changed, and wasn't what I wanted.

Summary: if your Cygwin home directory is wrong after an update, you need to look at /etc/nsswitch.conf, not /etc/passwd.

Here are the details.

After I updated, my home directory was a different place than before. I recognized this immediately because the prompt changed from

bash:redacted::~ $


terry@redacted ~

And of course, all the other settings from my .bashrc were not taking effect.

In my setup, for historical reasons, my home directory is "c:\usr\terry" -- I've been running this setup since Windows NT days, and it's been nice not having a name that changed based on the Windows version in use. I use the same home directory for Cygwin and Windows.

Also for historical reasons, I have let Windows continue to assign whatever it felt like for a home directory. On my current Win8.1 machine, that's "c:\users\terry".

In the old version of Cygwin, this was accomplished by editing the /etc/passwd file (as on Unix). My passwd file contains the following line:


In previous versions of Cygwin, this was all that was needed; when I launched a Cygwin window, bash found my .bashrc file in c:usrterry, and things proceeded as I expected.

After I updated to the version including Cygwin 2.0.4, this no longer worked. Cygwin was not honoring the contents of /etc/passwd.

I'll omit a discussion of the things I tried. It turns out that, by default, the newer versions of Cygwin no longer use /etc/passwd.  Instead, there's a new mechanism, /etc/nsswitch.conf, based on a similar mechanism from Linux. This page has all the details.  Search for nsswitch.conf, and don't worry too much about all the AD and SAM stuff; I was able to ignore it.

In order to get my home directory setup working again, I added the following to /etc/nsswitch.conf:

db_home: /cygdrive/c/usr/%U

%U is expanded to the current user's Windows login name (terry in my case).

The following setting is similar and useful, but it don't do what I want.

db_home: windows

It doesn't do what I want, because it uses the Windows home directory, which is c:\users\terry. This causes my home directory to be /cygdrive/c/Users/terry, which isn't the place I want. (Something like this might be good for other people, however, which is why I mention it.)

(Updated 2015-09-06: add some missing backslashes, make one-page article.)

Was this post useful to you? Want to see more on some topic? Leave a comment, or find me on Twitter (@TmmMcci) or LinkedIn (

Hits: 2319 0 Comments
0 votes
Legal and Copyright Information