1819879 Members
2520 Online
109607 Solutions
New Discussion юеВ

/etc/hosts is read only

 
SOLVED
Go to solution
Nadine Silue
Advisor

/etc/hosts is read only



Dears,

Please can someone help me solve this problem?

When i tried to add my system host name and ip address in /etc/hosts host file using vi the /etc/hosts shows read only therefore can't save anything.


Pls help.

Nadine
8 REPLIES 8
Jeff_Traigle
Honored Contributor
Solution

Re: /etc/hosts is read only

Since you need to be root to edit that files anyway, you should be able to use :wq! to save even though it's read-only. Note that this only works for root. Regular users must have write access to files to save changes even if they own them.
--
Jeff Traigle
James R. Ferguson
Acclaimed Contributor

Re: /etc/hosts is read only

Hi Nadine:

Only the 'root' user should be maintaining this file and then, as 'root' the permissions of the file are meaningless. That is, you can 'vi' the file and using ':wq!" replace the old version when done.

Regards!

...JRF...
Jeeshan
Honored Contributor

Re: /etc/hosts is read only

Hi

to save read only file you need to save it by vi editor is :wq!

a warrior never quits
Asif Sharif
Honored Contributor

Re: /etc/hosts is read only

Hi Nadine,

Use the ":wq!" that saves & quit the editor.

Read the vi editor Quick reference.

http://www.adminschoice.com/docs/vi_editor_ref.htm

Regards,
Asif Sharif
Regards,
Asif Sharif
Suraj K Sankari
Honored Contributor

Re: /etc/hosts is read only

Hi,

As everybody says, to save any readonly file in vi you have to use :wq!
wq! => save and quit

Suraj
Khairul_1
Frequent Advisor

Re: /etc/hosts is read only

Hi Nadine

may be you are using other user, use super user root and try with
#vi /etc/hosts
the save
#!wq

thanks
khairul
Bangladesh
Nadine Silue
Advisor

Re: /etc/hosts is read only



Thanks Dears,


I will all that and get back to you.


Nadine
Nadine Silue
Advisor

Re: /etc/hosts is read only

Thanks Dears,

It works.

Nadine