Safely change home directory

前端 未结 12 2327
南旧
南旧 2020-12-12 10:22

I\'m trying to safely update the home directory as specified in /etc/passwd, but the standard Linux utils - usermod and vipw - for doing so aren\'t provided by

12条回答
  •  抹茶落季
    2020-12-12 10:59

    Using Windows Environment Variable: HOME

    This works for me for a permanent, non-portable, non-network solution; i.e. setting the HOME Environment variable permanently in Windows.

    Note that this doesn't affect ssh or telnet sessions which always refer to /etc/passwd

    ref: Setting up Cygwin- My HOME environment variable is not what I want.

    CMD

    For current user (needs to run once per user)::

    reg add HKCU\Environment /v HOME /t REG_EXPAND_SZ /d ^%USERPROFILE^%
    

    For new Users:

    reg add HKU\.DEFAULT\Environment /v HOME /t REG_EXPAND_SZ /d ^%USERPROFILE^%
    

    Note: Carets ^ before percent-signs %

    IMPORT REG FILE

    Import this reg file (current user):

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Environment]
    "HOME"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
      00,45,00,25,00,00,00
    

    For new users:

    Windows Registry Editor Version 5.00
    
    [HKU\.DEFAULT\Environment]
    "HOME"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
      00,45,00,25,00,00,00
    

    REGEDIT

    In Regedit, under:

    For current user:

    HKEY_CURRENT_USER\Environment
    

    For new Users:

    HKU\.DEFAULT\Environment
    

    Create HOME as a new Expandable String Value (*REG_EXPAND_SZ*) and put in %USERPROFILE%

提交回复
热议问题