You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于通过文件系统修改Windows用户名及修复登录故障的技术咨询

通过文件系统修改Windows用户名及修复登录故障的技术咨询

Hey there, sorry to hear you hit this frustrating roadblock after changing your Windows username. Since you’ve got Linux dual boot access to your Windows filesystem, we can get you back in without too much hassle—let’s walk through the options step by step.

First: Mount your Windows system partition

Before making any changes, you need to properly mount your Windows NTFS partition in Linux:

  1. Open a terminal and create a mount point:
    sudo mkdir -p /mnt/windows
    
  2. Identify your Windows system partition (it’s usually the largest NTFS partition). List all partitions to find it:
    lsblk
    
    Look for a partition labeled Windows or with a TYPE of ntfs (common examples: /dev/sda2 or /dev/nvme0n1p2).
  3. Mount the partition (replace /dev/sdXn with your actual partition path):
    sudo mount -t ntfs-3g /dev/sdXn /mnt/windows
    

Option 1: Reset the user password (quickest fix)

The easiest way to regain access is to clear the password for the account showing up on the login screen. We’ll use chntpw—a tool for editing Windows registry and password databases (most Linux distros have it pre-installed; if not, install it with your package manager, e.g., sudo apt install chntpw for Debian/Ubuntu):

  1. Navigate to the Windows config directory:
    cd /mnt/windows/Windows/System32/config/
    
  2. List all user accounts to confirm the one you need (the old username showing at login):
    sudo chntpw -l SAM
    
    You’ll see a list of users with their unique RIDs and display names.
  3. Select the target user to edit (replace OldUsername with the name from the login screen):
    sudo chntpw -u "OldUsername" SAM
    
  4. A menu will appear—choose option 1 to clear the user’s password (set it to blank).
  5. Press q to exit the editor, then type y to save your changes.

Now reboot into Windows, and you’ll be able to log in without entering a password. Once inside, you can safely adjust the username back to your preferred setting through Windows’ built-in user account settings.

Option 2: Change the username back directly via the filesystem

If you want to revert the username before logging back into Windows, you’ll need to update both the user account database and the profile path registry entry:

  1. Follow the steps above to mount the Windows partition and list users with chntpw -l SAM.
  2. Edit the target user’s name in the SAM database (replace CurrentUsername with the new username you tried to set):
    sudo chntpw -u "CurrentUsername" SAM
    
    In the menu, choose option 3 to change the user name, then enter the old username that appears on the login screen. Save and exit as before.
  3. Next, update the profile path to match the old username:
    • Navigate to the ProfileList registry section:
      cd /mnt/windows/Windows/System32/config/
      sudo chntpw -e SOFTWARE
      
    • Use the cd command in the chntpw editor to navigate to:
      Microsoft\Windows NT\CurrentVersion\ProfileList
      
    • List the subfolders here (these are user SIDs) with ls. Find the SID corresponding to your user (cross-reference with the RID from the SAM list—the RID is the last part of the SID).
    • Enter that SID folder with cd <SID>, then use ed ProfileImagePath to edit the path. Change it from C:\Users\CurrentUsername to C:\Users\OldUsername.
    • Save and exit the editor.

After these changes, reboot into Windows, and you should be able to log in with your old username and original password.


备注:内容来源于stack exchange,提问作者Shalom Alecheim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 08:04:51