Back to Homepage
Tuesday 13 August 2024
137

How to view file Permissions in CMD

Viewing file permissions in Windows is essential for understanding who can access, modify, or execute a file or folder. While graphical interfaces are commonly used for this purpose, the Command Prompt (CMD) provides a powerful and efficient way to check permissions, especially when managing multiple files or automating tasks.

Viewing File Permissions with icacls

The icacls command is the primary tool used in CMD to view and manage file and folder permissions. It displays detailed information about Access Control Lists (ACLs), which define the permissions for users and groups.

1. Basic Usage of icacls:

To view the permissions of a specific file or folder, use the following command:

icacls "path\to\your\file_or_folder"

Example:

icacls "C:\Users\YourUsername\Documents\example.txt"

This command will display the permissions for the example.txt file.

2. Understanding the Output:

The output of the icacls command shows the users or groups and their associated permissions, such as F for Full control, M for Modify, RX for Read & Execute, R for Read, and W for Write.

Example Output:

C:\Users\YourUsername\Documents\example.txt NT AUTHORITY\SYSTEM:(I)(F)
                                               BUILTIN\Administrators:(I)(F)
                                               YourUsername:(I)(F)
  • NT AUTHORITY\SYSTEM:(I)(F): The SYSTEM account has Full control (F).
  • BUILTIN\Administrators:(I)(F): The Administrators group has Full control (F).
  • YourUsername:(I)(F): The specific user YourUsername has Full control (F).

3. Viewing Permissions for a Directory:

To view the permissions for all files and subfolders within a directory, use the /T flag with icacls:

icacls "C:\Users\YourUsername\Documents" /T

This will list the permissions for the directory and all items contained within it.

4. Viewing Specific Permissions:

If you're interested in checking specific permissions, such as who can write to a file, you can filter the results by using the findstr command:

icacls "C:\Users\YourUsername\Documents\example.txt" | findstr "W"

This command will show only the permissions related to writing (W).

Examples of Viewing File Permissions in CMD

  • Check Permissions for a Single File:
icacls "C:\path\to\your\file.txt"

This command shows detailed ACLs for the specified file.

  • Check Permissions Recursively for a Directory:
icacls "C:\path\to\your\directory" /T

This lists permissions for the directory and all its contents.

  • Check If a Specific User Has Write Permissions:
icacls "C:\path\to\your\file.txt" | findstr "YourUsername"

Official References

Share:
Created by:
Author photo

Jorge García

Fullstack developer