unable to resolve host---阿里云下的ubuntu普通用户执行sudo命令提示错误

版权声明:可以转载,请标明作者和来源。原创首发http://kakazai.cn https://blog.csdn.net/yeziand01/article/details/88376725

文章目录

问题

  • 新购买的阿里云服务器,系统是乌班图,登陆账户是普通账户
  • 执行sudo命令时,总会出现以下错误提示
sudo: unable to resolve host iZwz97y9f1fb0ymlzbdsv0Z
[sudo] password for hadoop1:
hadoop1 is not in the sudoers file.  This incident will be reported.

原因

  • 查看 /etc/hostname 文件,可以发现iZwz97y9f1fb0ymlzbdsv0Z是阿里云创建服务器默认的hostname
cat /etc/hostname
iZwz97y9f1fb0ymlzbdsv0Z
  • 查看/etc/hosts文件,可以发现
cat /etc/hosts
127.0.0.1       localhost

解决方案

  • 登陆到root账户或者切换到root账户:su - root(会提示输入root密码),将/etc/hosts的文件内容改变:vim /etc/hosts,如下
127.0.0.1       localhost iZwz97y9f1fb0ymlzbdsv0Z
  • 返回普通账户:su - 普通账户,再执行sudo命令,提示消失

猜你喜欢

转载自blog.csdn.net/yeziand01/article/details/88376725