在这种情况下 我们是往往进入不到root模式下的
问题来源:添加用户的时候重复添加等导致。
pkexec visudo
命令打开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
ESC: Ctrl + X
保存退出(可能要按两次 多看提示)
再尝试sudo命令等 检查是否还有其它问题
这种情况下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*"
查看是否还有与该用户相关的文件