Note: This has been tested in Rasbian Buster released on 2019-06-20
Important: replace
jeremy
below with whatever username you'd like as your new user.
sudo adduser jeremy
- You will be asked to enter a password
- When filling out basic information about the user, you may leave it blank
Adding user `jeremy' ... Adding new group `jeremy' (1001) ... Adding new user `jeremy' (1001) with group `jeremy' ... jeremy ALL=(ALL) NOPASSWD: ALL Creating home directory `/home/jeremy' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully Changing the user information for jeremy Enter the new value, or press ENTER for the default Full Name []: Jeremy Iglehart Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y
sudo adduser jeremy sudo
Adding user `jeremy' to group `sudo' ... Adding user jeremy to group sudo Done.
sudo cp /etc/sudoers.d/010_pi-nopasswd /etc/sudoers.d/010_jeremy-nopasswd
- If you don't like typing in the sudo password all the time, copy this file.
sudo chmod u+w /etc/sudoers.d/010_jeremy-nopasswd
- Add write permissions (so that you can change it)
sudo vi /etc/sudoers.d/010_jeremy-nopasswd
- Change "pi" to "jeremy"
sudo chmod u-w /etc/sudoers.d/010_jeremy-nopasswd
- remove write permissions (should be 0440 or
-r--r-----
)
- remove write permissions (should be 0440 or
sudo reboot
- To allow all settings to go into effect. You may get away with something else here - but rebooting does the trick. Also it ensures that the
pi
user is fully logged out and has nothing left running.
- To allow all settings to go into effect. You may get away with something else here - but rebooting does the trick. Also it ensures that the
- Login as your new user
sudo deluser -remove-home pi
If you try to do this before rebooting you will see something like this:Looking for files to backup/remove ... Removing user `pi' ... Warning: group `pi' has no more members. Done.
Looking for files to backup/remove ... Removing files ... sh: 0: getcwd() failed: No such file or directory Removing user `pi' ... Warning: group `pi' has no more members. userdel: user pi is currently used by process 702 /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.
sudo rm -vf /etc/sudoers.d/010_pi-nopasswd
removed '/etc/sudoers.d/010_pi-nopasswd'
Done.
also note, on a fresh system where you haven't set any locale you will see this a lot:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "en_US.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
Credit: https://raspi.tv/2012/how-to-create-a-new-user-on-raspberry-pi So, I first tried a few things outlined in this article above and found out quickly that the way Raspberry Pi is setting up the pi user is different than in this article, hence writing this new gist. After some trial and error I ended up settling on the method I describe here in this gist. I'd like to give credit to what got me started on this path.
I followed all these steps, and created a new user but when I get to Step 8: I rebooted and logged in as my new user, tried to delete the pi user and got the error:
"userdel: user pi is currently used by process 543"
What happens is that the Raspberry Noobs version logs in the pi user automatically. I had to go to the Preferences>Raspberry Pi Configuration menu and untick the box "Login as Pi," reboot, login with the new user then I was able to delete pi user. In case someone else has this issue.