sudo命令无法使用

sudo更改文件权限报错 is not in the sudoers file. This incident will be reported

按照已有的方法
su命令不能切换root,提示su: Authentication failure,在sudo passwd root输入密码后,依然会出现 is not in the sudoers file. This incident will be reported

按照另一个方法输入sudo passwd 新用户 ,依然提示要输入 password for ,输入密码之后再次出现 is not in the sudoers file. This incident will be reported

使用了sudo命令来更改文件权限,但是当前使用的用户没有sudo权限。
需要使用具有sudo权限的用户来执行此命令,或者在当前用户的sudoers文件中添加sudo权限。
要添加当前用户的sudo权限,操作如下:

  1. 打开终端并输入命令: su - root (输入您的 root 用户的密码)
  2. 输入命令: visudo
  3. 在文件中找到以下行: root ALL=(ALL:ALL) ALL
  4. 在该行下方添加以下内容: username ALL=(ALL:ALL) ALL (将 'username' 替换为您要添加sudo权限的用户名)
  5. 保存并退出

可参考:
https://blog.csdn.net/weixin_37787043/article/details/123045557

输入sudo su没有反应吗?截图看下!

img

输入 su-root依然报错

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^