I am new to this and need help I got this error and need step by step instructions
sudo: unable to resolve host legend27
I am running Ubuntu 16.04
Do you have your hostname entry present in /etc/hosts
like this?
127.0.0.1 legend27
And BTW, /etc/hostname
is a file which needs to be edited, not a command to be executed.
$ /etc/hostname # Executes /etc/hostname as a command; wrong way to do it
$ gedit /etc/hostname # Opens /etc/hostname for editing, right way to do it
You get that "Permission denied" error because /etc/hostname
doesn't have the execute bit set on its file permissions, and it is not intended to be executed anyway.
Everybody advises to modify /etc/hosts
. But in some cases this may not be possible (for example inside a docker container). So, I had to find a better way and I came up with this:
echo "alias sudo='sudo -h 127.0.0.1'" >> ~/.bash_aliases
source ~/.bashrc
Aliases don't work in bash scripts, but we can use variables: sudo='sudo -h 127.0.0.1'
hostnamectl
. – N0rbert Jan 13 '18 at 16:30