Posts tagged “/etc/hosts” E166: Can’t open linked file for writing
How to save a modified file as super user to avoid file permission problems
Dec 22nd
Posted by Nick in Command Line
This problem occurs when an user edits a file for which he doesn’t have write permission. Generally it happens when a non-root user attempts to save a modified file in /etc directory. In such cases, user can save the changes using the following vi command.
:w !sudo tee %
In the above command, all the contents of modified file are redirected to “tee” command as input. The “%” character expands to current file name. The “sudo” command executes the “tee” command with super user privileges. So basically, the tee commands reads contents of the modified files as input and writes to the More >


Recent Comments