0

I'm trying to rename the default pi username after getting a new raspberry pi 4. I am completely new to Linux, so my knowledge of the matter is small. From what I've discovered, one way to rename pi is to create a new root user and run commands from root. I ran the following command to do this,

sudo passwd root

I then entered the password, logged out of pi and into root. In root, I ran the following to change from pi to joffin (my favorite made up name),

root@raspberrypi:~# killall --user pi
root@raspberrypi:~# usermod -l joffin pi
usermod: user pi is currently used by process 8630

then ran this to get details for y'all to see (I don't know what this means).

root@raspberrypi:~# ps -lp 8630
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S  1000  8630     1  0  80   0 -  3679 do_epo ?        00:00:00 systemd

I tried again ...

root@raspberrypi:~# killall --user pi
root@raspberrypi:~# usermod -l joffin pi
usermod: user pi is currently used by process 8675
root@raspberrypi:~# ps -lp 8675
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S  1000  8675     1  0  80   0 -  3679 do_epo ?        00:00:00 systemd

How can I keep these new processes from spawning so that I can rename my pi?

2

Save yourself a lot of angst. There are a lot of similar posts, but no satisfactory solution.

As you have discovered the name pi is used in lots of places. It is coded into many scripts. It is not actually impossible to rename pi, but requires considerable Linux expertise.

What many of us do is create a new user and give this account all the privileges of the pi user. Even this requires some expertise but you can find tutorials.

The following will copy groups from user pi

sudo adduser username
#copy groups from user pi:-
    for GROUP in $(groups pi | sed 's/.*:\spi//'); do sudo adduser username $GROUP; done

You can then login to this account and prevent pi from logging in. It may be possible to then delete the pi account but there is little benefit.

6
  • I'll give this a try and get back with you Jan 11 at 3:56
  • See raspberrypi.stackexchange.com/a/36347/8697 which may help
    – Milliways
    Jan 11 at 4:02
  • I haven't done it yet, but would there be any bad consequences for deleting pi? Jan 11 at 4:19
  • One consequence is that if you haven't correctly and successfully transferred all the permissions to a new account, you'll end up locked out. It's really easier to just leave the pi account, maybe change its password for a while, and lock it out when you are very sure.
    – user10489
    Jan 11 at 6:05
  • @user10489 Would adduser joffin sudo from root successfully transfer everything? Jan 11 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.