xxx is not in the sudoers file. This incident will be reported.

参考链接

  1. 如何把普通用户添加到sudoers file
  2. /etc/sudoers文件解析

测试环境

操作系统:CentOS

xxx is not in the sudoers file

[ljl@VM-0-8-centos python]$ sudo -s
[sudo] password for ljl:
ljl is not in the sudoers file.  This incident will be reported.

如上所示,普通用户执行“sudo -s”切换到root用户时报错:xxx is not in the sudoers file. This incident will be reported.

根据错误提示,当前用户不在sudoers file,需要将当前用户添加到sudoers file

sudoers file是什么文件?

Sudoers allows particular users to run various commands as the root user, without needing the root password.

sudoer 使得普通用户能像root用户一样执行各种命令,而不必使用root密码。

sudoers file 默认指的是 文件 /etc/sudoers

$ ls -lha /etc/sudoers
-r--r----- 1 root root 4.3K Oct 19 14:41 /etc/sudoers

如何把普通用户添加到sudoers file

为了安全起见,/etc/sudoers文件是只读的,必须使用命令visudo来编辑它:

$ visudo --help
visudo - safely edit the sudoers file

usage: visudo [-chqsV] [-f sudoers]

Options:
  -c, --check              check-only mode
  -f, --file=sudoers       specify sudoers file location
  -h, --help               display help message and exit
  -q, --quiet              less verbose (quiet) syntax error messages
  -s, --strict             strict syntax checking
  -V, --version            display version information and exit

root用户执行visudo,找到 “root ALL=(ALL) ALL” 这行,在下面添加一行:

username     ALL=(ALL)       ALL

如果想要在使用“sudo -s”时跳过输入密码,则可以添加一行:

username    ALL=(ALL)       NOPASSWD:ALL

username是具体的用户名称。

然后Esc退出编辑,最后 :X保存并退出。

【完】

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
"fatal: 'git@gitee.com/kid-zcx/zhang-cx_-obsidian.git' does not appear to be a git repository fatal: Could not read from remote repository." 这个错误通常出现在使用 Git 进行远程操作时,表示 Git 无法从远程仓库读取数据或识别远程仓库。这可能是由于以下几个原因导致的: 1. 链接错误:请确保你提供的远程仓库链接是正确的。检查链接是否拼写正确,并且确保远程仓库存在且可用。 2. 访问权限:这个错误可能是由于你没有足够的权限来访问远程仓库导致的。请检查你对远程仓库的权限,并确保你具有读取和写入的权限。 3. SSH 配置:如果你使用 SSH 进行远程操作,你需要确保你已经正确配置了 SSH 密钥。你可以使用命令生成 SSH 密钥,并将公钥添加到你的远程仓库的 SSH 设置中。 综上所述,你可以按照以下步骤来解决这个问题: 1. 首先,确认你提供的远程仓库链接是否正确,确保没有拼写错误,并且远程仓库存在且可用。 2. 如果你使用 SSH 进行远程操作,请确保你已经正确配置了 SSH 密钥。你可以使用命令 `ssh-keygen -t rsa -C "your_email@example.com"` 来生成 SSH 密钥,然后将公钥添加到你的远程仓库的 SSH 设置中。 3. 如果问题仍然存在,请检查你对远程仓库的权限,并确保你具有读取和写入的权限。 通过以上步骤,你应该能够解决这个问题,并成功进行远程操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值