What Is a Read-Only File?
A read-only file is any file with the read-only file attribute turned on.
A file that’s read-only can be opened and viewed like any other file but writing to the file (e.g. saving changes to it) won’t be possible. In other words, the file can only be read from, not written to.
A file that’s marked as read-only usually implies that the file shouldn’t be altered or that great caution should be taken before making changes to it.
Other things besides files can also be read-only like particularly configured flash drives and other solid-state storage devices like SD cards. Certain areas of your computer memory may also be set as read-only.
What Types of Files Are Usually Read-Only?
Aside from the rare situation where you, or someone else, has manually set a read-only flag on a file, most of these types of files you’ll find are important ones that your operating system needs to start properly or, when changed or removed, might cause your computer to crash.
Some files that are read-only by default in Windows include bootmgr, hiberfil.sys, pagefile.sys, and swapfile.sys, and that’s just in the root directory! A number of files in the C:\Windows folder, and its subfolders are read-only by default.
In older versions of Windows, some common read-only files include boot.ini, io.sys, msdos.sys and others.
Most Windows files that are read-only are also usually marked as hidden files.
How Do You Make Changes to a Read-Only File?
Read-only files may be read-only on a file-level or a folder level, meaning there might be two ways to handle editing a read-only file depending on what level it’s been marked as read-only.
If just one file has a read-only attribute, the best way to edit it is to uncheck the read-only attribute in the file’s properties (to toggle it off) and then make changes to it. Then, once the editing is done, re-enable the read-only attribute when finished.
However, if a folder is marked as read-only, it usually means all the files in the folder are read-only as well. The difference in this and a file-based read-only attribute is that you must make a change to the folder’s permissions as a whole to edit the file, not just the single file.
In this scenario, you may not want to change the read-only attribute for a collection of files only to edit one or two. To edit this type of read-only file, you’d want to edit the file in a folder that does allow editing, and then move the newly created file into the original file’s folder, overwriting the original.
For example, a common location for read-only files is C:\Windows\System32\drivers\etc, which stores the host file. Instead of editing and saving the host’s file directly back to the “etc” folder, which isn’t permitted, you have to do all the work elsewhere, like on the Desktop, and then copy it back over.
Specifically, in the case of the host’s file, it would go like this:
Copy hosts from the etc folder to the Desktop.
Make the changes to the host file that’s on the Desktop.
Copy the host file on the Desktop to the etc folder.
Confirm the file overwrite.
Editing read-only files work this way because you’re not actually editing the same file, you’re making a new one and replacing the old one.