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
  • 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 – RubberStamp Nov 16 '17 at 14:13
  • @RubberStamp, I did logon directly as root, so I added that step to the original question. Thanks – FedeKrum Nov 16 '17 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. – RubberStamp Nov 16 '17 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 '17 at 15:41
  • @RubberStamp, no clue on that. Maybe I am not that sharp on it. – FedeKrum Nov 16 '17 at 16:03
  • The (sd-sam) process is a fork of PID 1. It's a normal process associated with logged in users on a systemd init machine... which includes Raspbian. Sometimes a process started by a logged in user will hang the sd-pam close. So, it's likely that somehow something was setup to autologin the user pi or some sort of chroot option somewhere. If this is a new installation, it should be safe just to kill the process and delete the user... Your OS seems to be listed as Raspbian... is it jessie or stretch? The official image or noobs ? – RubberStamp Nov 16 '17 at 17:50
  • Use pw or usermod. Or vipw. Delete the pi user. Fix any ensuinf errors. – user2497 Nov 18 '17 at 11:12

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,399
  • 1
  • 10
  • 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,855
  • 15
  • 61
  • 119
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