70

In linux, ls -l lists files permissions, like this:

-rw-r--r--  1 user user      924 2011-07-01 20:23 test.txt

In Windows, commands tree and dir don't have the options to list permissions. How is it possible to list files and their permissions using command line only?

1

5 Answers 5

70

Use icacls:

> icacls Music
Music SNOW\grawity:(I)(F)
      CREATOR OWNER:(I)(OI)(CI)(IO)(F)
      SNOW\grawity:(I)(OI)(CI)(IO)(F)
      NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)

The older cacls tool is the only choice on Windows XP [although you can copy icacls.exe from Server 2003]. cacls does not know about some ACL modes, but displays most of them fine.

> cacls Music
F:\Users\Mantas\Music SNOW\grawity:F
                      CREATOR OWNER:(OI)(CI)(IO)F
                      SNOW\grawity:(OI)(CI)(IO)F
                      NT AUTHORITY\SYSTEM:(OI)(CI)F

In both outputs, (OI) means "object inherit" (files will inherit this ACE), (CI) is "container inherit" (containers – i.e. folders – will inherit this ACE), (IO) is "inherit only".

Microsoft also used to provide an xcacls tool separately, but its functionality is now part of icacls.

37

You can use Powershell and the Get-Acl command

PS C:\> Get-Acl

   Directory:

Path              Owner                            Access  
----              -----                            ------  
C:\               NT SERVICE\TrustedInstaller      Everyone Allow  FullControl

Use it in conjunction with Get-ChildItem (aliased with dir and ls) to get the permissions for the files.

PS C:\> Get-ChildItem | Get-Acl

Or, using the alias:

PS C:\> Dir | Get-Acl
2
  • 13
    PS C:\> Get-Acl | fl for a nicer list.
    – AWippler
    Dec 2, 2013 at 17:10
  • Can I alter this to skip a folder that I don't have access to? for example, when I ran this (not as admin) I got an error ("unauthorized operation") and the report stopped at the folder I did not have access to
    – Ben
    Jan 18, 2018 at 0:14
16

You might also take a look at AccessChk from Sysinternals. The output can be parsed much easier.

C:\Users\jeremy>accesschk myad\simmonsj c:\inetpub

Accesschk v5.11 - Reports effective permissions for securable objects
Copyright (C) 2006-2012 Mark Russinovich
Sysinternals - www.sysinternals.com

RW c:\inetpub\custerr
RW c:\inetpub\history
RW c:\inetpub\logs
RW c:\inetpub\Roadkill
RW c:\inetpub\smartadmin
RW c:\inetpub\temp
RW c:\inetpub\wwwroot
2
  • It does a different thing though; it lists the effective access for the current (or specified) user, rather than the full configured access list. Aug 5, 2014 at 6:18
  • 1
    I believe the OP's question could have been interpreted either way. Judging by the recent up-vote on my answer, this was useful to at least one other person besides me. My answer is not meant to argue with or disprove your answer. It is a different way to approach the problem to get a very similar answer.
    – JJS
    Aug 6, 2014 at 20:13
10

dir /Q gives you the owner of the directories and of any files in the current folder.

With dir /Q /S you can see the owners of all files and directories in and under the current folder.

Thanks @DAB for the edit suggestions.

0

If you just want Windows file attributes (not ownership or ACLs) you can use the Powershell Dir command (a shortcut for the Get-ChildItem command). For example:

...>powershell dir


    Directory: C:\...


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        09/04/2022     18:09                testfiles
-a----        08/04/2022     23:19         130844 testbbackupd.cpp
-a----        08/04/2022     23:19             94 testextra
-a----        09/04/2022     18:06        8394752 test_bbackupd.exe

The letters in the Mode property are the Windows file attributes of each file, which can be interpreted as follows:

  • l (link)
  • d (directory)
  • a (archive)
  • r (read-only)
  • h (hidden)
  • s (system).
1
  • I downvoted because that's not what OP wanted. They unambiguously stated they wanted to see file permissions. This answer is better suited as a comment.
    – Zimano
    Sep 12, 2023 at 9:52

You must log in to answer this question.