Windows change access permissions from the command line

by LinuxTitli on April 11, 2006 · 13 comments

Linux and Unixish system comes with chmod and other commands to setup/change access permission from command line/shell.

However, when it comes to windows chmod is not available. Windows comes with a special command line utility called CACLS.

You can use it as follows:
CACLS files /e /p {USERNAME}:{PERMISSION}

Where,

  • /p : Set new permission
  • /e : Edit permission and kept old permission as it is i.e. edit ACL instead of replacing it.
  • {USERNAME} : Name of user
  • {PERMISSION} : Permission can be:
    • R - Read
    • W - Write
    • C - Change (write)
    • F - Full control

For example grant Rocky Full (F) control with following command (type at Windows command prompt):

C:> CACLS files /e /p rocky:f

Read complete help by typing following command:

C:> cacls /?

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 13 comments… read them below or add one }

1 Top Coder - Ankit Baphna November 13, 2008

You can use *.* in place of files to change access mode of multiple files at a time.

Reply

2 Alex May 16, 2009

Super dude.. i got in a right time.. thanks for your contribution and sharing of knowledge..keep doing..

Reply

3 J. February 5, 2010

/T is a very nice switch in case of an entire drive’s permissions getting messed up. Recursion ftw?

Reply

4 Guarantor Loans August 8, 2010

Life saver! Just used this after having problems with explorer! worked a treat! Thanks!

Reply

5 nevelis November 15, 2010

This helped me get rid of a virus – there was a process that kept spawning an executable inside of AppData\Temp, so I ran:

cacls hki304.exe /D

/D for “deny access”, which stopped the process from being able to be started, and then the process that was spawning this revved up to 50% CPU. Gotcha ya bastard :)

Thanks for the tip!

Reply

6 elango November 26, 2010

thanks dude.you correct time tell the answer for me

regards
elango

Reply

7 Cody December 7, 2010

Awesome, this was a life saver. I was working on a client’s PC and the host file got locked out somehow. It wasn’t visible, even while showing hidden files. I could open it through the command line but wouldn’t let me save it or edit it. Tried numerous things, scans, safemode, changing the attributes via command line, the whole nine yards. Only thing that worked was using this command.
“CACLS hosts /p administrator:f”
Then after that I was able to change the attributes and then edit the file back to normal. Thanks a ton OP

Reply

8 manu April 21, 2011

I tried it but, couldn’t get it done. Dont know why my command prompt accept the command I am using :(

Reply

9 Me May 20, 2011

Did you right click and run your command prompt as an administrator?

Reply

10 Ibs June 2, 2011

i went through your instructions as listed and the command line said this “No mapping between account names and security IDs was done” dont know what this means??

Reply

11 TameDrone June 9, 2011

I need help because while trying to shutdown another computer in my home it is saying failed to find registry and i can’t figure how to add special permissions to my thing.

Reply

12 sahamat khan June 23, 2011

here what is the meaninig by files???

Reply

13 KillerJH2 June 27, 2011

my permissions list got scrambled so i had to delete all permissions (stupid i know)
and now this is working but access denied
and i want to punch my laptop so hard :L

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 8 + 8 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: