Linux遇到的问题(一)Ubuntu报“xxx is not in the sudoers file.This incident will be reported” 错误解决方法...

提示错误信息

www@iZ236j3sofdZ:~$ ifconfig
Command 'ifconfig' is available in '/sbin/ifconfig'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
ifconfig: command not found
切换到root 用户模式下 ,找一个别的操作系统给的profile 文件,复制过来,替换掉以前的既可以

vi /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
错误信息:

www is not in the sudoers file.  This incident will be reported.
在这我是这么做的

sudo vi /etc/sudoers

# User privilege specification
root    ALL=(ALL:ALL) ALL

www     ALL=(ALL)     ALL   # 增加www用户这一行既可以了

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
保存皆可以了

Ubuntu报“xxx is not in the sudoers file.This incident will be reported” 错误解决方法
=

"xxx is not in the sudoers file. This incident will be reported"错误是在执行sudo命令时出现的。这个错误提示表示用户xxx没有被授权使用sudo命令。sudo命令是一种特权命令,只有被授权的用户才能使用它来执行以root权限运行的命令。 要解决这个错误,可以采取以下几种方法: 1. 添加用户到sudo组:在Linux系统中,可以使用visudo命令编辑sudoers文件,将用户添加到sudo组中。具体操作是打开终端并输入sudo visudo命令,然后找到sudoers文件中的"# User privilege specification"部分,在其中添加一行:xxx ALL=(ALL:ALL) ALL,其中xxx是你的用户名。保存并退出sudoers文件后,你就可以使用sudo命令了。 2. 创建新的sudoers文件:如果你无法编辑sudoers文件,或者无法使用sudo命令来编辑该文件,你可以创建一个新的sudoers文件。具体操作是在终端中以root身份运行命令:sudo cp /etc/sudoers /etc/sudoers.bak,然后使用文本编辑器打开/etc/sudoers.bak文件,并按照需要修改该文件。在保存并退出文件后,将新的sudoers文件复制到/etc目录中:sudo cp /etc/sudoers.bak /etc/sudoers。 3. 使用root账户操作:如果你知道root账户的密码,可以直接切换到root账户执行需要root权限的操作,而无需使用sudo命令。具体操作是在终端中输入su -命令,然后输入root账户的密码登录到root账户。注意,在使用root账户时要小心操作,确保只执行必要的操作。 总结起来,要解决"xxx is not in the sudoers file. This incident will be reported"错误,你可以将用户添加到sudo组、创建新的sudoers文件或者使用root账户操作。这些方法中的任何一个都可以帮助你解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [XXXX is not in the sudoers file. This incident will be reported解决方法](https://blog.csdn.net/qq_37964379/article/details/104193627)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [xxx is not in the sudoers file.This incident will be reported错误](https://blog.csdn.net/m0_49448331/article/details/125920541)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值