/etc/resolv.conf" E166: Can't open linked file for writing
unable to update resolv.conf file.
"/etc/resolv.conf" E166: Can't open linked file for writing
ubuntu 18.04.1
This is an assumption that you're asking about a vim
error message (you didn't specify where you got the error message).
Vim documentation reports E166 as
E166 Can't open linked file for writing
You are trying to write to a file which can't be overwritten, and the file is a link (either a hard link or a symbolic link). Writing might still be possible if the directory that contains the link or the file is writable, but Vim now doesn't know if you want to delete the link and write the file in its place, or if you want to delete the file itself and write the new file in its place. If you really want to write the file under this name, you have to manually delete the link or the file, or change the permissions so that Vim can overwrite.
http://vimdoc.sourceforge.net/htmldoc/message.html
guiverc@d960-ubu2:~$ stat /etc/resolv.conf
File: /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
Size: 39 Blocks: 0 IO Block: 4096 symbolic link
Device: 801h/2049d Inode: 130757 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-09-03 12:34:28.189468370 +1000
Modify: 2017-11-16 12:32:04.777265492 +1100
Change: 2017-11-16 12:32:04.777265492 +1100
A stat
of my /etc/resolv.conf confirms the file is a link.
I can happily write to that file (using sudo
) so you have an issue beyond what you've provided.
In my case it worked when I used sudo
while opening resolv.conf
file through vi. If file is not already present then it creates one.
$ sudo vi /etc/resolv.conf