brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: icacls /save backs up Windows folder permissions before you change them

Windows
~/tips/tip-windows-icacls-save-restore

icacls D:\Share\* /save D:\acl-backup.txt /t

Saves the permissions of a folder tree to a file, so you can restore them after a mistake.

Changing permissions on a shared folder in Windows is one wrong click away from locking people out. icacls can save the current state first.

icacls D:\Share\* /save D:\acl-backup.txt /t

/save stores the ACLs of all matching files in a file for later use with /restore, and /t includes everything in the subfolders. If things go wrong:

icacls D:\Share\ /restore D:\acl-backup.txt

Note the difference: the docs say /restore needs the directory, not the wildcard.

To look at permissions, icacls D:\Share on its own shows the current ACL. To give a user modify rights on a folder and everything below it:

icacls D:\Share /grant alice:(OI)(CI)M

M is modify access, and (OI)(CI) are the inheritance flags that make it apply to files and subfolders. Use /grant:r to replace a user’s existing explicit rights instead of adding to them.

Caveats. Keep the backup file outside the folder you are changing. /reset /t replaces the ACLs with the default inherited ones for everything below, which is a quick way to undo a mess and also to throw away rights you meant to keep, so save first. icacls replaces the old cacls command, so ignore guides that still use that one.

Further reading: icacls on Microsoft Learn

More Windows tips Win+Ctrl+C Win+Shift+Left arrow Win+Ctrl+Left arrow Alt+PrtScn Left Alt + Left Shift + Print Screen All Windows tips (33) All topics

Link