Ubuntu disables root login by default. You do not need root login because sudo is enough. But if you need root login for some reason, this article will describe how to enable root login.
Table of Contents
1 Switch user to root with sudo and su
Combination sudo and su can switch user to root. You need sudo password and not need root password.
$ sudo su -
2 Create root password
By default in Ubuntu, root password is not created and root account is locked. Creating root password will unlock root account. And then you can login to root via tty (Ctrl + Alt + F1).
$ sudo passwd root Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
The following will lock root account.
$ sudo passwd -l root
3 Change sshd to allow root login via password
sshd in Ubuntu does not allow root login via password. You should login to root via public key authentication.
After creating root password and unlocking root account, the following will change sshd to allow root login via password.
$ sudo sed -e 's/^PermitRootLogin prohibit-password/PermitRootLogin yes/g' \ -i /etc/ssh/sshd_config $ sudo systemctl restart sshd
4 root login to desktop environment
After creating root password and unlocking root account, the following will enable root login to desktop environment.
$ echo 'greeter-show-manual-login=true' | \ sudo tee -a /etc/lightdm/lightdm.conf $ sudo cp /etc/skel/\.[^\.]* /root/ $ sudo systemctl restart lightdm
Input root as account name and input root password.