I changed the default username using usermod from pi, but since raspi-config assumes the user is "pi", I am now unable to have it automatically boot into the GUI. Is there another way to do this other than manually starting X?
You can manually modify the raspi-config script as follows. Let's presume we're using the username "bob".
sudo nano /usr/bin/raspi-config
then search for
Under that, there's a line where we will replace the "-u pi" with "-u bob", leaving the rest of the line unchanged:
if id -u pi > /dev/null 2>&1; then
Next edit the line:
sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi/"
autologin-user=pi to be
If you want a pretty menu and also error when it occurs, edit these lines:
whiptail --msgbox "The pi user has been removed, can't set up boot to desktop" 20 60 2 "Desktop" "Log in as user 'pi' at the graphical desktop" \
Again, replacing "pi" with "bob", or your username of choice.
Now the only thing left is enter raspi-config:
Select the third option:
3 Enable Boot to Desktop/Scratch
And then select the second:
Desktop Log in as user 'bob' at the graphical desktop
This way the configuration files are written (crucial) and you are ready to automatically boot into the GUI
I had changed the pi user name and disabled the root account password, then followed direction in the previous answer including the suggested edit to this:
sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi
but as Brandon indicated in his answer, I also had to edit the lightdm.conf file. Otherwise I got the graphical login prompt and an "x" placeholder above the login field where the Raspberry Pi logo would be. The auto login worked after the lightdm.conf edit.
In my case, I did not actually change (or delte) the default user "pi" user, I simply created a new user for myself and wanted to boot to that user by default. In that case, even after doing the above, I still ran into the issue of the system booting to the "pi" user by default. For some reason, the sed line was not actually updating lightdm.conf. So I simply edited lightdm.conf, which implicitly lists "pi" as the autologin-user, to my username. After that, it would successfully boot to my new user by default.
As of Raspberry Stretch you can simple login to youruser and call
sudo -s raspi-config
and in the Boot Options Menu "B" under "B1/B2" you'll find .. automatically logged in as 'youruser' user will be available as an option. Select it and reboot.
Emanuele, if the username pi is actualy deleted and/or replaced, like it was in my case, you also have to edit: "if id -u pi > /dev/null 2>&1; then" located 2 rows above, with the desired username instead of pi. This will avoid the username presence check.
I just want to add to the above that sometimes the auto-startx line can be found in
/etc/rc.local especially when dealing with touchscreen images obtained from vendors. I once was trying to disable startx and did not think of it being here. The line will before
exit 0. Just change the "pi" in that line to your new username and reboot!
I also need to modified /etc/lightdm/lightdm.conf, just need to remove the
autologin-user=pi line in this configuration file, remaining from old configuration script, then apply new configurations again with the new raspi-config script.