I am trying to edit sources.list using vi editor but getting the following error while saving the file:
/etc/apt/sources.list\" E212: Can\'t open file for wr
You just need to access to Gemfile with root access. Before vi
:
command:
sudo su -
then:
vi ~/...
I got this error when my directory path is incorrect, ensure your directory names and path are correct
Or perhaps you are on a readonly mounted fs
For me there was was quite a simple solution. I was trying to edit/create a file in a folder that didn't exist. As I was already in the folder I was trying to edit/create a file in.
i.e. pwd folder/file
and was typing
sudo vim folder/file
and rather obviously it was looking for the folder in the folder and failing to save.
It might be possible that the file you are accessing has a swap copy (or swap version) already there in the same directory
Hence first see whether a hidden file exists or not.
For example, see for the following type of files
.system.conf.swp
By using the command
ls -a
And then, delete it using ...
rm .system.conf.swp
Usually, I recommend to start using super user privileges using ...
sudo su
change user to root
sodu su -
browse to etc
vi sudoers
look for root user in user priviledge section. you will get it like
root ALL=(ALL:ALL) ALL
make same entry for your user name. if you username is 'myuser' then add
myuser ALL=(ALL:ALL) ALL
it will look like
root ALL=(ALL:ALL) ALL
myuser ALL=(ALL:ALL) ALL
save it. change root user to your user. now try the same where you were getting the sudoers issue