首页 > 软件开发 > 编程语言 >

解决Centos\Ubuntu is not in the sudoers file

来源:互联网 2023-03-17 00:28:05 106

权限问题不仅在Windows下会出现问题,流行的Linux下也会有各种问题,如Ubuntu、Centos等。今天就来扯扯关于终端输入sudo后出现xx is not in the sudoers file.的提示。(xx代表你安装机器时的自定义用户名)Xii办公区 - 实用经验教程分享!

解决Centos\Ubuntu is not in the sudoers fileXii办公区 - 实用经验教程分享!

解决Centos\Ubuntu is not in the sudoers fileXii办公区 - 实用经验教程分享!

工具/原料

  • Linux系统终端

方法/步骤

  • 1

    输入“su -”进入超级用户模式,输入装机时第一个设置的root密码,即可进入超级用户模式,如图3;Xii办公区 - 实用经验教程分享!

    解决Centos\Ubuntu is not in the sudoers fileXii办公区 - 实用经验教程分享!

  • 2

    给sudoers文件加写入权限,输入“chmod u w /etc/sudoers”,然后编辑sudoers文件,输入“gedit /etc/sudoers”,这时会弹出一个文本文件,如图4;Xii办公区 - 实用经验教程分享!

    解决Centos\Ubuntu is not in the sudoers fileXii办公区 - 实用经验教程分享!

  • 3

    在弹出的文本文件里找到 Allow root to ruan any commands anywhere这一行,如图5;Xii办公区 - 实用经验教程分享!

    解决Centos\Ubuntu is not in the sudoers fileXii办公区 - 实用经验教程分享!

  • 4

    在root ALL=(ALL) ALL 下面另起一行,输入“xx ALL=(ALL) ALL”(xx表示你的用户名),然后保存退出,如图6;Xii办公区 - 实用经验教程分享!

    解决Centos\Ubuntu is not in the sudoers fileXii办公区 - 实用经验教程分享!

  • 4该信息未经授权抓取自百度经验
  • 5

    去掉sudoers文件的写入权限,如图7;(这一步主要为了安全,随手养成好习惯,自己玩的虚拟机可以不做,如果是服务器什么等联外网的,切记切记。)再输入获取管理权限的sudo就正常了,不会再提示xx is not in the sudoers file.的问题了Xii办公区 - 实用经验教程分享!

  • 注意事项

    • 终端输入大小写空格
    • “su -”命令以及良好操作的习惯

    以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!Xii办公区 - 实用经验教程分享!


    标签: 编程语言

    办公区 Copyright © 2016-2023 www.bgqu.net. Some Rights Reserved. 备案号:湘ICP备2020019561号统计代码