9

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

to

   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

    autologin-user=pi

that I changed to

    autologin-user=gordon

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 !!

FedeKrum
  • 193
  • 1
  • 1
  • 5

3 Answers3

7

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/autologin@.service

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.

RubberStamp
  • 1,449
  • 1
  • 12
  • 16
5

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.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
Burd
  • 51
  • 1
  • 1
0

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/autologin@.service /etc/systemd/system/autologin@.service.bak

sudo mv /etc/systemd/system/getty@tty1.service.d/autologin.conf /etc/systemd/system/getty@tty1.service.d/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