How to update readonly hosts file?

readonly_hosts_file

While trying to edit my readonly hosts file on a Mac, I was getting the following output and I was unable to save any changes.

"hosts" [readonly] 13L, 403B`

Let’s decode this and see how we can edit readonly hosts file and save our changes.

Explanation of Each Part:

  • “hosts”: The name of the file we are editing — in this case, a file named hosts.
  • [readonly]: we opened the file in read-only mode, meaning we can’t save changes unless we override the permissions.
  • 13L: The file has 13 lines.
  • 403B: The file has 403 bytes.

Why this is Read-Only?

The hosts file is usually a system file located at:

  • Linux/macOS: /etc/hosts
  • Windows: C:\Windows\System32\drivers\etc\hosts

These files are protected and require elevated (root or admin) permissions to modify.

How to Edit the readonly hosts file with Proper Permissions?

On Linux or macOS: Use sudo to open the file with write access:

sudo vim /etc/hosts

On Windows:

Run your text editor as Administrator, then open the file:

  1. Search for Notepad (or another editor), right-click it, choose “Run as administrator”.
  2. Open the file:
    C:\Windows\System32\drivers\etc\hosts

I hope this helps everyone!, Feel free to comment for any suggestion or update to the article

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top