環境:
OS:18.04.1
1.設定root賬號密碼
為root設定初始密碼
sudo passwd root
2.編輯檔案/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
在最後一行新增greeter-show-manual-login=true
greeter-show-manual-login=true
3.修改 /etc/pam.d/gdm-password 檔案,註釋掉第三行
root@hxl-VirtualBox:~# more /etc/pam.d/gdm-password
#%PAM-1.0
auth requisite pam_nologin.so
#auth required pam_succeed_if.so user != root quiet_success
4.修改 /etc/pam.d/gdm-autologin 檔案,註釋掉第三行
root@hxl-VirtualBox:~# more /etc/pam.d/gdm-autologin
#%PAM-1.0
auth requisite pam_nologin.so
#auth required pam_succeed_if.so user != root quiet_success
5.修改 /root/.profile 檔案,釋掉掉最後一行並增加 tty -s && mesg n || true 後儲存
root@hxl-VirtualBox:~# more /root/.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
6.重新啟動伺服器
reboot