Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

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.

share|improve this answer
    
Thanks for your answer. I tried your suggestions. When I tried to do save, I got [ Error writing /etc/apt/sources.list: No such file or directory ]. –  John Dec 11 '10 at 11:23
2  
Are you sure you're using a Ubuntu/Debian instance? Maybe you've set up a RPM based distribution. In that case that file wouldn't be there because the package manager is not apt-get. Instead you should use yum, for example. –  javipas Dec 11 '10 at 11:25
    
Hey thanks, yea i was able to install using yum :) –  John Dec 11 '10 at 12:40
    
You're welcome! Happy to help :) –  javipas Dec 11 '10 at 13:56
add comment

Not all GNU/Linux distributions use apt-get. Your micro instance is probably not Debian-based, and does not use apt-get to provide packages.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.