Error: Read-only file system (edit hosts)
This is probably a general sys-admin issue/solution, but as I have never not been able to edit a hosts file, under any operating system, I do not know how to address.
Need to redirect/block a couple of domains to localhost to prevent some apps from changing settings/features once they detect updates are available.
I attempted to edit the /etc/hosts file and /usr/etc/hosts file but both return {Read-only file system}.
I have created a hosts file with the redirects I need in /usr/local/etc/, which saved, but is not being read by the system.....
How, where, what can I do with this read-only file system to accomplish what would normally be done through simply editing the hosts file??
Thank you
6 Replies
Solution
Just sudo nano /etc/hosts
/etc is writeable
Usually the way to do this without local hosts file is setting up your own DNS using pi-hole (on another box) or Portmaster (local)
Or you can make a NextDNS account
But portmaster should be enough if you really canβt find a way
You can just add the entires through sed
Add the sed commands to system.yaml
heh.. didn't literally type (/etc/hosts)... just opened /etc/ in terminal from Files and typed sudo nano hosts.. Why wouldn't that be the same thing..?
It wrote, so loging out/in to see if it gets read..
Great! Domains are pinging to localhost... Do not know why the syntax from within /etc/ folder would make any difference.. hasn't before. Thank you.
Lmao
The terminal might have been in another folder
Or sudo gnome-text-editor /etc/hosts if on gnome to GUI edit
Almost always do ls before any commands, but possible technically, also did it numerous times, starting from root, as user, sudo, su.. Looks good for now. I looked up any way to do it through system.yaml but could not find any information on what header to use, or syntax, but good information to have. Thanks again.
You add sed commands to the commands block
Pretty easy to understand
But you donβt have to do that
Sed is a file editing tool that edits files using patterns you give it kinda like regex