Error saying hosts E212 Can t open file for writing when trying to change host name on the VM

0 votes

I have two VMs, one is the master and the other is the worker. I'm trying to create a kubernetes cluster. When I try to edit the hosts name, I get the following error:

"hosts" E212: Can"t open file for writing 
Dec 17, 2018 in Docker by Ali
• 11,360 points
28,764 views

2 answers to this question.

0 votes

Hey @Ali, Follow these steps:

 sudo su

When asked for password give the password.

After that to edit the hosts file using any one of the below commands:

nano /etc/hosts 

or 

vi /etc/hosts
answered Dec 17, 2018 by Arohi
Okayyy....but why was the error occurring in the first place?
Hey @Vardhan, You get this error when you don't have permissions or not running as a root user. Not just anyone can change the host name of the system. Hence using the sudo su command, you start accessing resources as a root user and it solves your issue.
0 votes
I am interested in the answer as well. I am having the same challenges on SLES12 SP3 when exditing files such as /etc/passwd, /etc/group, etc.. I provide the lsattr and the ls -l to disregard any comments on those two..

I am root.. I know, I logged in as root...

# lsattr /etc/passwd shows

---------------- /etc/passwd

# ls -l /etc/passwd
-rw-r--r-- 1 root root 1838 Jan 25 13:23 /etc/passwd

# lsof /etc/passwd
#                       ( <<- Nothing is returned)
answered Jan 26, 2019 by anonymous

Hey, You have read and write permissions as root. Open your etc/passwd file as root.

sudo vi etc/passwd

This should solve your problem. 

Related Questions In Docker

0 votes
1 answer

Error when trying to start host on Oracle Virtual Box

You have to enable the virtualization technology ...READ MORE

answered Dec 16, 2018 in Docker by Kiyara
3,097 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,620 views
0 votes
1 answer

permissions related to AWS ECR

if you add allowContainerRegistry: true, kops will add those permissions ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 52,350 points
1,448 views
0 votes
4 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP