Linux下sudo命令无法使用及报sudoers.d下某文件语法错误-编程思维

Linux下sudo命令无法使用及报sudoers.d下某文件语法错误

在这种情况下 我们是往往进入不到root模式下的

问题来源:添加用户的时候重复添加等导致。

sudoers文件错误

  1. pkexec visudo命令打开sudoers文件

  2. 修改该文件(此处展示一份无错配置)

    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # Please consider adding local content in /etc/sudoers.d/ instead of
    # directly modifying this file.
    #
    # See the man page for details on how to write a sudoers file.
    #
    Defaults	env_reset
    Defaults	mail_badpass
    Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root	ALL=(ALL:ALL) ALL
    stack   ALL=(ALL) NOPASSWD: ALL
    #dengschoo  ALL=(ALL:ALL) ALL
    # 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
    
    # See sudoers(5) for more information on "#include" directives:
    #includedir /etc/sudoers.d
    
  3. ESC: Ctrl + X保存退出(可能要按两次 多看提示)

  4. 再尝试sudo命令等 检查是否还有其它问题

sudoers.d目录下某个文件报错

这种情况下sudoers文件是没有问题的 就需要先把sudoers.d目录从sudoers文件中移除

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults	env_reset
Defaults	mail_badpass
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL:ALL) ALL
stack   ALL=(ALL) NOPASSWD: ALL
#dengschoo  ALL=(ALL:ALL) ALL
# 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

# See sudoers(5) for more information on "#include" directives:


#就是这句 包含了该目录下的其他用户的权限 把它注释
#includedir /etc/sudoers.d

#includedir /etc/sudoers.d => ##includedir /etc/sudoers.d

然后就可以正常使用sudo命令了 就可以切换到root用户 然后删除或者修改出问题的文件了。

修改完成后别忘记重新 把刚才的注释改回来 为了不影响以后其它操作。

完全删除用户

userdel -r username

find / -name "*haha*"查看是否还有与该用户相关的文件

版权声明:本文版权归作者所有,遵循 CC 4.0 BY-SA 许可协议, 转载请注明原文链接
https://www.cnblogs.com/DengSchoo/p/15496246.html

Java生产环境JVM设置成固定堆大小深层原理-编程思维

  可能很多人都知道Java程序上生产后,运维人员都会设定好JVM的堆大小,而且还是把最大最小设置成一样的值。那究竟是为什么呢?一般而言,Java程序如果你不显示设定该值得话,会自动进行初始化设定。   -Xmx 的默认值为你当前机器最大内存的 1/4   -Xms 的默认值为你当前机器最大内存的 1/64    显然

如何在Docker容器中使用Arthas-编程思维

Arthas(阿尔萨斯) 能为你做什么? Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。 当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决: 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception? 我改的代码为什么没有执行到?难道是我没 commit?分支搞错

linux(centos8):基于java13安装rocketmq-4.7.1(解决jdk不兼容的报错)-编程思维

一,Rocketmq是什么? 1, RocketMQ是一个队列模型的消息中间件,具有高性能、高可靠、高实时、分布式特点 相比kafka,rocketmq的实时性更强 2,官方网站: http://rocketmq.apache.org/   说明:刘宏缔的架构森林是一个专注架构的博客,地址:https:/

IEnumerable踩过的坑-编程思维

1. 查询接口:建议使用IEnumerable 更新、创建接口:不要使用IEnumerable(maybe 接口会重复调用);建议使用可以讲结果保存到内存中的类型(like:IList、IDictionary)   var result = _serv

【Git】Git常见问题汇总-编程思维

Git常见问题汇总及解决方案 目录 访问速度过慢 openssl errno10054 Timeout errno 443 远程库与本地库不一致 github.io无法打开 上传文件过慢 访问github速度过慢 DNS请求问题 需要查一下github.com这个地址的ip,在本地dns缓存即hosts文件,具体路