0
sudo: unable to resolve host

I think I need to edit the /etc/hosts file to make an entry for 127.0.1.1 PC name.

But how can I do that if I can't access sudo? It seems to have gone since I updated to 13.10.

I have tried nano, which still doesn't work.

kiri
  • 28,246
  • 16
  • 81
  • 118

2 Answers2

2

I'd suggest you boot into recovery mode then edit the hosts file with these steps:

  1. Boot into recovery mode with steps from here: How do I boot into recovery mode?

    Steps 2 - 5 below are from the above question.

  2. Hold Shift after your BIOS has passed, then choose:
    "Advanced options → something ending with '(recovery mode)'"

  3. Choose the "Drop to root shell prompt" option
  4. Remount the root partition as R/W with this command:

    mount -o remount,rw /
    
  5. If you have separate partitions, execute this command to mount them:

    mount -a
    
  6. Edit the /etc/hosts file with this command :

    nano /etc/hosts  # Replace `nano` with your favourite command line editor
    
  7. Make the changes you want.
  8. Press these keys to save and exit it: Ctrl+X; Y; Enter

    Note: If there's a + between two keys, press those at the same time. If there's a ; between two key sequences, press the first sequence, then release it, then press the second.

  9. Reboot:

    reboot
    
kiri
  • 28,246
  • 16
  • 81
  • 118
1

If you set a password on the root account, you can try :

su -

After putting the correct password in (if set) you should be "root" and free to change the files as needed.

Avinash Raj
  • 78,556
  • 2
    This is unlikely to work as the root account is locked by default and so will not have a password set. Best solution is to login to a recovery console then edit as root. – Warren Hill Oct 31 '13 at 11:37
  • I agree if the password hasn't been set - as per my answer, however in the lucky situation that it has been - it works fine. I always set a root password to avoid this type of issue. This of course needs to be done before you have problems :) From a working system, just sudo su - passwd and you're done. – FreudianSlip Oct 31 '13 at 12:27