/etc/apt/sources.list" E212: Can't open file for writing

后端 未结 13 697
一生所求
一生所求 2020-12-22 15:06

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         


        
相关标签:
13条回答
  • 2020-12-22 15:37

    You just need to access to Gemfile with root access. Before vi:

    command:

    sudo su -
    

    then:

    vi ~/...
    
    0 讨论(0)
  • 2020-12-22 15:45

    I got this error when my directory path is incorrect, ensure your directory names and path are correct

    0 讨论(0)
  • 2020-12-22 15:46

    Or perhaps you are on a readonly mounted fs

    0 讨论(0)
  • 2020-12-22 15:47

    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.

    0 讨论(0)
  • 2020-12-22 15:49

    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
    
    0 讨论(0)
  • 2020-12-22 15:50

    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

    0 讨论(0)
提交回复
热议问题