Skip to content

Instantly share code, notes, and snippets.

@MarcHeiden
Created April 19, 2023 17:32
Show Gist options
  • Save MarcHeiden/e8da1afc8b5b1fb078fbe75297c9a328 to your computer and use it in GitHub Desktop.
Save MarcHeiden/e8da1afc8b5b1fb078fbe75297c9a328 to your computer and use it in GitHub Desktop.

Reset NTFS file permissions with icacls and takeown

  1. Save file permissions in a txt file to be able to restore them if something went wrong:

    > icacls <path> /save <txtFilePath> [/t] [/c] [/l]

    Permissions can be restored with /restore:

    > icacls <path> /restore <txtFilePath> [/c] [/l]
  2. Get ownership of the files if needed:

    > takeown /f <path> [/r]
  3. Reset file permissions:

    > icacls <path> /reset [/t] [/c] [/l]
  4. Set new onwer for files if needed:

    > icacls <path> /setowner <user|group> [/t] [/c] [/l]

Options

Option Description
/t, /r Performs operation recursively on all files in the specified directory and subdirectories.
/c Skips errors, error message is still displayed
/l Performs operation on a symbolic link instead of its destination.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment