|

How To Use The Icacls Command In Windows (2027)

Icacls shows or changes who can open, edit or delete a file or folder from the command line.

The basic grant form is icacls <path> /grant <user>:F, and /T carries the change into every subfolder.

Every option below comes from Microsoft’s icacls reference, which lists Windows 11 and Windows 10 as supported.

Table of Contents

Icacls quick answers

I want toType this
Give a user full accessicacls <path> /grant <user>:F
Give a user modify accessicacls <path> /grant <user>:M
Block a usericacls <path> /deny <user>:F
Remove every entry for a usericacls <path> /remove <user>
Change the ownericacls <path> /setowner <user>
Reset permissions to the inherited defaultsicacls <path> /reset
Save permissions to a fileicacls <path> /save perms.txt /T

Replace the placeholders with your own path and account name, and put quotes around any path with a space.

What icacls does

Microsoft says icacls displays or modifies discretionary access control lists (DACLs) on files, and applies stored DACLs to files in a directory.

A DACL is the list of who may do what to an item.

The command replaces the older cacls command, which Microsoft marks as deprecated.

Open Command Prompt as administrator

  1. Press the Windows key and type cmd.
  2. Right-click Command Prompt and choose Run as administrator.
  3. Type your icacls command and press Enter.

The steps for an elevated window are in how to open Terminal as administrator.

The icacls syntax

Microsoft gives three forms: one to save, own, find, verify or reset, one to grant, deny or remove, and one to substitute or restore.

The first form is icacls name [/save aclfile] [/setowner user] [/findsid Sid] [/verify] [/reset] [/T] [/C] [/L] [/Q].

The second form is icacls name [/grant[:r] Sid:perm[...]] [/deny Sid:perm [...]] [/remove[:g|:d]] Sid[...]]] [/setintegritylevel Level:policy[...]] [/T] [/C] [/L] [/Q].

The third form is icacls directory [/substitute SidOld SidNew [...]] [/restore aclfile] [/C] [/L] [/Q].

Icacls options at a glance

OptionWhat it does
/TRuns the operation on all matching files in the current directory and its subdirectories.
/CContinues even if file errors occur, and still shows the error messages.
/LWorks on a symbolic link instead of its destination.
/QSuppresses success messages.
/save <ACLfile>Stores the DACLs of all matching files for later use with /restore.
/setowner <user>Changes the owner of all matching files to the user.
/findsid <sid>Finds files whose DACL explicitly mentions the SID.
/verifyFinds files with ACLs that are not canonical or have inconsistent lengths.
/resetReplaces ACLs with the default inherited ACLs.

Grant permissions to a user

Use /grant followed by the account, a colon and the permission code.

Microsoft’s example gives User1 Delete and Write DAC rights on a file with icacls test1 /grant User1:(d,wdac).

Without :r the permission is added to any explicit permissions already granted, and with /grant:r it replaces them.

  1. Open an elevated Command Prompt.
  2. Run icacls "C:\Data" /grant "User1:(OI)(CI)M" with your own folder and account.
  3. Add /T if you want the change applied to existing files and subfolders.

That folder command is built from Microsoft’s documented modify code and inheritance flags rather than copied from an example.

Basic permission codes

CodeAccess it gives
NNo access.
FFull access.
MModify access.
RXRead and execute access.
RRead-only access.
WWrite-only access.
DDelete access.

Pick the smallest code that does the job, such as RX for people who only need to open files.

Inheritance flags for folders

FlagMeaning
(I)The entry was inherited from the parent container.
(OI)Objects in this container inherit the entry, and it applies only to directories.
(CI)Containers in this parent container inherit the entry, and it applies only to directories.
(IO)Inherit only: the entry does not apply to the object itself, only to what it passes down.
(NP)Do not propagate: the entry does not pass on to nested containers.

Putting (OI)(CI) before the permission code is the usual way to make new files and subfolders pick up a folder’s permission.

Advanced permission codes

Advanced rights go in parentheses as a comma-separated list, as in (d,wdac).

  • DE is Delete and RC is Read control.
  • WDAC changes permissions and WO takes ownership.
  • RD reads data or lists a directory and WD writes data or adds a file.
  • AD appends data or adds a subdirectory, and X executes or traverses.
  • RA reads attributes and WA writes attributes.

Deny, remove and reset

Microsoft says /deny adds an explicit deny entry for the stated permissions and removes the same permissions from any explicit grant.

The /remove option deletes every occurrence of a SID from the DACL, and :g or :d limits it to granted or denied entries.

The /reset option replaces the ACLs with the default inherited ones.

Microsoft lists the order Windows keeps entries in as explicit denials, explicit grants, inherited denials, then inherited grants.

Save and restore permissions

Run icacls c:\windows\* /save aclfile /t to store the permissions of everything under a folder, which is Microsoft’s own example.

Restore them with icacls c:\windows\ /restore aclfile.

Saving a copy before a large change gives you a way back if the new permissions lock someone out.

Use a SID instead of a name

Microsoft says SIDs can be friendly names or numerical values, and numerical ones need an asterisk in front.

Its example is icacls TestFile /grant *S-1-1-0:(d,wdac).

Set an integrity level

The /setintegritylevel option adds an integrity entry to all matching files, with the level given as L for low, M for medium or H for high.

Microsoft’s example is icacls "myDirectory" /setintegritylevel (CI)(OI)H, which makes files and subdirectories inherit a high level.

Inheritance flags in front of the level apply only to directories.

Find and check files

Use /findsid to list files whose DACL explicitly names a security identifier, and /verify to find files with ACLs that are not canonical.

Microsoft also documents /inheritancelevel with e to enable inheritance, d to disable it and copy the entries, and r to disable it and remove only inherited entries.

Mistakes that stop icacls from working

  • Running it in a window that is not elevated.
  • Leaving out the colon between the account and the permission code.
  • Forgetting /T, so existing files below the folder keep their old permissions.
  • Using /deny on a broad group, since explicit denies come first in the order.
  • Changing permissions on system folders without a saved copy.

If the error says you do not own the item, take ownership first with the takeown command.

Change a folder’s permissions step by step

  1. Open an elevated Command Prompt.
  2. Save the current permissions with icacls <folder> /save perms.txt /T.
  3. Run icacls <folder> /grant <user>:(OI)(CI)M to give modify access.
  4. Open the folder as that user and confirm the access works.
  5. If something goes wrong, run icacls <parent folder> /restore perms.txt.

Related guides

For the Explorer route to the same problem, see how to fix folder access denied in Windows 11.

For changing file flags instead of permissions, see the attrib command guide.

Official sources

The options, codes and examples come from Microsoft’s icacls reference.

Leave a Reply

Your email address will not be published. Required fields are marked *