Ubuntu系统Root用户无法登录
默认 系统 root 登录 图形界面,出现 登录失败。解决方法如下:
1,登录普通用户, 打开终端执行命令, 使用su root或sudo -i切换到root用户(必须)
su root
按照提示输入密码即可切换用户。
若root账户密码忘记,使用如下命令重设后再切换。
sudo passwd root
2,在终端中输入如下命令,打开文件
gedit /etc/pam.d/gdm-autologin
将打开的文件中第三行前加#,如下注释掉语句 “auth required pam_succeed_if.so user != root quiet_success”
#%PAM-1.0 auth requisite pam_nologin.so #auth required pam_succeed_if.so user != root quiet_success auth optional pam_gdm.so auth optional pam_gnome_keyring.so auth required pam_permit.so @include common-account # SELinux needs to be the first session rule. This ensures that any # lingering context has been cleared. Without this it is possible # that a module could execute code in the wrong domain. session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close session required pam_loginuid.so # SELinux needs to intervene at login time to ensure that the process # starts in the proper default security context. Only sessions which are # intended to run in the user's context should be run after this. session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open session optional pam_keyinit.so force revoke session required pam_limits.so session required pam_env.so readenv=1 session required pam_env.so readenv=1 user_readenv=1 envfile=/etc/default/locale @include common-session session optional pam_gnome_keyring.so auto_start @include common-password
3,保存并退出,继续在终端执行
gedit /etc/pam.d/gdm-password
将打开的文件中第三行语句加#注释掉,如下图
#%PAM-1.0 auth requisite pam_nologin.so #auth required pam_succeed_if.so user != root quiet_success @include common-auth auth optional pam_gnome_keyring.so @include common-account # SELinux needs to be the first session rule. This ensures that any # lingering context has been cleared. Without this it is possible # that a module could execute code in the wrong domain. session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close session required pam_loginuid.so # SELinux needs to intervene at login time to ensure that the process # starts in the proper default security context. Only sessions which are # intended to run in the user's context should be run after this. # pam_selinux.so changes the SELinux context of the used TTY and configures # SELinux in order to transition to the user context with the next execve() # call. session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open session optional pam_keyinit.so force revoke session required pam_limits.so session required pam_env.so readenv=1 session required pam_env.so readenv=1 user_readenv=1 envfile=/etc/default/locale @include common-session session optional pam_gnome_keyring.so auto_start @include common-password
4,保存并退出。在终端继续执行
gedit /root/.profile
将打开的文件中“mesg n 2> /dev/null || true” 改为
tty -s&&mesg n 2> /dev/null || true
5,保存并退出。
6,重启电脑,即可以root用户登录。