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?
-
Also just to confirm are you using 12.04 because it doesn't support resolv.conf any more. The changes just get overwritten.– LinuxBillJun 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.– AmadeusJun 12, 2012 at 8:41
5 Answers
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
-
1This will only work if
vim
is actually capable of writing the file. Ifvim
opens a file as a regular user that can only be changed as root, thenvim
will not be able to save the changes to the file. Jun 12, 2012 at 8:32 -
1Try with
chmod 777 /etc/resolv.conf
but don't forget to set it back!– jasminesJun 12, 2012 at 8:43 -
1It's preferable to run
vim
asroot
(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
/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
.
-
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.– AmadeusJun 12, 2012 at 8:45
-
1@Zxy You can run
vim /etc/resolv.conf
. So you should be able to runsudo 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
(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:
- SSH into your Beagleboard as root.
- Edit
/etc/network/interfaces
. - Add
dns-nameservers 8.8.8.8
. - 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
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
-
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!– AmadeusJun 12, 2012 at 9:00
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/