I was really tired, and after tossing for a day, I couldn't find a solution. Finally, I tried the next article to let the root user log in automatically, and finally succeeded.
1. Log in to the Ubuntu graphical interface as an ordinary user, enter the terminal, and switch to the root user.
Enter the command: vim /usr/share/lightdm/lightdm.d/50-ubuntu.conf, append two lines to the end of the file
greeter-show-manual-login=true
allow-guest=false
2. If it still does not take effect, directly set the automatic root user login
Enter the command: vim /etc/lightdm/lightdm.conf
Add the following information:
[Seat:*]
autologin-guest=false
autologin-user=root
greeter-session=lightdm-gtk-greeter
3. If you log in with the root user in the GUI now, there will be an error, an error occurs when reading /root/.profile: mesg:tty n
The following modifications are also required:
Enter the command: vi /root/.profile
replace mesg n || true with
tty -s && mesg n || true