How can I grant permissions to a user on a directory (Read, Write, Modify) using the Windows command line?
To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( - ) the read, write, and execute permissions.
In the Administrator: Command Prompt window, type net user and then press the Enter key. NOTE: You will see both the Administrator and Guest accounts listed. To activate the Administrator account, type the command net user administrator /active:yes and then press the Enter key.
chmod o-rwx foldername To change directory permissions for everyone, use “u” for users, “g” for group, “o” for others, and “ugo” or “a” (for all). chmod ugo+rwx foldername to give read, write, and execute to everyone. chmod a=r foldername to give only read permission for everyone.
As of Vista, cacls is deprecated. Here's the first couple of help lines:
C:\>cacls NOTE: Cacls is now deprecated, please use Icacls. Displays or modifies access control lists (ACLs) of files You should use icacls instead. This is how you grant John full control over D:\test folder and all its subfolders:
C:\>icacls "D:\test" /grant John:(OI)(CI)F /T According do MS documentation:
F = Full ControlCI = Container Inherit - This flag indicates that subordinate containers will inherit this ACE.OI = Object Inherit - This flag indicates that subordinate files will inherit the ACE./T = Apply recursively to existing files and sub-folders. (OI and CI only apply to new files and sub-folders). Credit: comment by @AlexSpence.For complete documentation, you may run "icacls" with no arguments or see the Microsoft documentation here and here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With