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 !!
 
     
     
     
     
    
pi? Andsuasroot? ... You probably need to log out as userpibefore deleting userpi... BTW, if you want to login as root, all you need to do is set the password for root like this....sudo passwd rootand then you can login asroot– RubberStamp Nov 16 '17 at 14:13root... If you are looking for the process name, you can usps -u piwhich should return allPIDsfor that user. – RubberStamp Nov 16 '17 at 15:33
– FedeKrum Nov 16 '17 at 15:41root@raspberrypi:~# ps -u pi PID TTY TIME CMD 477 ? 00:00:00 systemd 484 ? 00:00:00 (sd-pam) 494 tty1 00:00:00 bashsystemdinit machine... which includes Raspbian. Sometimes a process started by a logged in user will hang thesd-pamclose. So, it's likely that somehow something was setup to autologin the userpior some sort ofchrootoption somewhere. If this is a new installation, it should be safe just tokillthe process and delete the user... Your OS seems to be listed as Raspbian... is itjessieorstretch? The official image ornoobs? – RubberStamp Nov 16 '17 at 17:50