7

When I try to edit my sources.list file using the command:

$ gksu gedit /etc/apt/sources.list

It requests an administrative password and when I type the password, It says incorrect and try again.What to do? I am new to Linux and Ubuntu.

Zanna
  • 70,465
IronMan007
  • 157
  • 1
  • 2
  • 12

5 Answers5

10

Use the default terminal text editor program nano instead of gedit to edit /etc/apt/sources.list. Open the terminal and type:

sudo nano /etc/apt/sources.list

Alternatively you can also replace sudo nano /etc/apt/sources.list with sudoedit /etc/apt/sources.list. Because nano is the default terminal editor in Ubuntu the two commands do exactly the same thing.

The instructions for using nano are always displayed at the bottom of the page. Use the keyboard combination Ctrl + O and after that press Enter to save the file to its current location. Use the keyboard combination Ctrl + X to exit nano.

karel
  • 114,770
3

gksu is probably set to use su instead of sudo as the authentication method. Therefore, it's asking you for the administrative (root) password.

To change this, run gksu-properties and choose sudo as the Authentication Method. This way, gksu will ask you for your password.

You'll notice that the dialog box that asks you for the password changes from:

which is asking for the administrative (root) password to:

which asks for your password to perform administrative tasks.

Alaa Ali
  • 31,535
1

Solving the problem:

If your root password is correct and you are receiving error from using gksu gedit /etc/apt/sources.list then use gksudo gedit /etc/apt/sources.list and go about the changes.

all4naija
  • 1,554
  • Why not use simple sudo gedit /etc/apt/sources.list ? When I do, it open gedit and let me edit the file. – Tulains Córdova Aug 14 '13 at 20:55
  • @ Karel. No, it is gksu that is deprecated in Ubuntu 13.04 not gksudo. – all4naija Aug 14 '13 at 21:03
  • I guess not. I have tried both out myself -- gksu doesn't work but gksudo works as against your launchpad link. It seems that gksu is deprecated in Ubuntu 13.04. It is clear that until you start using pkexec gksudo is the right one to use. There is no argument here though. – all4naija Aug 14 '13 at 21:30
0

In kde you cannot open kate with sudo, ie # sudo kate <file>. Instead, you open the file normally, edit it then save. Kate then asks for your password.

gryphonB
  • 139
  • 4
0

Although I have been logged in as root user, the file was effectively not editable. Multiple editors took minutes to only display its content and none of the editors was able to write.

This is most likely to be caused by a swap file at the same location which is locking the file for editing.

In this case, backup the file, delete the original and re-copy the copy.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo rm /etc/apt/sources.list
sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list
sudo rm /etc/apt/sources.list.bak

You can also delete the file, create a new one and edit / paste the desired content into it, in case you have the text.

philburns
  • 135