What to do when sudo won't work

2020-09-25   1 min read

When sudo doesn't work, it kind of feels like the end of the world (to me, at least). I noticed this message 'unable to resolve host fun-toy: Name or service not known' started to show every now and then when I ran certain commands and sudo didn't work. Here is what to do when you want that ultimate power back.

Contents

  • The cause of the issue & Fix

(1) How I identified the cause of the issue

Ask! Ubuntu taught me that

/etc/hostname and /etc/hosts both need to contain the name of your machine.

So I took a look at both of them and aha, my /etc/hosts file didn't have my machine name fun-toy in it. After the edit, the file looks like this;

/etc/hostname and /etc/host

Make sure to run sudo reboot so that this fix takes into effect.


Typos/comments/suggestions are welcomed on GitHub issues

ELLIOT SHIMBA  ©  2020-2022