The cleanest solution would be to change the C:\cygwin\etc\nsswitch.conf
file in the following way:
The %H variable represents the Windows home directory in POSIX style, so add it to the db_home:
line and uncomment the line.
Example:
# /etc/nsswitch.conf
#
# This file is read once by the first process in a Cygwin process tree.
# To pick up changes, restart all Cygwin processes. For a description
# see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
# Defaults:
# passwd: files db
# group: files db
# db_enum: cache builtin
db_home: /%H/home
# db_shell: /bin/bash
# db_gecos: <empty>
See this answer for more information on how to change Cygwin's defaults by editing the /etc/nsswitch.conf
file.
More info: the root directory /
is c:\cygwin
(or c:\cygwin64
on a 64-bit installation) by default, so everything exists under there. Changing the setting above will make a symlink in c:\cygwin\home
corresponding to your profile directory in Windows, usually c:\Users\<username>
referenced by the environmental variable %userprofile%
.
Edit: The last sentence isn't correct. What actually happens is that your home directory will change to /cygdrive/c/Users/<username>
One last useful tip: if you want to verify which directory you're in, relative to Windows' directory structure, you can run the following at the cygwin prompt:
explorer.exe .
(Note the .
) This opens up an explorer window in your current directory.
I think the simplest answer to your question is that you can navigate to any directory on any drive (i.e. C:
, D:
, etc) by replacing the drive letter with /cygdrive/<letter>
(i.e. C:\
can be accessed at /cygdrive/c
)