Change Username and Password

Set the root password so you can log in as root then logout as pi

sudo passwd root

Log in as root using the password you set then change the username

usermod -l newname pi
usermod -m -d /home/newname newname

Now logout and login back in and set the new users password

sudo passwd newname

Check that sudo works for the new username with

sudo apt update

Finally you can disable the root password with

sudo passwd -l root

Updated Aug 22, 2019