Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Change File Ownership on Windows and Linux

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Changing file ownership lets you transfer control of a file or folder to another user account. This is useful when you’re handing off projects, fixing permission errors, or managing a shared system. The process differs significantly between Windows and Linux, and you’ll need administrator or root access on both. This guide walks you through the standard methods for each operating system.

What You'll Need

  • An administrator account on Windows, or a sudo/root user on Linux.
  • The exact name of the user or group you want to make the new owner.
  • The full path to the file or folder (optional but helpful).
  • For Linux: a terminal window.
  • For Windows: the target drive must be NTFS (not FAT32 or exFAT) for ownership changes to stick.

Step-by-Step

On Windows (GUI Method)

  1. Right-click the file or folder and select Properties.
  2. Go to the Security tab, then click the Advanced button at the bottom.
  3. At the top of the Advanced Security window, you’ll see the current owner. Click Change next to it.
  4. In the “Enter the object name to select” box, type the username (e.g., jdoe) or group name, then click Check Names to validate it. Click OK.
  5. Check the box Replace owner on subcontainers and objects if you want to change ownership of all subfolders and files inside the folder.
  6. Click OK to apply. If you get a permission prompt, confirm it.
  7. Close the Properties window. The change is immediate.

On Windows (Command Line)

  1. Open Command Prompt or PowerShell as Administrator (right-click the Start button and choose “Windows Terminal (Admin)” or “Command Prompt (Admin)”).
  2. Use the takeown command to take ownership first. For a file:
    takeown /F "C:\path\to\file.txt"
    For a folder and everything inside it:
    takeown /F "C:\path\to\folder" /R
  3. Then use icacls to grant the new owner full control (optional but common):
    icacls "C:\path\to\file.txt" /grant jdoe:F
    For a folder recursively:
    icacls "C:\path\to\folder" /grant jdoe:F /T
  4. If you need to actually change the owner (not just take ownership), use:
    icacls "C:\path\to\file.txt" /setowner jdoe
    Add /T for folders to apply to all subitems.

On Linux (Command Line)

  1. Open a terminal.
  2. Check the current owner with:
    ls -l /path/to/file or ls -ld /path/to/folder
  3. Use the chown command to change ownership. For a single file:
    sudo chown username /path/to/file
  4. For a folder and all its contents (recursive), add the -R flag:
    sudo chown -R username /path/to/folder
  5. To change both user and group at once, use user:group:
    sudo chown username:groupname /path/to/file
  6. Verify the change with ls -l again.

Common Mistakes

  • Forgetting the -R flag on Linux: Without it, only the top folder changes, not the files inside.
  • Using the wrong username: On Linux, usernames are case-sensitive. On Windows, they usually aren’t, but the account must exist.
  • Not running as administrator/root: Both systems will reject the change with “Access Denied” if you lack privileges.
  • Confusing ownership with permissions: Ownership is about who controls the file; permissions (chmod or icacls) control what they can do. Changing owner doesn’t automatically grant read/write rights.
  • On Windows, trying to change owner on FAT32/exFAT drives: Those filesystems don’t support ownership. Convert to NTFS or use a different drive.
  • Using chown without sudo: Only root can change ownership on Linux. You’ll get “Operation not permitted.”

Tips

  • On Windows, if you only need to give another user access, consider adding them to the file’s permissions instead of changing ownership. That’s less disruptive.
  • On Linux, use chown -R carefully—applying it to system directories can break your OS. Only target user data or specific project folders.
  • Always verify ownership after the change using ls -l (Linux) or the Security tab (Windows).
  • If you’re handing off a project, also update the group on Linux to a shared group (e.g., sudo chown -R user:devteam project/) so teammates can collaborate.
  • On Windows, you can use whoami to see your current username, and net user to list all accounts.

Troubleshooting

  • “Access Denied” on Windows: Make sure you’re running the command prompt as Administrator. Also, if the file is in use, close any programs that might have it open.
  • “Operation not permitted” on Linux: You’re not root. Use sudo or log in as root. If sudo fails, check that your user is in the sudoers file.
  • Windows says “Unable to set new owner”: The account name might be wrong. Use the Check Names button in the GUI to verify. Also ensure the drive is NTFS.
  • Linux: chown succeeds but files still show old owner: If you used chown without -R on a folder, only the folder changes. Run chown -R to include contents.
  • Windows: Ownership changes but you can’t open the file: The new owner may not have permissions. Use icacls to grant them, e.g., icacls "file" /grant user:F.
  • Linux: You changed owner but can’t access the file: Check permissions with ls -l. The new owner needs read/write bits set. Use chmod if needed.

Frequently Asked Questions

Can I change ownership back to myself later?

Yes. On Windows, use the same steps with your username. On Linux, use sudo chown yourname file. As long as you have admin/root rights, you can always take ownership back.

What’s the difference between ownership and permissions?

Ownership defines who “owns” the file—typically the user who created it. Permissions define what actions (read, write, execute) are allowed for the owner, group, and others. Changing ownership doesn’t automatically change permissions.

Do I need to be root to use chown?

Yes. Only root can change file ownership on Linux. Regular users can change permissions on files they own, but not ownership. Use sudo to run chown.

Why does Windows show “TrustedInstaller” as owner?

System files are often owned by TrustedInstaller to protect them. To modify them, you need to take ownership first (using takeown or the GUI). Be cautious—changing system file ownership can cause instability.

Can I change ownership of a file on a network drive?

It depends on the server’s filesystem and your permissions. On Windows, the drive must be NTFS and you need admin rights on the server. On Linux, the drive must be mounted with appropriate options, and you need root on the machine where the drive is physically located.

What if I don’t know the exact username?

On Windows, use net user in Command Prompt to list accounts. On Linux, use cat /etc/passwd or getent passwd to see all users. You can also use the GUI’s “Check Names” button to validate.