Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant permission to users for a directory using command line in Windows?

How can I grant permissions to a user on a directory (Read, Write, Modify) using the Windows command line?

like image 971
Amitabh Avatar asked May 28 '10 11:05

Amitabh


People also ask

How do I change permissions in CMD?

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.

How do I give someone Admin rights using CMD?

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.

How do I give permission to specific users?

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.


1 Answers

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 Control
  • CI = 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

like image 58
Călin Darie Avatar answered Oct 20 '22 10:10

Călin Darie