CentOS切换中文拼音安装包时:zw 不在 sudoers 文件中。此事将被报告。【记录】

CentOS切换中文拼音安装包时:zw 不在 sudoers 文件中。此事将被报告。

先摆错误过程:

[zw@CentOS72 ~]$ yum install ibus-libpinyin
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
您需要 root 权限执行此命令。
[zw@CentOS72 ~]$ su root
密码:
[root@CentOS72 zw]# yum install ibus-libpinyin
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
软件包 ibus-libpinyin-1.6.91-4.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@CentOS72 zw]# exit
exit
[zw@CentOS72 ~]$ yum install ibus-libpinyin
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
您需要 root 权限执行此命令。
[zw@CentOS72 ~]$ sudo yum install ibus-libpinyin
[sudo] zw 的密码:
zw 不在 sudoers 文件中。此事将被报告。

- 添加汉语拼音键盘

如上面的引用,本来想添加中文拼英键盘,但是在设置里面只找到了汉语,没有汉语(intelligent Pinyin),这种情况下不能切换中文键盘。进行下载:

yum install ibus-libpinyin

提示需要root权限进行下载,我是可以进入root的,但是在命令前使用sudo 就会提示 当前用户不在sudoers文件中:

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

(以前我每次遇到这种都是直接su root 进入root ,但是这次我去看了一下root 用户和sudo之间的区别:弄清这个很有必要,避免不必要的麻烦。
命令前加sudo执行和用真正的root用户执行有什么区别? - pansz的回答 - 知乎
)

- 解决sudoers问题——在sudoers中增加用户,并赋予权限

解决方案来源:http://t.csdn.cn/T6hGe

  1. 进入root用户
su root 
  1. 给root用户添加可写权限
chmod 640 /etc/sudoers
  1. 修改文件
vim /etc/sudoers

在 root ALL=(ALL) ALL下添加:(按i进入插入模式)
zw ALL=(ALL) ALL
(Esc 后按: 输入wq! 强制保存退出)
4. 打印查看是否修改成功

cat /etc/sudoers
  1. 改回原有的sudoers文件只读权限
chmod 440 /etc/sudoers
  1. 退出root到zw用户
exit
  1. 再次下载
sudo yum install ibus-libpinyin

这个时候去设置看语言地区就能看到汉语(Intelligent Pinyin)选项,选它并移到前面就可以切换中文拼音键盘了。

### 解决 CentOS 7 虚拟机用户不在 `sudoers` 文件中的问题 当遇到“用户不在 sudoers 文件中”的错误,意味着当前用户未被授予超级用户权限。为了修复此问题并赋予特定用户必要的权限,可以采取以下措施: #### 修改 `/etc/sudoers` 文件以添加新用户 对于具有管理员访问权的情况,可以通过直接编辑系统的 `sudoers` 配置来解决问题。 1. **获取临root 权限** 如果有其他方式获得 root 访问(例如通过物理控制台或者云服务提供商管理界面),那么可以直接切换root 用户来进行更改[^2]。 2. **调整文件权限以便于编辑** 使用命令 `chmod u+w /etc/sudoers` 更改文件属性使其可写入,从而允许后续操作对其进行修改[^3]。 3. **利用文本编辑器更新配置** 执行如下指令打开 `sudoers` 文件: ```bash vim /etc/sudoers ``` 4. **增加新的条目给目标账户授权** 寻找现有的一行定义如 `root ALL=(ALL) ALL` ,在其下方追加一行用于指定希望拥有相同权利的新用户名字,格式为 `<username> ALL=(ALL) ALL` 。这一步骤确保了所选用户能够在任何上下文中执行任意命令作为超级用户身份运行[^4]。 5. **恢复原始保护模式** 完成上述改动之后立即撤回之前给予额外写的许可,即再次应用严格的读取只权限:`chmod u-w /etc/sudoers` 。 #### 当前环境缺乏 root 接近手段的选择方案 如果无法轻易取得更高层次的操作资格,则考虑借助外部资源或求助具备相应能力的人士协助处理。另外一种方法是尝试重启机器进入单用户模式,在那里通常不需要验证即可享有完全掌控力去修正相关设置[^5]。 ```bash # 单用户模式下的典型流程可能涉及这些步骤之一 mount -o remount,rw / vi /etc/sudoers ``` 以上就是针对 CentOS 7 中因缺少适当权限而产生的 “用户不在 sudoers 文件中” 错误的具体应对策略。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值