24 November 2025

Windows ICACLS and Permission Inheritance

When NTFS permissions get out of sync, one common culprit is broken inheritance. A folder (or file) has been set to “stop inheriting permissions” and now behaves differently from the rest of the tree. Last week I had to reset the inheritance on a folder and realized that it would be the perfect topic to write an article about. So, in this post, you’ll learn how to use the Windows icacls command to re‑enable inheritance on a single file, a single folder, or recursively on an entire folder tree, and the difference between ACLs and ACEs.

Understanding Windows ICACLS and Permission Inheritance

The Windows icacls command is a powerful tool to view, modify, and manage permissions (aka Access Control Lists – ACL) on files and folders. One common scenario in permission management is controlling inheritance — whether an object inherits permissions from its parent folder or maintains its own explicit permissions.

Inheritance ensures that permissions applied on a parent folder can automatically propagate to its child files and subfolders, simplifying administration. Sometimes, inheritance is disabled and needs to be re-enabled. In order to change the object’s inheritance you will need to run the commands below as an administrator, or with full ownership of the folders. Running the commands as a normal user may cause “Access is denied” errors, even if the commands are correct.

This table shows the icacls commands that are most commonly used. I highly encourage you to read the entire article to better understand what the commands are actually doing and see examples of how they are used. Remember, I am not responsible for the changes you make!

CommandsEffect on inheritanceEffect on inherited ACEs
icacls "Path"Displays permissions as they currently existDisplays permissions as they currently exist
icacls "Path" /save "SavePath"Saves permissions as they currently existSaves permissions as they currently exist
icacls "Path" /inheritance:eEnable inheritance on a file or folderStarts inheriting from parent again
icacls "Path" /inheritance:e /tEnable inheritance recursively on folders and subfolders with filesStarts inheriting from parent again
icacls "Path" /inheritance:dDisable inheritance but keep current permissions explicitlyConverts inherited ACEs into explicit ones
icacls "Path" /inheritance:rDisable inheritance and remove inherited permissionsRemoves inherited ACEs entirely

Viewing Current Permissions and Inheritance

Before changing anything, show the current ACL to confirm whether inheritance is disabled.

icacls "C:\ExampleFolder"

In the output:

  • Entries marked with (I) are inherited from a parent.
  • If you only see explicit entries and no (I) flags, inheritance is likely disabled on that object.

Example snippet you might see when inheritance is working:

C:\ExampleFolder  NT AUTHORITY\SYSTEM:(I)(F)
                  BUILTIN\Administrators:(I)(F)
                  CONTOSO\Domain Users:(I)(M)

If those (I) indicators are missing at this level while present higher up the tree, someone has broken inheritance on this folder or file.


 Backup ACLs Before You Touch Anything

Use “icacls /save” to capture your ACLs for rollback:

icacls "C:\ExampleFolder\Project" /save "C:\Temp\Project.acl" /t

That way, if anything goes wrong, you can restore the ACLs :

icacls "C:\ExampleFolder" /restore "C:\Temp\Project.acl"

Notice that if you are restoring ACLs on a subfolder, you restore the backup to a base folder that matches the stored paths. The name of actual .acl file can be anything you want or that makes sense for your environment.

With things backed up, now we’re ready to go make changes!


How to Re-enable Inheritance Using ICACLS

The icacls command supports three inheritance-related switches:

  • Enable inheritance (re-enable permission inheritance from the parent) — /inheritance:e
  • Disable inheritance and copy existing inherited permissions explicitly — /inheritance:d
  • Disable inheritance and remove only inherited permissions — /inheritance:r
  • Reset inheritance to permissions from its parent directory — /reset

To re-enable inheritance on a file or folder, you use:

icacls "FullPathToFileOrFolder" /inheritance:e

Replace “FullPathToFileOrFolder” with the actual path of the file or folder you are working with.


Examples for Different Scopes


Enable Inheritance on a Single Folder or File

To re-enable inheritance only on a specific folder:

icacls "C:\ExampleFolder" /inheritance:e

Use this when you only want to fix one folder and leave children unchanged. As existing explicit permissions remain unchanged unless they conflict with what the parent applies.

To re-enable inheritance only on a specific file:

icacls "C:\ExampleFolder\File.txt" /inheritance:e

This makes “File.txt” inherit permissions again from “C:\ExampleFolder” (and ultimately from higher levels). The file will pick up any ACEs that are configured to flow down to files (container/object inherit flags). You can re-run icacls against just the file to look for “(I)” entries to confirm inheritance is active again.


Enable Inheritance on a Folder and All Its Subfolders and Files

This is the “fix the entire tree” scenario, and is useful when someone clicked “Disable inheritance” on a top‑level folder and has created a real mess. To recursively enable inheritance to a folder, all its subfolders, and files, use the “/t” (traverse) and “/c” (continue on errors) flags:

icacls "C:\ExampleFolder" /inheritance:e /t /c

This command makes sure inheritance is restored on the folder, all contained subfolders, and files, even if some files generate errors during processing. On large folder trees, this can take some time; so you can combine “/c” with “/q” to quiet the output:

icacls "C:\ExampleFolder" /inheritance:e /t /c /q


When to Use “/inheritance:d” vs “/inheritance:r”

It’s worth briefly discussing the other switches so we know when and how to use them, even if they are used less commonly.​

  • /inheritance:d
    • Disables inheritance on the object.
    • Copies currently inherited ACEs as explicit entries, preserving the effective permissions at that moment.
  • /inheritance:r
    • Disables inheritance.
    • Removes all inherited ACEs from the ACL, potentially locking users out if you rely on parent permissions.

Reset Inheritance

Completely resetting inheritance is a powerful way to restore all of the default security settings on files and folders by resetting explicit ACLs back to the default ACLs inherited values from the parent folder object. This means any manually configured permissions will be removed, and the file/folder will inherit its’ permissions as if it were newly created in that location. It is commonly used to fix corrupted or undesired permissions by restoring the default inheritance and access settings.

icacls "C:\ExampleFolder" /reset /t /c /l

A couple things to know about using “/reset” is that you may need to take ownership first before resetting permissions, especially if access is denied. takeown /R /F "C:\ExampleFolder" And that resetting inheritance removes explicit permissions and can temporarily restrict access until the inheritance applies and you verify everything is correct. Depending on the size of your folder tree, this could take some time, so it’s better to perform this during off hours.


What are ACE and ACL?

An ACE (Access Control Entry) is an individual rule that defines the permissions granted or denied to a specific user or group (called a trustee) on a securable object like a file or folder. Each ACE contains crucial information such as a security identifier (SID) that identifies the trustee, an access mask specifying the allowed or denied rights (e.g., read, write, execute), and flags indicating whether the ACE applies to child objects through inheritance. ACEs control or audit access by specifying who can do what on an object and are the building blocks of ACLs.

An ACL (Access Control List) is a collection of ACEs associated with a securable object. It acts as an ordered list of these individual ACEs that collectively define the overall security policy for that object. For example, an ACL on a file might have several ACEs granting different users read or write permissions while denying others. There are two common types of ACLs:

  • Discretionary ACL (DACL), which explicitly allows or denies access
  • System ACL (SACL), which specifies audit rules for tracking access attempts

In short, the ACL is the overall list of permission entries, and each ACE within it is a discrete permission rule for a trustee on that object.

This relationship is fundamental in Windows NTFS security and is managed by tools like icacls, which modify the ACLs by adding, removing, or changing individual ACEs on files or folders.


Additional Notes

  • Be sure to run the Command Prompt as Administrator to have sufficient privileges.
  • The “/t” flag is essential for recursive application across all subfolders and files.
  • Use “/c” to prevent the command from stopping on errors, which is useful for large directories.
  • When inheritance is enabled, permissions from the parent folder’s ACL are applied automatically to children, marked with an “(I)” for inherited in permission listings.

Common Gotchas and Tips

  • Inherited vs explicit permissions: Even after turning inheritance back on, explicit ACEs can still override or add to inherited permissions, so the ACL may not look perfectly “clean.”
  • File‑only vs folder‑only inheritance: Flags like “(OI)” (object inherit) and “(CI)” (container inherit) control whether permissions flow to files, folders, or both, which explains why some files still differ.
  • Locked or in‑use files: Using “/c” ensures the command continues even if a file is locked; errors will still be reported in the console.
  • Combine with “takeown”: If a different owner prevents changes, scripts often pair “takeown” followed by “icacls /reset” or “/inheritance:e” to normalize problem trees.

I hope this guide and examples help you to understand how to use icacls to manage ACL inheritance on Windows systems effectively.

7 July 2024

Emptying a File Without Deleting it

Working in IT, there will be a day when you will need to purge a file on one of your systems. As an administrator, managing file sizes and content is crucial for maintaining the system performance and stability you require. Regardless of what you call it – emptying, clearing, wiping, purging; There are various reasons why you might want to clear a file without actually deleting it:

  1. Log Management: Logs can grow excessively large, consuming valuable disk space. Clearing logs without deleting them ensures continuity in logging.
  2. Data Reset: Some applications might require periodic resets while keeping the file structure intact.
  3. Error Resolution: Clearing files with erroneous or corrupted data can be a quick way to restore normal operations without affecting the file’s existence or permissions.

Here are nine methods to empty a file from the command line:

  1. Using the truncate Command:
    The truncate command can be used to resize files. Setting the size to zero effectively clears the file.
   truncate -s 0 file.txt

This command is straightforward and efficient for emptying a file while preserving its metadata.

  1. Using the echo Command:
    The echo command can output an empty string to a file, thereby clearing its contents.
   echo -n > file.txt

The -n option ensures that no newline character is added, leaving the file empty.

  1. Using Vim Editor:
    Vim, a powerful text editor, can also be used to clear a file.
    Open the file with vim.
    In Vim, type the following command to delete all lines:
vim file.txt
:1,$d 

This command deletes all lines from the first to the last line in the file.

  1. Using the dd Command:
    The dd command is useful for low-level data manipulation and can clear a file by reading from /dev/null.
   dd if=/dev/null of=file.txt

This reads from /dev/null and writes to file.txt, making it empty.

  1. Using the cp Command with /dev/null:
    The cp command can replace the file’s contents with the empty contents of /dev/null.
   cp /dev/null file.txt

This is an efficient way to clear a file while maintaining its attributes.

  1. Using the > Operator:
    The simplest method involves using the redirection operator to truncate the file.
   > file.txt

This method is quick and commonly used for clearing file contents.

  1. Using the cat Command:
    By redirecting the contents of /dev/null to the file, you can clear its contents.
   cat /dev/null > file.txt

This is another straightforward method to empty a file.

  1. Using the : (Colon) Command:
    The colon (:) is a built-in shell command that does nothing but return a true exit status. When combined with the redirection operator, it can clear a file.
   : > file.txt

This command is both simple and efficient for emptying files.

  1. Using the sed Command:
    The sed command can delete all lines in a file.
   sed -i d file.txt

The -i option tells sed to edit the file in place, and the d command deletes all lines.

Conclusion

Emptying files without deleting them is a common administrative task in Linux. Each of these methods allows you to clear file contents while preserving the file itself, along with its permissions and ownership. Whether you are managing log files, resetting data, or addressing errors, these commands provide efficient ways to handle files without removing them. The choice of method simply depends on your specific needs and the tools you are comfortable with. Hopefully this helps you somewhere in your day-to-day linux administration.

20 December 2019

File management – Cisco Flash

When working on Cisco devices, sometimes you have to delete files from the device. It’s moreless the same on all Cisco devices. While there are other file systems available to you on your device (see first command listed), Cisco devices use “flash:” as their default file system. My examples will also use the default “flash:” but note that the commands will work the same on any other available file system, such as “usb0:“.

Show Available File Systems
Device# show file systems

Show Files
Device# dir flash:

Create Directory
Device# mkdir folder

Step into Directory
Device# cd folder

Delete File
Device# delete /force flash:/filename
Device# delete flash:/filename

Delete Directory
Device# delete /force /recursive flash:/folder

Copy File
Device# copy usb0:[/directory]/filename flash0:[/directory]/filename

Category: Cisco | LEAVE A COMMENT