Debian 11 安装完后,通过终端执行 sudo 命令,提示错误:

xxx 不在 sudoers 文件中。此事将被报告。

解决办法(:

  1. 终端输入 su 回车,输入 root 密码,回车,切换到 root 用户                   

  2. 打开 sudoers 文件:nano /etc/sudoers
  3. 找到 # Allow members of group sudo to execute any command,在 %sudo ALL=(ALL:ALL) ALL 下面添加 xxx ALL=(ALL:ALL) ALLxxx 为前面无法执行 sudo 命令的用户名。注:按Ctrl+W后输入”Allow members”后回车进行搜索,添加完后按提示依次按下Ctrl+XYCtrl+M保存修改并退出。

注:没有nano命令可通过vim /etc/sudoersvi /etc/sudoers打开文件,修改完用Esc+:+wq!强制保存(即依次按Esc键、:、w、q、!)。保存后文件自动生效。

Logo

更多推荐