Search code examples
windowscygwinportable-applications

Using only one user in cygwin


I installed Cygwin on USB stick. I'm going to use Cygwin on two computers. (My laptop and a desktop computer.)

Unfortunately, those two computer have a different user name. (user and ryang). So every time I switch those two computers, the location of user's home directory chages.

If I use Cygwin with ryang, the home directory is /home/ryang. If I use Cygwin with user, the home directory is in /home/user. But I want to use only one user, "sohnryang".

I don't want to change those two computer's settings. Any good solution for this?


Solution

  • The problem is not just that the two users are different for Cygwin, they are also different from Windows point of view.

    To rename a cygwin user you can use the file /etc/passwd

     mkpasswd -c > /etc/passwd
     sed -e "s/ryang:/sohnryang:/g" -i /etc/passwd
    

    and you can repeat it in the second computer

     mkpasswd -c >> /etc/passwd
     sed -e "s/user:/sohnryang:/g" -i /etc/passwd
    

    so now both will share the same cygwin name. The : is needed to change only the first and sixth fields; leaving untouched the fifth.

    However the two users are different also for Windows as you can verify with

    C:\Users\myself>whoami /user    
    USER INFORMATION
    ----------------
    User Name            SID
    ==================== =============================================
    my_computer\myself   S-1-5-21-531030479-1339336681-3415091201-1009
    

    The two SID's are different in the two computer also if the user names were the same in Windows. The Windows User Name and SID are merged in the 5th field of /etc/passwd

    The SID difference could cause authorization issue between files created on the two computer, depending on the type of system. Windows Home versions are usually more puzzling than Professional ones.