Windows change access permissions from the command line

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:


  • /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 /?

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 28 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
28 comments… add one
  • Top Coder - Ankit Baphna Nov 13, 2008 @ 8:08

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

  • Alex May 16, 2009 @ 7:28

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

  • J. Feb 5, 2010 @ 15:02

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

  • Guarantor Loans Aug 8, 2010 @ 10:37

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

  • nevelis Nov 15, 2010 @ 7:30

    This helped me get rid of a virus – there was a process that kept spawning an executable inside of AppDataTemp, 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!

  • elango Nov 26, 2010 @ 11:56

    thanks correct time tell the answer for me


    • Cody Dec 7, 2010 @ 20:53

      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

      • Eric Jun 4, 2016 @ 12:15

        I want to delete my anti-virus but it keeps saying permission denied.. it has refused to un-install.. please help a brother out..

        • PrincessCoderDashie Jun 10, 2016 @ 12:20

          This may be a late reaction but to actually remove those files :

          -Run CMD.EXE as administrator.

          Look for the files located in the AntiVirus folder.

          -taskkill /F /IM “antiviruslocatedproccess”
          Change antiviruslocatedprogress to processes
          located in the antivirus folder, that show up in taskmgr.exe

          -Go to the files that still were unable to be deleted

          -Go to properties





          -Click your profile instead the other ones (TrustedInstaller, System, Administrator etc)

          -Close all of it except for the property tab

          -Go to security again…

          -Then edit

          -Give your own profile all access and block everything from the other ones

          -Close it

          -Save the settings

          -Remove the files

          Also if this thing is to complicated or to long :

          Reboot system in CommandPrompt Modes
          and type :

          -start Explorer.exe
          go to the folder of the antivirus
          -del /s /f /q files
          then just type that.
          (Replace files with the antivirus files)
          -shutdown -r -t 0


  • manu Apr 21, 2011 @ 0:23

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

    • Me May 20, 2011 @ 13:41

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

  • Ibs Jun 2, 2011 @ 22:38

    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??

  • TameDrone Jun 9, 2011 @ 0:08

    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.

  • sahamat khan Jun 23, 2011 @ 19:59

    here what is the meaninig by files???

    • It is the folder name or path to that folder Aug 3, 2012 @ 14:50

      C:UserssudheeshVideos>cacls filims /e /p sudheesh

      syntax : > cacls — > is the keyword that does the job for you.
      filims —> is the name of the folder needed to be deleted in my case .
      /e —> stands for editing the permissions.
      /p —> stands for creating a new permission .
      sudheesh –> my username

      processed dir: C:UserssudheeshVideosFilims

  • KillerJH2 Jun 27, 2011 @ 15:59

    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

  • MattH Oct 12, 2012 @ 17:26

    I was doing some work in my Digital forensics class and accidently set my admin permission to read only. when I use this method to try and set permission it doesnt seem to change anything. How do I get my admin right back to my admin without using admin obviously to set it. System still has full access obviously so I thought that command prompt would solve this issue.

  • Job Oct 24, 2012 @ 22:27

    Trying to recover data from a dead computer. Used Apricorn adapter to view IDE drive via usb connection. Am able to view and extract data from Administrative and All Users but not from user phbergh. I used the command CACLS PHBERGH /P PAUL:F and was able to cd to phbergh. I got access denied when trying to access My Documents for phbergh. I then used the command line CACLS *.* /T /P PAUL:F and after answering I was sure I received the access denied message. What am I doing wrong? Please help me.

  • Tliimfee Dec 22, 2012 @ 4:05

    Access is denied despite being signed in as admin? Any suggestions?

  • Cynara Dec 26, 2012 @ 5:26

    this works only for files in NTFS permission. How about for exFAT?

  • v Mar 23, 2013 @ 16:07

    it does not worked for me. Access was denied while changing permission of a directory.

  • rakesh kumar jena May 9, 2013 @ 13:20

    i have locked a folder in my computer by using cacls (folder name) /e /p everyone:n
    but when i want to unlock this i have used CACLS files /e /p everyone:f
    but i am unable to open this file
    please help how i can unlock this folder

  • Mark Sep 28, 2013 @ 19:32

    Thank you so much!

  • mark Mar 29, 2014 @ 19:08

    Bought a computer and it won’t let me add or remove programs or anything says I don’t have permission please help

  • user Sep 29, 2015 @ 17:25

    Running this code to get permission is not permitted! F@#!

  • user Sep 29, 2015 @ 17:40

    Granting permission is not permitted. Funny.

  • Bashed Forkbomb Nov 9, 2015 @ 1:16

    Just to bring some help i was reading the post which btw is extremely detailled and explicit Good job! it was usefull and have found my answer and even more knowledge about privileges under Windows OS thank you!

    Ok!! for all people who posted about permission and privileges lost for wtvr reason or because they got infected by a Virus who managed to remove you permission here a little simple and easy fix:

    1: Open notepad (Notepad++ or any other text editor will do also)
    2: copie/paste the following line:
    @echo off
    echo,Y|cacls “%WinDir%system32driversetchosts” /G everyone:f
    attrib -s -h -r “%WinDir%system32driversetchosts”

    3:Save As, and name the files: ‘wtvryouwant’.bat , Where: ‘wtvryouwant’ is wtvr you wanna call it to find it later on. The only thing that mather is to put that .bat, which gonna make it a batch files.
    4:Right click: Run as admin.
    5:Pemission should be fixed, if not reboot into Safe Mode and run it as admin again.

    If you dont know what your doing just do it the exact same way then mentioned upward, if you know what your doing just use theyse exact command 1by1 on elevated command prompt rather then going for the batch files option.

  • MR. Garcia Jan 30, 2016 @ 12:24

    Thanks a lot man, I was unable to delete a shortcut from startup folder for a loooong time!
    Giving it full permissions did the trick…
    Thanks again! 🙂

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum