2

A few hours earlier I bought a beaglebone and now I am trying to add nameserver 8.8.8.8 to /etc/resolv.conf. However when I open it with vim and try to add my nameserver, it gives me E21: cannot make changes, 'modifiable' is off. I changed permissions via chmod. chmod u+rx /etc/resolv.conf But nothing changed. I am still unable to write into resolv.conf file. What should I do?

2
  • Also just to confirm are you using 12.04 because it doesn't support resolv.conf any more. The changes just get overwritten.
    – LinuxBill
    Jun 12, 2012 at 8:33
  • I am sorry I forgot to add something and now edited my question: I am trying to edit resolv.conf existing on my beaglebone which is operating angstrom.
    – Amadeus
    Jun 12, 2012 at 8:41

5 Answers 5

2

From vim documentation:

If you make changes to a file and forgot that it was read-only, you can still write it. Add the ! to the write command to force writing.

If you really want to forbid making changes in a file, do this:

vim -M file

Now every attempt to change the text will fail. The help files are like this, for example. If you try to make a change you get this error message:

E21: Cannot make changes, 'modifiable' is off 

You could use the -M argument to setup Vim to work in a viewer mode. This is only voluntary though, since these commands will remove the protection:

:set modifiable
:set write
3
  • 1
    This will only work if vim is actually capable of writing the file. If vim opens a file as a regular user that can only be changed as root, then vim will not be able to save the changes to the file. Jun 12, 2012 at 8:32
  • 1
    Try with chmod 777 /etc/resolv.conf but don't forget to set it back!
    – jasmines
    Jun 12, 2012 at 8:43
  • 1
    It's preferable to run vim as root (sudo vim ...)--that way, the file is never changeable by any unauthorized user or process, and you don't have to change permissions. Jun 12, 2012 at 8:44
2

/etc/resolv.conf is owned by root, so you must edit it as root (using sudo):

sudo vim /etc/resolv.conf

You might want to back it up first though:

sudo cp /etc/resolv.conf /etc/resolv.conf.old

If you prefer to edit it graphically, then instead of using vim, you can use:

gksu gedit /etc/resolv.conf

Or on Kubuntu:

kdesudo kate /etc/resolv.conf

If you changed /etc/resolv.conf's permissions, you should change them back, as the default permissions prevent unauthorized access while allowing authorized access as explained above.

However, it's likely you didn't really change any permissions, since by default (at least on Ubuntu 12.04 LTS) /etc/resolv.conf is actually a symbolic link to /run/resolvconf/resolv.conf.

2
  • Thank you for your help. But I caused a misunderstanding because of the reason that I forgot to add that I am trying to edit resolv.conf file on my beaglebone which is operating angstrom. Again, sorry for the inconvenience. If you still have an idea and share with me, I will be appreciate to you.
    – Amadeus
    Jun 12, 2012 at 8:45
  • 1
    @Zxy You can run vim /etc/resolv.conf. So you should be able to run sudo vim /etc/resolv.conf. That is, if you're using Ubuntu. If you're using another distro, like the Ångström distribution, then your questions is off-topic for AskUbuntu and you should ask it at Unix.SE instead. Jun 12, 2012 at 8:47
1

(Disclaimer: this is based on Internet research, not on actual hands-on experience with the board.)

According to this article,

Ångström Linux distribution [...] is included in the microSD card packaged with each Beaglebone.

Without citing the whole article (it seems to be very well written, btw.) you need to:

  1. SSH into your Beagleboard as root.
  2. Edit /etc/network/interfaces.
  3. Add dns-nameservers 8.8.8.8.
  4. Run /etc/init.d/networking restart

If your settings seem to work, but go away after a reboot, read this article on setting up Connman.

You'll need to install the connman-tests package to enable command-line configuration of Connman, and set the nameservers by following the instructions.

Example:

./set-nameservers ethernet_405fc276b749_cable 8.8.8.8
1

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.

gksudo gedit /etc/resolv.conf

That will let you modify the file and save it.

You can try:

opkg update
opkg install gedit 
1
  • currently I am not able to connect to net because of my dns options. therefore I cannot use opkg install gedit. however thanks for your advice!
    – Amadeus
    Jun 12, 2012 at 9:00
0

You can try:

vim resolv.conf

Save it after that

rm -rf /etc/resolv.conf

Then move resolv.conf file in /etc/

mv resolv.conf /etc/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .