Learn how to set or unset the read-only attribute on any file or folder using File Explorer and the terminal in Windows 11.
Quick steps: Right-click on a file or folder, select “Properties“, select or uncheck the “Read-only” checkbox, and click “OK” to set or unset the read-only attribute.
If you ever want to prevent accidental edits to a specific file or files in a specific folder, setting the read-only attribute (attrib +r) is what you need. Once a file is set to read-only, Windows prevents any app from modifying the contents of the file. The best thing is that this feature has been built into Windows for a long time, and setting or unsetting read-only mode for any file or folder is as easy as selecting or unselecting a checkbox. Along with the regular GUI method, you can also do the same using the terminal. In this quick and easy guide, let me show you how to set any file or folder to read-only in Windows 11 in simple and easy steps. Let’s get started.
Before You Start
- Once the read-only mode is enabled, Windows tries to prevent modification of file contents. However, the file can still be renamed.
- You can copy, move, or delete a read-only file. Permanent deletion (Shift + Delete) may require unsetting the read-only attribute.
- While Windows tries to prevent modifying the content of a read-only file, applications installed on your computer can easily bypass this restriction by changing the attributes.
- Setting read-only mode on a folder makes all the files in that folder and subfolders read-only.
Set or Unset Read-Only on a File or Folder Using File Explorer
First, open File Explorer using the “Windows key + E” shortcut. Once it opens, find the file or folder you want to set as read-only, right-click on it, and select the “Properties” option.

In the ‘Properties’ dialog, go to the “General” tab, do the following, and click “OK” to save the change.
- Select the “Read-only” checkbox: Sets the read-only attribute on the file or folder.
- Uncheck the “Read-only” checkbox: Unsets the read-only attribute on the file or folder.
Important note: When you set or unset read-only mode on a folder, Windows doesn’t apply the attribute to the folder itself, instead, the attribute is applied to files in that folder and subfolders.

Set or Unset Read-Only on a File or Folder Using Terminal
Instead of using File Explorer, you can also set or unset a file or folder to read-only using the attrib command in Terminal. Here’s how.
First, right-click the Start icon on the taskbar or press “Windows key + X” and select “Terminal“.
In the Terminal window, run the following command to set or unset the read-only attribute for a specific file. Don’t forget to replace the dummy path with the actual path, along with the file extension.
Set the read-only attribute on a file:
attrib +r "C:\path\to\file.txt"
Unset the read-only attribute on a file:
attrib -r "C:\path\to\file.txt"
Run the following command to set or unset the read-only attribute for a specific folder. Don’t forget to replace the dummy path with the actual folder path.
Set the read-only attribute on a folder:
attrib +r "C:\path\to\folder\* /s /d"
Unset the read-only attribute on a folder:
attrib -r "C:\path\to\folder\* /s /d"
That’s it. Close the terminal window, and you are good to go.
Write down any questions or comments you have below. I’ll respond quickly.
Thank you,
Vamsi.