How to Restore NTFS Permissions on a folder & files, Backup or Copy

Some Time when playing around with share folder. Wrong click can destroy the hole sub-tree of folder permissions allowing UN-authorise users access to sensitive folders. you can restore the NTFS permissions with build in tool call ICALCS and you can manage the NTFS with it . To see NTFS permissions (D:\temp = example directory) :

D:\>icacls D:\temp
D:\temp BUILTIN\Administrators:(I)(F)
        BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
        NT AUTHORITY\SYSTEM:(I)(F)
        NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)
        NT AUTHORITY\Authenticated Users:(I)(M)
        NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(IO)(M)
        BUILTIN\Users:(I)(RX)
        BUILTIN\Users:(I)(OI)(CI)(IO)(GR,GE)

Successfully processed 1 files; Failed processing 0 files

The command will return a list of users and groups that have been assigned access permissions. Permissions are specified using abbreviations

  • F – full access
  • – modify access
  • RX – read and execute access
  • R – read-only access
  • W –write-only access
  • D – delete

Inheritance rights are specified before access permissions (inheritance permissions are applied only to folders):

  • (OI) – object inherit
  • (CI) – container inherit
  • (IO) – inherit only
  • (I) – inheriting permissions from parent container

With ICACLS you can add, remove or change permissions,for example to grant the user john read and execute permissions :

icacls D:\temp /grant pc\john:RX

You can even use the ICACLS to change ownership of a file or folder :

icacls 'D:\temp' /setowner PC\john /T /C /L /Q

To Back up NTFS permissions and this could be running also on the root directory :

icacls D:\temp /save c:\backup\d-temp_perms.txt /t /c

Note/t key is used to get ACLs for all subdirectories and files, /c allows to ignore access errors. By adding /q option, you can disable the display of information about successful access to the file system objects. Depending on the number of files and folders, the export of permissions can take quite a long time .

To restore the NTFS permissions with ICACLS :

icacls D:\ /restore c:\backup\d-temp_perms.txt /t /c

Note. Please, note that when importing permissions from the file, you should specify the path to the parent directory instead of the folder name.

in case you need to reset the folder permission to default :

icacls D:\temp /reset /T /Q /C

More information can be found here :

How to Set, Copy, Export or Restore NTFS Permissions Using iCACLS? | Windows OS Hub (woshub.com)

Good Luck

Leave a Reply

Your email address will not be published.