How to change user name on Cygwin

9

2

When I first installed and ran Cygwin, my username and PC name appeared at the beginning of the prompt, like

Johm@John-PC ~

The problem is, there was a typo in the account name when I first installed Windows 7 and it still remains in Cygwin.

I changed the Windows account name, changed the corresponding folder name and corrected the relevant registry (Local Machine->Microsoft->Windows NT->Current Version->profile list). Then I deleted Cygwin, including its registries, re-downloaded it, and installed it again.

But the old wrong user name still remains. How can I correct this?

user67275

Posted 2013-05-20T01:32:27.187

Reputation: 1 248

This answer on StackOverflow should help: http://stackoverflow.com/questions/225764/safely-change-home-directory-in-cygwin.

– boot13 – 2013-05-20T09:38:12.927

Answers

11

Try editing the /etc/passwd file, the username can be changed in the first field. Avoid using spaces in the name

user202670

Posted 2013-05-20T01:32:27.187

Reputation:

7I had to mkpasswd > /etc/passwd and then edit the line beginning with my firstname to match the desired cygwin username. It was my firstname because on Windows 10, I used a microsoft account as my windows login. – stevesliva – 2015-10-14T05:35:13.907

Could you tell me how can I edit /etc/passwd file? I'm not familiar with cygwin commands – user67275 – 2013-05-21T08:08:24.003

1I believe you would type nano /etc/passwd (you must run Cygwin as an administrator) and you would edit it from the command line. Then you press CTRL + X, then Y and finally the enter key to save it. – None – 2013-05-21T10:29:48.257