How do I specify chmod 744 in Powershell?

70,416

Give this a shot and see if this does what you're trying to accomplish. I always run these explicitly so one for setting the Owner, one for Full Control, one for Read-only, and one for Read and Execute.

This way you can do it for a specific file and for a specific user or group where applicable. Just plug in your file names, etc.

Sample ICACLS commands to set owner, grant full control, read-only, and read plus execute access (You may need to run the command prompt as administrator with these commands)

::Set Owner of a specific file
ICACLS "D:\test\test.txt" /setowner "administrator"

::Grant Full Control
ICACLS "D:\test\test.txt" /grant:r "administrator:(F)" /C

::Grant Read and Execute Access of a specific file
ICACLS "D:\test\test.txt" /grant:r "users:(RX)" /C

::Grant Read-only Access of a specific file
ICACLS "D:\test\test.txt" /grant:r "users:(R)" /C
Share:
70,416

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    Community over 1 year

    I know that I can use icacls to specify the permission on the file, and from What is the equivalent of chmod 777?, I can use

    icacls myfile.txt /grant Everyone:F
    

    But how do I set an equivalent for chmod 744? I think I can use /grant:____:R for just read access, but I'm not sure how to specify the owners and the group permissions as simply as with chmod. When I try this:

    icacls myfile.txt /grant Owner:F Group:R Everyone:R
    

    I receive an error, "No mapping between account names and security IDs was done." I'm probably missing something obvious, any ideas?

    When I try:

    icacls myfile.txt /grant Administrator:F /grant:r Users:R
    

    I take a look at the file in Explorer and it has given Administrator "Special Permissions" (rather than Full Control) and gives Users "Read & execute, Read, and Special Permissions."

    • Admin
      Admin over 8 years
      If you specifically want 744, you might as well skip group permissions (not applicable on Windows anyway) altogether because they’re already covered with “Everyone” permissions.