Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As part of installing EGit, I had to set a HOME environment variable in Windows. This caused a problem whereby cygwin considers the HOME environment variable in Windows more important than the value in /etc/passwd. As a result, cygwin thinks my HOME directory in cygwin has moved from its previous location to my Windows user profile folder. I'd rather keep my cygwin files separate as my user profile folder is cluttered enough already but it doesn't seem to be possible to do so.

Is there any way to have cygwin use the value from /etc/passwd instead of the HOME enviroment variable?

share|improve this question

Edit /etc/profile and change the lines

# Set the user id
USER="$(id -un)"


# Set the user id
USER="$(id -un)"

# Set user home dir
HOME=$(eval echo "~$USER")

This forces Cygwin always to use the value from /etc/passwd. This is better than using Cygwin.bat because this applies to all login shells, no matter how they're spawned.

share|improve this answer
Alternatives: HOME=$(awk -F: "/^$USER:/ { print \$6 }" /etc/passwd) or HOME=$(eval echo "~$USER") – Keith Thompson Jun 4 '13 at 22:01
Your cat is unnecessary; you can change cat /etc/passwd | fgrep "$USER" to fgrep "$USER" /etc/passwd. Also, your command can misbehave if your user name happens to appear elsewhere in /etc/passwd, perhaps as part of another user name or of some other field. – Keith Thompson Jun 4 '13 at 22:03
Answer updated to use the HOME=$(eval echo "~$USER") method. That's really cool, thanks. – Lily Finley Jun 4 '13 at 23:32

The cygwin.bat file generally used to start the Cygwin shell can be modified to do whatever you need with HOME. You could try:

set HOME=

This should, based on documentation and experience, actually UNset %HOME% so that cygwin does not see it. As cygwin will default to setting up $HOME as the value in /etc/passwd (if HOME is not set in the parent process from which it inherits the environment), you should then get the result you want.

Notice please that I am stating that

set HOME=

actually removes HOME from the set env variables; not, as one might expect, the alternative result of setting HOME to the null string (but leaving it hanging around in the environment).

share|improve this answer

Here are a couple of things you can try:

  1. Edit cygwin.bat and set HOME= to whatever dir you want.

  2. Edit /etc/profile (C:\cygwin\etc\profile) and change cd "${HOME}" to whatever dir you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.