I just installed Cygwin, and it looks like the home directory in the bash prompt is on my Z: drive. That’s not where I want it.
How can I change this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Starting with Cygwin 1.7.34, the recommended way to do this is to add a custom
db_homesetting 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:Or, equivalently:
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:
There are several other alternative schemes for the
windowsoption plus several other%tokens you can use instead of%Hor in addition to it. See thensswitch.confsyntax description in the Cygwin User Guide for details.If you installed Cygwin prior to 1.7.34 or have run its
mkpasswdutility so that you have an/etc/passwdfile, 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
HOMEenvironment variable to be set during shell startup.²See this FAQ item for more on the topic.
Footnotes:
Consider moving
/etc/passwdand/etc/groupout 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.