Firstly, set a Windows environment variable for HOME that points to your user profile:
- Go to Control Panel --> System and Security --> System (or press the [WINDOWS]+PAUSE|BREAK] keys)
- Click Advanced system settings (located at the left)
- Click Environment Variables (toward the bottom)
- In the User Variables area click "New…"
- For Variable name enter HOME
- For Variable value enter
%USERPROFILE%
- Click OK in all the open dialog boxes to apply this new setting
Now we are going to update the Cygwin /etc/passwd
file with the Windows %HOME%
variable we just created. Shell logins and remote logins via ssh
will rely on /etc/passwd
to tell them the location of the user's $HOME
path.
At the Cygwin bash command prompt type the following:
cp /etc/passwd /etc/passwd.bak
mkpasswd -l -p $(cygpath -H) > /etc/passwd
mkpasswd -d -p $(cygpath -H) >> /etc/passwd
The -d
switch tells mkpasswd to include DOMAIN users as well as LOCAL machine users. This is important if you're using a PC at work where the user information is obtained from a Windows Domain Controller.
Now, do the same for groups by executing the following:
cp /etc/group /etc/group.bak
mkgroup -l > /etc/group
mkgroup -d >> /etc/group
Now, exit Cygwin and start it up again. You should find that your HOME path points to the same location as your Windows User Profile -- i.e. /cygdrive/c/Users/username