ubuntu 搞坏了sudoers文件之修复方案
2016-11-11 14:31
330 查看
pkexec visudo
askubuntu原回答摘抄如下
On a modern Ubuntu system (and many other GNU/Linux distributions), fixing a corrupted sudoers file is actually quite easy, and doesn't require rebooting, using a live CD, or physical access to the machine. To do this via SSH, log in to the machine and run the command pkexec visudo. If you have physical access to the machine, SSH is unnecessary; just open a Terminal window and run that pkexec command. Assuming you (or some other user) are authorized to run programs as root with PolicyKit, you can enter your password, and then it will run visudo as root, and you can fix your /etc/sudoers. If you need to edit one of the configuration files in /etc/sudoers.d (which in uncommon in this situation, but possible), use pkexec visudo -f /etc/sudoers.d/filename. If you have a related situation where you have to perform additional system administration commands as root to fix the problem (also uncommon in this circumstance, but common in others), you can start an interactive root shell with pkexec bash. Generally speaking, any non-graphical command you'd run with sudo can be run with pkexec instead. (If there is more than one user account on the system authorized to run programs as root with PolicyKit, then for any of those actions, you'll be asked to select which one you want to use, before being asked for your password.) If that doesn't work--for example, if there are no users authorized to run programs as root via PolicyKit--then boot from an Ubuntu live CD (like the CD you probably used to install Ubuntu) and mount the filesystem for the installed system. You can do this by running sudo parted -l to view your partitions--there is probably just one ext4 partition, and that's the root filesystem. Suppose the installed Ubuntu system's root filesystem is on /dev/sda1. Then you could mount it with sudo mount /dev/sda1 /mnt. Then you can edit the installed system's sudoers file with sudo nano -w /mnt/etc/sudoers. Or, even better, you can edit it with sudo visudo -f /mnt/etc/sudoers (which will prevent you from saving a sudoers file with incorrect syntax).
相关文章推荐
- Linux 设置sudo免密码 及 sudoers文件损坏修复方案
- Ubuntu10.04 sudoers文件损坏又没有root密码修复
- 解决Ubuntu 14.04 sudoers 文件修复问题
- ubuntu14.04 /etc/sudoers文件损坏修复
- ubuntu中的sudoers文件损坏,修复办法(附图、详细)
- /etc/sudoers文件损坏修复
- Linux 设置sudo免密码 及 sudoers文件损坏修复
- ubuntu root认证失败 用户名 不在 sudoers文件中,此事将被报告
- ubuntu 用户不在 sudoers文件中,此事将被报告。
- Ubuntu无法sudo提权,报当前用户不在sudoers文件中错误
- ubuntu 用户不在sudoers文件中
- Ubuntu 不在sudoers文件中
- Ubuntu无法sudo提权,报当前用户不在sudoers文件中错误
- ubuntu中sudo不能使用的问题,/etc/sudoers文件不存在
- ubuntu修改用户名称和计算机名称以及“不在sudoers 文件中。此事将被报告。”
- 树莓派 修复etc/sudoers文件
- 关于解决ubuntu误改sudoers文件的解决办法
- 烂泥:【解决】ubuntu提示ilanni不在sudoers文件中错误
- Linux/Ubuntu sudoers 文件妙用
- ubuntu下更改/etc/sudoers文件的命令