Can't remove deleted user from file permissions by command

Abstract: Resolve orphaned NTFS permissions for deleted users by removing specific SIDs using the icacls command.

Created: 2026-09-25 by
You can remove a deleted user from NTFS file permissions by using the icacls command with the /remove flag and the specific Security Identifier (SID) instead of the username. This approach bypasses the need for Active Directory resolution, allowing you to clean up orphaned access control entries directly through the command line or PowerShell on Windows systems.

Understanding Orphaned Permissions

When a user account is deleted from a domain or local machine, the files they owned or had access to retain the original Access Control Entry (ACE). The operating system cannot resolve the username because the account no longer exists in the directory service. Consequently, standard graphical tools often display the SID as a string of numbers and letters, or simply fail to load the permission dialog because the identity is unresolvable.

This situation creates "orphaned" permissions that clutter your security settings and can complicate auditing processes. While you might see warnings about inaccessible accounts when browsing properties, the underlying issue is that the ACL (Access Control List) still references an invalid principal. Removing these entries requires addressing the unique identifier rather than the human-readable name.

Identifying the Problematic SID

The first step is to identify the exact Security Identifier associated with the deleted user. You can view this information using the icacls tool from the command prompt. Navigate to the affected directory and run the following command to list all permissions:

icacls "C:\Path\To\Folder" /T /Q

Look for entries that resemble S-1-5-21-... followed by a long numeric string. These are the SIDs of the deleted users. If you have many files, the output will be extensive, so it helps to filter the results. You can use PowerShell to extract only the lines containing the specific SID pattern if you know part of the identifier. Alternatively, check the Event Viewer under Security logs for events related to denied access, which may sometimes provide context, though direct inspection of the ACL is more reliable.

Removing Permissions via Command Line

Once you have identified the SID, you can use the icacls command to remove the ACE. The syntax requires specifying the target path, the /remove parameter, and the SID itself. It is crucial to use the full SID string without any prefixes like DOMAIN\ since the domain reference is invalid for a deleted account.

icacls "C:\Path\To\Folder" /T /remove S-1-5-21-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX-XXXXXX

In this command, /T ensures that the operation applies recursively to all subdirectories and files within the specified folder. The /remove flag tells icacls to delete the matching ACE entirely. If you do not use /T, only the top-level folder's permissions will be updated, leaving the rest of the structure with the orphaned entries. Always test this on a non-critical folder first to ensure the syntax works correctly for your environment.

PowerShell Alternative

For administrators who prefer scripting or need to handle multiple folders, PowerShell offers a robust alternative using the Get-Acl and Set-Acl cmdlets. However, manipulating ACLs programmatically requires loading the existing ACL, removing the specific access rule, and then applying the modified ACL back to the object. This method is more verbose but provides greater control over error handling and logging.

You can retrieve the ACL for a file, iterate through the access rules, find the one matching the orphaned SID, remove it from the collection, and then save the changes. This approach is particularly useful when you need to audit the changes before committing them or when dealing with complex inheritance scenarios that icacls might handle differently. For more details on managing permissions across different environments, consider reviewing our guide on NTFS Permissions on Multi-OS Volumes.

Verifying the Cleanup

After executing the removal command, verify that the orphaned permissions have been successfully deleted. Run the icacls command again on the same directory and confirm that the SID no longer appears in the output. If the entry persists, it is possible that the file has additional hardlinks or that the change was not applied recursively due to permission errors on specific subfolders.

If you encounter issues where files appear locked or inaccessible during the cleanup process, it may be due to other services holding handles to those files. In such cases, refer to resources on resolving folder in use errors to ensure that no background processes are interfering with the permission modification. Successful removal should result in clean ACLs that only contain active, resolvable user accounts and groups.

Frequently Asked Questions

Why does the GUI show a long number string instead of a name?

The graphical interface displays the raw Security Identifier (SID) because it cannot resolve the username to a known account in Active Directory or the local SAM database. This happens automatically when the linked user object is deleted, leaving the permission entry orphaned. You must use the SID string to manage these permissions effectively.

Can I remove orphaned permissions using the Properties dialog?

While you can open the Security tab in the Properties dialog, editing these entries is often difficult or impossible because the UI expects a resolvable identity. Attempting to edit the field may result in errors or require manual SID entry, which is prone to typos. Using the command line is the recommended and more reliable method for bulk removal.

What happens if I remove the wrong SID?

Removing an incorrect SID will revoke access for the corresponding user or group, potentially causing legitimate users to lose permissions to critical files. Always double-check the SID against your records or event logs before executing the remove command. It is advisable to take a backup of the ACL using icacls /save before making widespread changes.

Does this fix apply to shared network folders?

Yes, the icacls command modifies the underlying NTFS permissions, which are separate from Share permissions. Removing an orphaned NTFS entry will clean up the security descriptor regardless of whether the folder is shared. However, you should also check Share permissions to ensure there are no conflicting access rules at the network level.

How do I restore permissions after accidental deletion?

If you accidentally remove valid permissions, you can restore them from a backup created with icacls /save. Use the icacls /restore command with the backup file to revert the ACLs to their previous state. Without a backup, you may need to manually re-add the correct users or reset permissions to inherit from the parent directory.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More