LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unable to edit /etc/apt/sources.list (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-edit-etc-apt-sources-list-608005/)

JudgeMonkey 12-19-2007 09:36 PM

Unable to edit /etc/apt/sources.list
 
Ok, so I was recently pulled into the world of linux through my purchase of an EEE pc. So I'm trying to get it setup, I find a tutorial on how to install wine, but it wants me to edit /etc/apt/sources.list. A similar tutorial for dosbox had me do the same.

It first suggests I run konsole to allow pasting.

It then tells me to use the command sudo nano /etc/apt/sources.list

I understand that, I think. sudo (the important part) gives full access to the file, supposedly. nano is the text editor that is being given super user privileges, and /etc/apt/sources.list is the file.

However, I save the file and close it, and when I open it, it is unchanged. I browse to the folder, and I see it is creating sources.list.save, sources.list.save 1, etc... All of these files are marked as owned by the root, I figure sudo rm /etc/apt/sources.list.save* will remove them, but my main concern is an inability to edit the file I want.

I'd login as root just for this process, but don't even know how to do that.

Acron_0248 12-19-2007 09:42 PM

Hi,


sudo should be able to give the privileges neede unless some sore of unusual configuration on sudoers, however, to become root, open konsole (or any other terminal emulator) and type just su, it will ask you for the root pass, type it and press Enter, from then, you can edit the sources just using nano /etc/apt/sources.list



Regards

JudgeMonkey 12-19-2007 10:03 PM

Hmm, ok. I type su and it gives the password prompt. I don't know my root password, but i heard someone say on these systems that it's the same as your password. I typed that in and I guess it worked. The prompt changed from /home/users> to eeepc-myname:/home/users>

I tried editing the file with just nano /etc/apt/sources.list and it does the same thing. It seems to change, but when I check it's the same. Sure enough I'm now up to .save 5

I can only guess some config file is unusually configured (the only other thing I've done on this system is use synaptic to install a few essential packs that this computer would be in kid mode without.) it seems like the changes I made with synaptic took.

neophytezer0 12-19-2007 10:15 PM

vi ftw?
 
I would suggest using vi (or vim) instead of nano. I think what is going on is nano is saving to a different file, which you have to "mv" onto the file you are editing for the changes to take effect. try to view the '.save's and see if those have the changes. if so, do a quick 'mv (file) sources.list' and you should be ok.

Acron_0248 12-19-2007 10:19 PM

How are you exactly saving changes?

The .save files are emergency files that nano create when it exits suddenly or when it recieves a sigterm o sighup, it appends a number if there's already a .save file.

Do:
Code:

# nano /etc/apt/sources.list
After all changes, press Ctrl + O (read letter "o" not zero 0), it will ask you if you want to save changes, press Enter to save them, and then press Ctrl + X to quit nano.

Read man nano for more info





Regards

jay73 12-19-2007 10:20 PM

I wouldn't recommend simply overwriting critical files anyway. What if sometimes goes wrong ? It's safer to make a copy first and give it a slightly different name, for example adding .bak to the extension, then edit the original.

As for nano, it doesn't work any different from vim. If it created a different file, how would it know what to name it? No, it simply uses the original just as vim does.

Did you use Ctrl+O and Ctrl+X to save your changes?

JudgeMonkey 12-19-2007 10:24 PM

I found the problem. You press x to exit, and then yes to save the buffer. It is then asking me what file to save to. I kept assuming it was done and closed the console. I needed to press enter one more time. That's it. I just didn't hit enter enough.

Don't worry, I'll punch myself for you. Dang, I don't think my mother (who keeps making the "any key" joke.) would make such a silly mistake. Thank you all for your help.

I think mv one of the .save files would have worked too, yes.

Also, before i did this I did a cp on the sources.list and made a sources.list.bak

Update: Ah, I see ya'll could tell what i was doing wrong anyway, so if my brain didn't work, well darn. You've got a resolution for even that.


All times are GMT -5. The time now is 03:32 AM.