I have made a new Raspbian installation. All good. I wanted to delete pi user and make another user with same privileges (lets say gordon).

So first I enabled direct ssh access to user root by doing this:

   sudo nano /etc/ssh/sshd_config

...and editing the line

  #PermitRootLogin prohibit-password


   PermitRootLogin yes

Then I restarted and directly login as root.

So I followed https://gordonlesti.com/change-default-users-on-raspberry-pi/ recommendations.

I added a step to make new user gordon belong to the same exact groups pi belongs. So I did this to know those groups...

  root@raspberrypi:~# groups pi
  pi : pi adm dialout cdrom sudo audio video plugdev games users input netdev spi i2c gpio

... and then this to make new user belong to them.

  root@raspberrypi:~# usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio gordon

I also did a change in /etc/lightdm/lightdm.conf at line


that I changed to


All good til I get to "Delete pi" step in the guide.

I get this error:

 deluser pi
 Removing user `pi' ...
 Warning: group `pi' has no more members.
 userdel: user pi is currently used by process 445
 /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

So I did a

  ps -aux| grep 445

and I got

   pi  445  0.0  0.6  9768  5944  ?  Ss  13:28  0:00  /lib/systemd/systemd --user

So I have several questions.

  • How to know what is that process?

  • Supposing my new user name is gordon ..... how can I make this process not run as pi anymore and run as gordon ?

Thanks !!

  • Are you logged in as user pi ? And su as root ? ... You probably need to log out as user pi before deleting user pi ... BTW, if you want to login as root, all you need to do is set the password for root like this.... sudo passwd root and then you can login as root Nov 16, 2017 at 14:13
  • @RubberStamp, I did logon directly as root, so I added that step to the original question. Thanks
    – FedeKrum
    Nov 16, 2017 at 14:27
  • 1
    I've never had problems deleting a user on the RPi when logged in as root ... If you are looking for the process name, you can us ps -u pi which should return all PIDs for that user. Nov 16, 2017 at 15:33
  • @RubberStamp, I get this. root@raspberrypi:~# ps -u pi PID TTY TIME CMD 477 ? 00:00:00 systemd 484 ? 00:00:00 (sd-pam) 494 tty1 00:00:00 bash
    – FedeKrum
    Nov 16, 2017 at 15:41
  • See this Unix Linux question Nov 16, 2017 at 15:51

3 Answers 3


I think I tracked it down for you...

You removed the lightdm autologin for user pi ... but, if you are using noobs, there is another autologin here:

/etc/systemd/system/[email protected]

line 28:

ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM

So, it seems that noobs is has two locations for autologin with the user pi

Remove the second one, and see what happens.

  • How to remove "the second one"? sudo rm /etc/systemd/system/[email protected]?
    – Flux
    Jul 14, 2019 at 3:27

I did what rubberstamp did, but it still did noy work.

So I went to preferences, raspberry pi configuration and removed the check from auto login. Then it worked for me.


Rename both files and terminal autologins will not occur on the next reboot. A reboot is required or autologin will continue to relogin anytime these terminals exits.

sudo mv /etc/systemd/system/[email protected] /etc/systemd/system/[email protected]

sudo mv /etc/systemd/system/[email protected]/autologin.conf /etc/systemd/system/[email protected]/autologin.conf.bak

For lightdm, I comment out the autologin line with:

sudo sed -i.bak 's/^autologin-user=pi/#autologin-user=pi/g;' /etc/lightdm/lightdm.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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