Linux – Using apt-get in Linux EC2 Micro Instance

amazon ec2amazon-web-serviceslinuxuser-permissions

I am trying to install apt on my Linux EC2 Micro Instance. I am trying to do as it is mentioned in the first answer of this question. But when I try to edit and save the sources.list file, I am getting the following error.
"/etc/apt/sources.list" E212: Can't open file for writing

I have logged in as ec2-user and changed to root using sudo su -. But Still I am not able to save the file. Can you please help me to fix this.

Best Answer

Can't you do a

sudo nano /etc/apt/sources.list

? Should work this way. If it does not allow you, maybe you're not in the sudoers file. To include yourself, do

sudo visudo

(that should get you in a vi editor with the sudoers config file open). You can edit using the "I" key to start adding text, but first move the cursor just below where it says

root ALL=(ALL) ALL

From there, as I say, press I and write:

ec2-user ALL=(ALL) ALL

To sabe your changes, press "ESC", ":" and "w", and ENTER. To quit, "ESC", ":", "q".

After editing sudoers, you should be able to try again the

sudo nano /etc/apt/sources.list

And edit the file normally. Should work.

Related Topic