usermod -l new_username -m -d /home/new_username pi
- -l new value of the login name
- -m move contents of the home directory to the
- -d new home directory for the user account
Also, change default user’s group name:
groupmod -n new_username pi
To successfully change it, pi user can’t be logged in. You have to log in as root (or another user in sudo group) and execute above commands.