how to login with root user in ubuntu code example

Example 1: ubuntu root login ssh

echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
sudo systemctl restart sshd

# NOTE: root login is locked by default, assign a password with:
# [sudo passwd root]

# To lock root login afterwards run
# [sudo passwd -l root]

# To disable root login over ssh afterwards run
# [sed '$d' /etc/ssh/sshd_config | sudo tee /etc/ssh/sshd_config]

Example 2: how to become root user in ubuntu

sudo passwd root