When you first start the Cygwin shell, you are logged in as the user you are on Windows. How do you change just the username of that user, leaving the existing cygwin association of the Cygwin user with the Windows user? (i.e. without creating a whole new Windows account)
Why? I just moved over from a virtual machine to Cygwin and wish to reuse all my scripts and shell customizations which assume a specific username (think of .ssh/config, .subversion, etc.) without change.
My original username was root
(under Windows, ironically), and I wanted it to be someuser
. I figured I'd want my home dir to be /home/someuser
as well, and be readable from Windows.
This is what I did:
cd /home
mv root someuser
ln -s someuser root
sed -e 's/^root/someuser/' -e 's/\/home\/root/\/home\/user/' -i /etc/passwd
And that's all, just restart the shell.
I made the symlink in case Cygwin updates /etc/passwd
for some reason, and restores the username to root
and its home dir to /home/root
, so that it is still possible to log in.
(To only change the username: sed -e 's/^root/someuser/' -i /etc/passwd
)