su進入超級用戶(root), 而後運行 visudo, 必定使用visudo命令來編輯,否則會提示以下錯誤:ide
「sudo: 沒有找到有效的 sudoers 資源,退出this
sudo: 沒法初始化策略插件 」spa
visudo默認打開/etc/sudoers文件進行編輯, 調用的nano編輯。插件
以下, 將XX處改成你的普通用戶, Ctrl+O寫入文件, Ctrl+X退出便可:code
1 root@bb-debian:/home/bb# cat /etc/sudoers 2 # 3 # This file MUST be edited with the 'visudo' command as root. 4 # 5 # Please consider adding local content in /etc/sudoers.d/ instead of 6 # directly modifying this file. 7 # 8 # See the man page for details on how to write a sudoers file. 9 # 10 Defaults env_reset 11 Defaults mail_badpass 12 Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 13 14 # Host alias specification 15 16 # User alias specification 17 18 # Cmnd alias specification 19 20 # User privilege specification 21 root ALL=(ALL:ALL) ALL 22 XX ALL=(ALL:ALL) ALL 23 24 # Allow members of group sudo to execute any command 25 %sudo ALL=(ALL:ALL) ALL 26 27 # See sudoers(5) for more information on "#include" directives: 28 29 #includedir /etc/sudoers.d