參考網址http://www.maketecheasier.com/fixing-sudo-error-in-ubuntu/
使用環境Ubuntu Linux系統下:
在學習鳥哥的私房菜時,使用瞭如下命令
<span style="font-size:18px;">usermod -G users username</span>
username爲你自己的用戶名。
由於沒有使用-a參數導致我的用戶被分到了users用戶組裏,而原先的用戶組被重置掉,僅剩下users用戶組
由於沒有sudo用戶組,因此無法使用sudo的命令。
解決方法:在x-windows圖形界面下reboot系統
然後進入grub界面選擇選中的項
選擇fsck,等待30秒左右
點擊root項進入root下的命令行
在命令行中輸入
<span style="font-size:18px;">usermod -a -G sudo username
usermod -a -G adm username</span>
有的系統是admin,但我的系統是adm,不過我看了sudoers文件裏的內容中用的是admin,
在我的/etc/group中沒有admin這一項,所以我添加adm是無法讓我的用戶使用sudo的,因此還是要加入sudo用戶組
<span style="font-size:18px;">#
# 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
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root 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
#includedir /etc/sudoers.d</span>
然後點擊resume重啓系統
重啓後就可以進入root了。
如果你可以直接用su - 命令直接進入超級root用戶,那麼就可以直接修改/etc/sudoers文件
並改動username用戶所屬的用戶組。