ubuntu18.04 桌面允许root账户直接登录设置

1.通过其他账号登录系统,例如test

切换至root 账号,并设置root密码

test@Testmysql:~$sudo su -
[sudo] password for test:****** root@Testmysql:~# passwd root

2 修改root账号下的/root/.profile 文件

vim /root/.profile

root@Testmysql:~# cat .profile
# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi

#mesg n || true
tty -s && mesg n || true

 3.进入目录/etc/pam.d目录,修改gdm-autologin和gdm-password两个文件

3.1注释gdm-autologin文件中红色字体行

root@Testmysql:/etc/pam.d# cat gdm-autologin 
#%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.2注释gdm-password文件中红色字体行

root@Testmysql:/etc/pam.d# cat 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.
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.进入/usr/share/lightdm/lightdm.conf.d/目录,编辑50-ubuntu.conf文件,在文件中增加红色标记字体行

root@Testmysql:/usr/share/lightdm/lightdm.conf.d# cat 50-ubuntu.conf 
[Seat:*]
user-session=ubuntu
greeter-show-manual-login=true
all-guest=false

5.注销或重启系统,重新登录,即可直接通过root登录系统

 

posted @ 2022-02-16 10:10  彦祚  阅读(696)  评论(0编辑  收藏  举报