Why failing to delete user in Raspbian?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
1












I do successfully in Raspbian Jessie of Raspberry Pi 3b



% http://askubuntu.com/a/227513/25388
masi@raspberrypi:~ $ sudo locale-gen en_US en_US.UTF-8
masi@raspberrypi:~ $ sudo dpkg-reconfigure locales


I run sudo deluser pi but I get



perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 929
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


I also tried the fix if polylocale problem unsuccessfully



for y in $(locale | cut -d '=' -f 2| sort |uniq );do sudo locale-gen $y; done


I do



masi@raspberrypi:~ $ ps -fp 929
UID PID PPID C STIME TTY TIME CMD
pi 929 1 0 08:54 ? 00:00:00 /usr/lib/menu-cache/menu-cached /tmp/.


I do



masi@raspberrypi:~ $ sudo kill 929

masi@raspberrypi:~ $ sudo deluser pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 1174
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

masi@raspberrypi:~ $ sudo deluser -remove-home pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Looking for files to backup/remove ...
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 1174
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

masi@raspberrypi:~ $


I kill now the process id 1174 but I get exactly same output, but now giving a new process id 1202.
I do sudo killall -u pi -m . but I get
Usage: killall [OPTION]... [--] NAME...



I do



masi@raspberrypi:~ $ sudo pkill -u pi 

masi@raspberrypi:~ $ sudo deluser pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
...
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 3422
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


I do



masi@raspberrypi:~ $ ps -u pi
PID TTY TIME CMD
3422 tty1 00:00:00 bash

masi@raspberrypi:~ $ sudo kill 3422

masi@raspberrypi:~ $ sudo deluser pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 3496
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


I do



masi@raspberrypi:~ $ who
pi tty1 Jun 4 09:38
masi pts/0 Jun 4 09:06 (masi)


I do



masi@raspberrypi:~ $ sudo skill -KILL -u pi

masi@raspberrypi:~ $ sudo deluser pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 3496
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


I do Stephen's proposal but



masi@raspberrypi:~ $ sudo service lightdm stop

masi@raspberrypi:~ $ sudo deluser pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 3496
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


My second iteration of the commands included again trying to change the locales by the first step of commands, again unsuccessfully.



I do



masi@raspberrypi:~ $ ps -ft tty1
UID PID PPID C STIME TTY TIME CMD
root 3491 1 0 09:38 tty1 00:00:00 /bin/login -f
pi 3507 3491 0 09:38 tty1 00:00:00 -bash


I do sudo vim /etc/inittab but the file is empty.
I do masi@raspberrypi:~ $ sudo grep -r "login -f" /etc but nothing as output.



I do



masi@raspberrypi:~ $ sudo grep -r autologin /etc
/etc/lightdm/lightdm.conf:# pam-autologin-service = PAM service to use for autologin
/etc/lightdm/lightdm.conf:# autologin-guest = True to log in as guest by default
/etc/lightdm/lightdm.conf:# autologin-user = User to log in with by default (overrides autologin-guest)
/etc/lightdm/lightdm.conf:# autologin-user-timeout = Number of seconds to wait before loading default user
/etc/lightdm/lightdm.conf:# autologin-session = Session to load for automatic login (overrides user-session)
/etc/lightdm/lightdm.conf:# autologin-in-background = True if autologin session should not be immediately activated
/etc/lightdm/lightdm.conf:#pam-autologin-service=lightdm-autologin
/etc/lightdm/lightdm.conf:#autologin-guest=false
/etc/lightdm/lightdm.conf:autologin-user=pi
/etc/lightdm/lightdm.conf:#autologin-user-timeout=0
/etc/lightdm/lightdm.conf:#autologin-in-background=false
/etc/lightdm/lightdm.conf:#autologin-session=UNIMPLEMENTED
/etc/systemd/system/autologin@.service:ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM


Content of /etc/lightdm/lightdm.conf



# General configuration
#
# start-default-seat = True to always start one seat if none are defined in the configuration
# greeter-user = User to run greeter as
# minimum-display-number = Minimum display number to use for X servers
# minimum-vt = First VT to run displays on
# lock-memory = True to prevent memory from being paged to disk
# user-authority-in-system-dir = True if session authority should be in the system location
# guest-account-script = Script to be run to setup guest account
# logind-load-seats = True to automatically set up multi-seat configuration from logind
# logind-check-graphical = True to on start seats that are marked as graphical by logind
# log-directory = Directory to log information to
# run-directory = Directory to put running state in
# cache-directory = Directory to cache to
# sessions-directory = Directory to find sessions
# remote-sessions-directory = Directory to find remote sessions
# greeters-directory = Directory to find greeters
#
[LightDM]
#start-default-seat=true
#greeter-user=lightdm
#minimum-display-number=0
#minimum-vt=7
#lock-memory=true
#user-authority-in-system-dir=false
#guest-account-script=guest-account
#logind-load-seats=false
#logind-check-graphical=false
#log-directory=/var/log/lightdm
#run-directory=/var/run/lightdm
#cache-directory=/var/cache/lightdm
#sessions-directory=/usr/share/lightdm/sessions:/usr/share/xsessions
#remote-sessions-directory=/usr/share/lightdm/remote-sessions
#greeters-directory=/usr/share/lightdm/greeters:/usr/share/xgreeters

#
# Seat defaults
#
# type = Seat type (xlocal, xremote)
# xdg-seat = Seat name to set pam_systemd XDG_SEAT variable and name to pass to X server
# pam-service = PAM service to use for login
# pam-autologin-service = PAM service to use for autologin
# pam-greeter-service = PAM service to use for greeters
# xserver-command = X server command to run (can also contain arguments e.g. X -special-option)
# xserver-layout = Layout to pass to X server
# xserver-config = Config file to pass to X server
# xserver-allow-tcp = True if TCP/IP connections are allowed to this X server
# xserver-share = True if the X server is shared for both greeter and session
# xserver-hostname = Hostname of X server (only for type=xremote)
# xserver-display-number = Display number of X server (only for type=xremote)
# xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
# xdmcp-port = XDMCP UDP/IP port to communicate on
# xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
# unity-compositor-command = Unity compositor command to run (can also contain arguments e.g. unity-system-compositor -special-option)
# unity-compositor-timeout = Number of seconds to wait for compositor to start
# greeter-session = Session to load for greeter
# greeter-hide-users = True to hide the user list
# greeter-allow-guest = True if the greeter should show a guest login option
# greeter-show-manual-login = True if the greeter should offer a manual login option
# greeter-show-remote-login = True if the greeter should offer a remote login option
# user-session = Session to load for users
# allow-user-switching = True if allowed to switch users
# allow-guest = True if guest login is allowed
# guest-session = Session to load for guests (overrides user-session)
# session-wrapper = Wrapper script to run session with
# greeter-wrapper = Wrapper script to run greeter with
# guest-wrapper = Wrapper script to run guest sessions with
# display-setup-script = Script to run when starting a greeter session (runs as root)
# display-stopped-script = Script to run after stopping the display server (runs as root)
# greeter-setup-script = Script to run when starting a greeter (runs as root)
# session-setup-script = Script to run when starting a user session (runs as root)
# session-cleanup-script = Script to run when quitting a user session (runs as root)
# autologin-guest = True to log in as guest by default
# autologin-user = User to log in with by default (overrides autologin-guest)
# autologin-user-timeout = Number of seconds to wait before loading default user
# autologin-session = Session to load for automatic login (overrides user-session)
# autologin-in-background = True if autologin session should not be immediately activated
# exit-on-failure = True if the daemon should exit if this seat fails
#
[SeatDefaults]
#type=xlocal
#xdg-seat=seat0
#pam-service=lightdm
#pam-autologin-service=lightdm-autologin
#pam-greeter-service=lightdm-greeter
#xserver-command=X
#xserver-layout=
#xserver-config=
#xserver-allow-tcp=false
#xserver-share=true
#xserver-hostname=
#xserver-display-number=
#xdmcp-manager=
#xdmcp-port=177
#xdmcp-key=
#unity-compositor-command=unity-system-compositor
#unity-compositor-timeout=60
#greeter-session=example-gtk-gnome
#greeter-hide-users=false
#greeter-allow-guest=true
#greeter-show-manual-login=false
#greeter-show-remote-login=true
#user-session=default
#allow-user-switching=true
#allow-guest=true
#guest-session=
#session-wrapper=lightdm-session
#greeter-wrapper=
#guest-wrapper=
#display-setup-script=
#display-stopped-script=
#greeter-setup-script=
#session-setup-script=
#session-cleanup-script=
#autologin-guest=false
autologin-user=pi
#autologin-user-timeout=0
#autologin-in-background=false
#autologin-session=UNIMPLEMENTED
#exit-on-failure=false

#
# Seat configuration
#
# Each seat must start with "Seat:".
# Uses settings from [SeatDefaults], any of these can be overriden by setting them in this section.
#
#[Seat:0]

#
# XDMCP Server configuration
#
# enabled = True if XDMCP connections should be allowed
# port = UDP/IP port to listen for connections on
# key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf)
#
# The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn. Alternatively
# it can be a word and the first 7 characters are used as the key.
#
[XDMCPServer]
#enabled=false
#port=177
#key=

#
# VNC Server configuration
#
# enabled = True if VNC connections should be allowed
# command = Command to run Xvnc server with
# port = TCP/IP port to listen for connections on
# width = Width of display to use
# height = Height of display to use
# depth = Color depth of display to use
#
[VNCServer]
#enabled=false
#command=Xvnc
#port=5900
#width=1024
#height=768
#depth=8


I do



masi@raspberrypi:~ $ sudo systemctl disable autologin@tty1

masi@raspberrypi:~ $ ps -fu pi
UID PID PPID C STIME TTY TIME CMD
pi 3496 1 0 09:38 ? 00:00:00 /lib/systemd/systemd --user
pi 3502 3496 0 09:38 ? 00:00:00 (sd-pam)
pi 3507 3491 0 09:38 tty1 00:00:00 -bash

masi@raspberrypi:~ $ sudo kill 3496 3502 3507

masi@raspberrypi:~ $ ps -fu pi
UID PID PPID C STIME TTY TIME CMD
pi 7062 1 1 21:46 ? 00:00:00 /lib/systemd/systemd --user
pi 7068 7062 0 21:46 ? 00:00:00 (sd-pam)
pi 7073 7056 6 21:46 tty1 00:00:00 -bash


The file /etc/systemd/system/autologin@.service



# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0

[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

[Install]
WantedBy=getty.target
DefaultInstance=tty1


I do



masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

masi@raspberrypi:~ $ ps -fu pi
UID PID PPID C STIME TTY TIME CMD

masi@raspberrypi:~ $ sudo deluser pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LC_ADDRESS = "fi_FI.UTF-8",
LC_MONETARY = "fi_FI.UTF-8",
LC_NUMERIC = "fi_FI.UTF-8",
LC_TELEPHONE = "fi_FI.UTF-8",
LC_IDENTIFICATION = "fi_FI.UTF-8",
LC_MEASUREMENT = "fi_FI.UTF-8",
LC_TIME = "fi_FI.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Removing user `pi' ...
Warning: group `pi' has no more members.
Done.


Problems



  • it creates always a new process to the user pi after removing its current processes. How can you prevent this?

Successful attempt [Stephen]



Do



masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

masi@raspberrypi:~ $ ps -fu pi
UID PID PPID C STIME TTY TIME CMD

masi@raspberrypi:~ $ sudo deluser pi
...

masi@raspberrypi:~ & sudo vim /etc/passwd
... pi no longer here!

masi@raspberrypi:~ & sudo deluser -remove-home pi


Solution of locale problem is in the thread here.



Replace autologin-user=pi with autologin-user=masi in /etc/lightdm/lightdm.conf.




How can you remove the pi user successfully?










share|improve this question



























    up vote
    4
    down vote

    favorite
    1












    I do successfully in Raspbian Jessie of Raspberry Pi 3b



    % http://askubuntu.com/a/227513/25388
    masi@raspberrypi:~ $ sudo locale-gen en_US en_US.UTF-8
    masi@raspberrypi:~ $ sudo dpkg-reconfigure locales


    I run sudo deluser pi but I get



    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 929
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


    I also tried the fix if polylocale problem unsuccessfully



    for y in $(locale | cut -d '=' -f 2| sort |uniq );do sudo locale-gen $y; done


    I do



    masi@raspberrypi:~ $ ps -fp 929
    UID PID PPID C STIME TTY TIME CMD
    pi 929 1 0 08:54 ? 00:00:00 /usr/lib/menu-cache/menu-cached /tmp/.


    I do



    masi@raspberrypi:~ $ sudo kill 929

    masi@raspberrypi:~ $ sudo deluser pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 1174
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

    masi@raspberrypi:~ $ sudo deluser -remove-home pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Looking for files to backup/remove ...
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 1174
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

    masi@raspberrypi:~ $


    I kill now the process id 1174 but I get exactly same output, but now giving a new process id 1202.
    I do sudo killall -u pi -m . but I get
    Usage: killall [OPTION]... [--] NAME...



    I do



    masi@raspberrypi:~ $ sudo pkill -u pi 

    masi@raspberrypi:~ $ sudo deluser pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    ...
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 3422
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


    I do



    masi@raspberrypi:~ $ ps -u pi
    PID TTY TIME CMD
    3422 tty1 00:00:00 bash

    masi@raspberrypi:~ $ sudo kill 3422

    masi@raspberrypi:~ $ sudo deluser pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 3496
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


    I do



    masi@raspberrypi:~ $ who
    pi tty1 Jun 4 09:38
    masi pts/0 Jun 4 09:06 (masi)


    I do



    masi@raspberrypi:~ $ sudo skill -KILL -u pi

    masi@raspberrypi:~ $ sudo deluser pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 3496
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


    I do Stephen's proposal but



    masi@raspberrypi:~ $ sudo service lightdm stop

    masi@raspberrypi:~ $ sudo deluser pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    userdel: user pi is currently used by process 3496
    /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


    My second iteration of the commands included again trying to change the locales by the first step of commands, again unsuccessfully.



    I do



    masi@raspberrypi:~ $ ps -ft tty1
    UID PID PPID C STIME TTY TIME CMD
    root 3491 1 0 09:38 tty1 00:00:00 /bin/login -f
    pi 3507 3491 0 09:38 tty1 00:00:00 -bash


    I do sudo vim /etc/inittab but the file is empty.
    I do masi@raspberrypi:~ $ sudo grep -r "login -f" /etc but nothing as output.



    I do



    masi@raspberrypi:~ $ sudo grep -r autologin /etc
    /etc/lightdm/lightdm.conf:# pam-autologin-service = PAM service to use for autologin
    /etc/lightdm/lightdm.conf:# autologin-guest = True to log in as guest by default
    /etc/lightdm/lightdm.conf:# autologin-user = User to log in with by default (overrides autologin-guest)
    /etc/lightdm/lightdm.conf:# autologin-user-timeout = Number of seconds to wait before loading default user
    /etc/lightdm/lightdm.conf:# autologin-session = Session to load for automatic login (overrides user-session)
    /etc/lightdm/lightdm.conf:# autologin-in-background = True if autologin session should not be immediately activated
    /etc/lightdm/lightdm.conf:#pam-autologin-service=lightdm-autologin
    /etc/lightdm/lightdm.conf:#autologin-guest=false
    /etc/lightdm/lightdm.conf:autologin-user=pi
    /etc/lightdm/lightdm.conf:#autologin-user-timeout=0
    /etc/lightdm/lightdm.conf:#autologin-in-background=false
    /etc/lightdm/lightdm.conf:#autologin-session=UNIMPLEMENTED
    /etc/systemd/system/autologin@.service:ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM


    Content of /etc/lightdm/lightdm.conf



    # General configuration
    #
    # start-default-seat = True to always start one seat if none are defined in the configuration
    # greeter-user = User to run greeter as
    # minimum-display-number = Minimum display number to use for X servers
    # minimum-vt = First VT to run displays on
    # lock-memory = True to prevent memory from being paged to disk
    # user-authority-in-system-dir = True if session authority should be in the system location
    # guest-account-script = Script to be run to setup guest account
    # logind-load-seats = True to automatically set up multi-seat configuration from logind
    # logind-check-graphical = True to on start seats that are marked as graphical by logind
    # log-directory = Directory to log information to
    # run-directory = Directory to put running state in
    # cache-directory = Directory to cache to
    # sessions-directory = Directory to find sessions
    # remote-sessions-directory = Directory to find remote sessions
    # greeters-directory = Directory to find greeters
    #
    [LightDM]
    #start-default-seat=true
    #greeter-user=lightdm
    #minimum-display-number=0
    #minimum-vt=7
    #lock-memory=true
    #user-authority-in-system-dir=false
    #guest-account-script=guest-account
    #logind-load-seats=false
    #logind-check-graphical=false
    #log-directory=/var/log/lightdm
    #run-directory=/var/run/lightdm
    #cache-directory=/var/cache/lightdm
    #sessions-directory=/usr/share/lightdm/sessions:/usr/share/xsessions
    #remote-sessions-directory=/usr/share/lightdm/remote-sessions
    #greeters-directory=/usr/share/lightdm/greeters:/usr/share/xgreeters

    #
    # Seat defaults
    #
    # type = Seat type (xlocal, xremote)
    # xdg-seat = Seat name to set pam_systemd XDG_SEAT variable and name to pass to X server
    # pam-service = PAM service to use for login
    # pam-autologin-service = PAM service to use for autologin
    # pam-greeter-service = PAM service to use for greeters
    # xserver-command = X server command to run (can also contain arguments e.g. X -special-option)
    # xserver-layout = Layout to pass to X server
    # xserver-config = Config file to pass to X server
    # xserver-allow-tcp = True if TCP/IP connections are allowed to this X server
    # xserver-share = True if the X server is shared for both greeter and session
    # xserver-hostname = Hostname of X server (only for type=xremote)
    # xserver-display-number = Display number of X server (only for type=xremote)
    # xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
    # xdmcp-port = XDMCP UDP/IP port to communicate on
    # xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
    # unity-compositor-command = Unity compositor command to run (can also contain arguments e.g. unity-system-compositor -special-option)
    # unity-compositor-timeout = Number of seconds to wait for compositor to start
    # greeter-session = Session to load for greeter
    # greeter-hide-users = True to hide the user list
    # greeter-allow-guest = True if the greeter should show a guest login option
    # greeter-show-manual-login = True if the greeter should offer a manual login option
    # greeter-show-remote-login = True if the greeter should offer a remote login option
    # user-session = Session to load for users
    # allow-user-switching = True if allowed to switch users
    # allow-guest = True if guest login is allowed
    # guest-session = Session to load for guests (overrides user-session)
    # session-wrapper = Wrapper script to run session with
    # greeter-wrapper = Wrapper script to run greeter with
    # guest-wrapper = Wrapper script to run guest sessions with
    # display-setup-script = Script to run when starting a greeter session (runs as root)
    # display-stopped-script = Script to run after stopping the display server (runs as root)
    # greeter-setup-script = Script to run when starting a greeter (runs as root)
    # session-setup-script = Script to run when starting a user session (runs as root)
    # session-cleanup-script = Script to run when quitting a user session (runs as root)
    # autologin-guest = True to log in as guest by default
    # autologin-user = User to log in with by default (overrides autologin-guest)
    # autologin-user-timeout = Number of seconds to wait before loading default user
    # autologin-session = Session to load for automatic login (overrides user-session)
    # autologin-in-background = True if autologin session should not be immediately activated
    # exit-on-failure = True if the daemon should exit if this seat fails
    #
    [SeatDefaults]
    #type=xlocal
    #xdg-seat=seat0
    #pam-service=lightdm
    #pam-autologin-service=lightdm-autologin
    #pam-greeter-service=lightdm-greeter
    #xserver-command=X
    #xserver-layout=
    #xserver-config=
    #xserver-allow-tcp=false
    #xserver-share=true
    #xserver-hostname=
    #xserver-display-number=
    #xdmcp-manager=
    #xdmcp-port=177
    #xdmcp-key=
    #unity-compositor-command=unity-system-compositor
    #unity-compositor-timeout=60
    #greeter-session=example-gtk-gnome
    #greeter-hide-users=false
    #greeter-allow-guest=true
    #greeter-show-manual-login=false
    #greeter-show-remote-login=true
    #user-session=default
    #allow-user-switching=true
    #allow-guest=true
    #guest-session=
    #session-wrapper=lightdm-session
    #greeter-wrapper=
    #guest-wrapper=
    #display-setup-script=
    #display-stopped-script=
    #greeter-setup-script=
    #session-setup-script=
    #session-cleanup-script=
    #autologin-guest=false
    autologin-user=pi
    #autologin-user-timeout=0
    #autologin-in-background=false
    #autologin-session=UNIMPLEMENTED
    #exit-on-failure=false

    #
    # Seat configuration
    #
    # Each seat must start with "Seat:".
    # Uses settings from [SeatDefaults], any of these can be overriden by setting them in this section.
    #
    #[Seat:0]

    #
    # XDMCP Server configuration
    #
    # enabled = True if XDMCP connections should be allowed
    # port = UDP/IP port to listen for connections on
    # key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf)
    #
    # The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn. Alternatively
    # it can be a word and the first 7 characters are used as the key.
    #
    [XDMCPServer]
    #enabled=false
    #port=177
    #key=

    #
    # VNC Server configuration
    #
    # enabled = True if VNC connections should be allowed
    # command = Command to run Xvnc server with
    # port = TCP/IP port to listen for connections on
    # width = Width of display to use
    # height = Height of display to use
    # depth = Color depth of display to use
    #
    [VNCServer]
    #enabled=false
    #command=Xvnc
    #port=5900
    #width=1024
    #height=768
    #depth=8


    I do



    masi@raspberrypi:~ $ sudo systemctl disable autologin@tty1

    masi@raspberrypi:~ $ ps -fu pi
    UID PID PPID C STIME TTY TIME CMD
    pi 3496 1 0 09:38 ? 00:00:00 /lib/systemd/systemd --user
    pi 3502 3496 0 09:38 ? 00:00:00 (sd-pam)
    pi 3507 3491 0 09:38 tty1 00:00:00 -bash

    masi@raspberrypi:~ $ sudo kill 3496 3502 3507

    masi@raspberrypi:~ $ ps -fu pi
    UID PID PPID C STIME TTY TIME CMD
    pi 7062 1 1 21:46 ? 00:00:00 /lib/systemd/systemd --user
    pi 7068 7062 0 21:46 ? 00:00:00 (sd-pam)
    pi 7073 7056 6 21:46 tty1 00:00:00 -bash


    The file /etc/systemd/system/autologin@.service



    # This file is part of systemd.
    #
    # systemd is free software; you can redistribute it and/or modify it
    # under the terms of the GNU Lesser General Public License as published by
    # the Free Software Foundation; either version 2.1 of the License, or
    # (at your option) any later version.

    [Unit]
    Description=Getty on %I
    Documentation=man:agetty(8) man:systemd-getty-generator(8)
    Documentation=http://0pointer.de/blog/projects/serial-console.html
    After=systemd-user-sessions.service plymouth-quit-wait.service
    After=rc-local.service

    # If additional gettys are spawned during boot then we should make
    # sure that this is synchronized before getty.target, even though
    # getty.target didn't actually pull it in.
    Before=getty.target
    IgnoreOnIsolate=yes

    # On systems without virtual consoles, don't start any getty. Note
    # that serial gettys are covered by serial-getty@.service, not this
    # unit.
    ConditionPathExists=/dev/tty0

    [Service]
    # the VT is cleared by TTYVTDisallocate
    ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
    Type=idle
    Restart=always
    RestartSec=0
    UtmpIdentifier=%I
    TTYPath=/dev/%I
    TTYReset=yes
    TTYVHangup=yes
    TTYVTDisallocate=yes
    KillMode=process
    IgnoreSIGPIPE=no
    SendSIGHUP=yes

    # Unset locale for the console getty since the console has problems
    # displaying some internationalized messages.
    Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

    [Install]
    WantedBy=getty.target
    DefaultInstance=tty1


    I do



    masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

    masi@raspberrypi:~ $ ps -fu pi
    UID PID PPID C STIME TTY TIME CMD

    masi@raspberrypi:~ $ sudo deluser pi
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    Removing user `pi' ...
    Warning: group `pi' has no more members.
    Done.


    Problems



    • it creates always a new process to the user pi after removing its current processes. How can you prevent this?

    Successful attempt [Stephen]



    Do



    masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

    masi@raspberrypi:~ $ ps -fu pi
    UID PID PPID C STIME TTY TIME CMD

    masi@raspberrypi:~ $ sudo deluser pi
    ...

    masi@raspberrypi:~ & sudo vim /etc/passwd
    ... pi no longer here!

    masi@raspberrypi:~ & sudo deluser -remove-home pi


    Solution of locale problem is in the thread here.



    Replace autologin-user=pi with autologin-user=masi in /etc/lightdm/lightdm.conf.




    How can you remove the pi user successfully?










    share|improve this question

























      up vote
      4
      down vote

      favorite
      1









      up vote
      4
      down vote

      favorite
      1






      1





      I do successfully in Raspbian Jessie of Raspberry Pi 3b



      % http://askubuntu.com/a/227513/25388
      masi@raspberrypi:~ $ sudo locale-gen en_US en_US.UTF-8
      masi@raspberrypi:~ $ sudo dpkg-reconfigure locales


      I run sudo deluser pi but I get



      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 929
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I also tried the fix if polylocale problem unsuccessfully



      for y in $(locale | cut -d '=' -f 2| sort |uniq );do sudo locale-gen $y; done


      I do



      masi@raspberrypi:~ $ ps -fp 929
      UID PID PPID C STIME TTY TIME CMD
      pi 929 1 0 08:54 ? 00:00:00 /usr/lib/menu-cache/menu-cached /tmp/.


      I do



      masi@raspberrypi:~ $ sudo kill 929

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 1174
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

      masi@raspberrypi:~ $ sudo deluser -remove-home pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Looking for files to backup/remove ...
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 1174
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

      masi@raspberrypi:~ $


      I kill now the process id 1174 but I get exactly same output, but now giving a new process id 1202.
      I do sudo killall -u pi -m . but I get
      Usage: killall [OPTION]... [--] NAME...



      I do



      masi@raspberrypi:~ $ sudo pkill -u pi 

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      ...
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3422
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I do



      masi@raspberrypi:~ $ ps -u pi
      PID TTY TIME CMD
      3422 tty1 00:00:00 bash

      masi@raspberrypi:~ $ sudo kill 3422

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3496
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I do



      masi@raspberrypi:~ $ who
      pi tty1 Jun 4 09:38
      masi pts/0 Jun 4 09:06 (masi)


      I do



      masi@raspberrypi:~ $ sudo skill -KILL -u pi

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3496
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I do Stephen's proposal but



      masi@raspberrypi:~ $ sudo service lightdm stop

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3496
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      My second iteration of the commands included again trying to change the locales by the first step of commands, again unsuccessfully.



      I do



      masi@raspberrypi:~ $ ps -ft tty1
      UID PID PPID C STIME TTY TIME CMD
      root 3491 1 0 09:38 tty1 00:00:00 /bin/login -f
      pi 3507 3491 0 09:38 tty1 00:00:00 -bash


      I do sudo vim /etc/inittab but the file is empty.
      I do masi@raspberrypi:~ $ sudo grep -r "login -f" /etc but nothing as output.



      I do



      masi@raspberrypi:~ $ sudo grep -r autologin /etc
      /etc/lightdm/lightdm.conf:# pam-autologin-service = PAM service to use for autologin
      /etc/lightdm/lightdm.conf:# autologin-guest = True to log in as guest by default
      /etc/lightdm/lightdm.conf:# autologin-user = User to log in with by default (overrides autologin-guest)
      /etc/lightdm/lightdm.conf:# autologin-user-timeout = Number of seconds to wait before loading default user
      /etc/lightdm/lightdm.conf:# autologin-session = Session to load for automatic login (overrides user-session)
      /etc/lightdm/lightdm.conf:# autologin-in-background = True if autologin session should not be immediately activated
      /etc/lightdm/lightdm.conf:#pam-autologin-service=lightdm-autologin
      /etc/lightdm/lightdm.conf:#autologin-guest=false
      /etc/lightdm/lightdm.conf:autologin-user=pi
      /etc/lightdm/lightdm.conf:#autologin-user-timeout=0
      /etc/lightdm/lightdm.conf:#autologin-in-background=false
      /etc/lightdm/lightdm.conf:#autologin-session=UNIMPLEMENTED
      /etc/systemd/system/autologin@.service:ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM


      Content of /etc/lightdm/lightdm.conf



      # General configuration
      #
      # start-default-seat = True to always start one seat if none are defined in the configuration
      # greeter-user = User to run greeter as
      # minimum-display-number = Minimum display number to use for X servers
      # minimum-vt = First VT to run displays on
      # lock-memory = True to prevent memory from being paged to disk
      # user-authority-in-system-dir = True if session authority should be in the system location
      # guest-account-script = Script to be run to setup guest account
      # logind-load-seats = True to automatically set up multi-seat configuration from logind
      # logind-check-graphical = True to on start seats that are marked as graphical by logind
      # log-directory = Directory to log information to
      # run-directory = Directory to put running state in
      # cache-directory = Directory to cache to
      # sessions-directory = Directory to find sessions
      # remote-sessions-directory = Directory to find remote sessions
      # greeters-directory = Directory to find greeters
      #
      [LightDM]
      #start-default-seat=true
      #greeter-user=lightdm
      #minimum-display-number=0
      #minimum-vt=7
      #lock-memory=true
      #user-authority-in-system-dir=false
      #guest-account-script=guest-account
      #logind-load-seats=false
      #logind-check-graphical=false
      #log-directory=/var/log/lightdm
      #run-directory=/var/run/lightdm
      #cache-directory=/var/cache/lightdm
      #sessions-directory=/usr/share/lightdm/sessions:/usr/share/xsessions
      #remote-sessions-directory=/usr/share/lightdm/remote-sessions
      #greeters-directory=/usr/share/lightdm/greeters:/usr/share/xgreeters

      #
      # Seat defaults
      #
      # type = Seat type (xlocal, xremote)
      # xdg-seat = Seat name to set pam_systemd XDG_SEAT variable and name to pass to X server
      # pam-service = PAM service to use for login
      # pam-autologin-service = PAM service to use for autologin
      # pam-greeter-service = PAM service to use for greeters
      # xserver-command = X server command to run (can also contain arguments e.g. X -special-option)
      # xserver-layout = Layout to pass to X server
      # xserver-config = Config file to pass to X server
      # xserver-allow-tcp = True if TCP/IP connections are allowed to this X server
      # xserver-share = True if the X server is shared for both greeter and session
      # xserver-hostname = Hostname of X server (only for type=xremote)
      # xserver-display-number = Display number of X server (only for type=xremote)
      # xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
      # xdmcp-port = XDMCP UDP/IP port to communicate on
      # xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
      # unity-compositor-command = Unity compositor command to run (can also contain arguments e.g. unity-system-compositor -special-option)
      # unity-compositor-timeout = Number of seconds to wait for compositor to start
      # greeter-session = Session to load for greeter
      # greeter-hide-users = True to hide the user list
      # greeter-allow-guest = True if the greeter should show a guest login option
      # greeter-show-manual-login = True if the greeter should offer a manual login option
      # greeter-show-remote-login = True if the greeter should offer a remote login option
      # user-session = Session to load for users
      # allow-user-switching = True if allowed to switch users
      # allow-guest = True if guest login is allowed
      # guest-session = Session to load for guests (overrides user-session)
      # session-wrapper = Wrapper script to run session with
      # greeter-wrapper = Wrapper script to run greeter with
      # guest-wrapper = Wrapper script to run guest sessions with
      # display-setup-script = Script to run when starting a greeter session (runs as root)
      # display-stopped-script = Script to run after stopping the display server (runs as root)
      # greeter-setup-script = Script to run when starting a greeter (runs as root)
      # session-setup-script = Script to run when starting a user session (runs as root)
      # session-cleanup-script = Script to run when quitting a user session (runs as root)
      # autologin-guest = True to log in as guest by default
      # autologin-user = User to log in with by default (overrides autologin-guest)
      # autologin-user-timeout = Number of seconds to wait before loading default user
      # autologin-session = Session to load for automatic login (overrides user-session)
      # autologin-in-background = True if autologin session should not be immediately activated
      # exit-on-failure = True if the daemon should exit if this seat fails
      #
      [SeatDefaults]
      #type=xlocal
      #xdg-seat=seat0
      #pam-service=lightdm
      #pam-autologin-service=lightdm-autologin
      #pam-greeter-service=lightdm-greeter
      #xserver-command=X
      #xserver-layout=
      #xserver-config=
      #xserver-allow-tcp=false
      #xserver-share=true
      #xserver-hostname=
      #xserver-display-number=
      #xdmcp-manager=
      #xdmcp-port=177
      #xdmcp-key=
      #unity-compositor-command=unity-system-compositor
      #unity-compositor-timeout=60
      #greeter-session=example-gtk-gnome
      #greeter-hide-users=false
      #greeter-allow-guest=true
      #greeter-show-manual-login=false
      #greeter-show-remote-login=true
      #user-session=default
      #allow-user-switching=true
      #allow-guest=true
      #guest-session=
      #session-wrapper=lightdm-session
      #greeter-wrapper=
      #guest-wrapper=
      #display-setup-script=
      #display-stopped-script=
      #greeter-setup-script=
      #session-setup-script=
      #session-cleanup-script=
      #autologin-guest=false
      autologin-user=pi
      #autologin-user-timeout=0
      #autologin-in-background=false
      #autologin-session=UNIMPLEMENTED
      #exit-on-failure=false

      #
      # Seat configuration
      #
      # Each seat must start with "Seat:".
      # Uses settings from [SeatDefaults], any of these can be overriden by setting them in this section.
      #
      #[Seat:0]

      #
      # XDMCP Server configuration
      #
      # enabled = True if XDMCP connections should be allowed
      # port = UDP/IP port to listen for connections on
      # key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf)
      #
      # The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn. Alternatively
      # it can be a word and the first 7 characters are used as the key.
      #
      [XDMCPServer]
      #enabled=false
      #port=177
      #key=

      #
      # VNC Server configuration
      #
      # enabled = True if VNC connections should be allowed
      # command = Command to run Xvnc server with
      # port = TCP/IP port to listen for connections on
      # width = Width of display to use
      # height = Height of display to use
      # depth = Color depth of display to use
      #
      [VNCServer]
      #enabled=false
      #command=Xvnc
      #port=5900
      #width=1024
      #height=768
      #depth=8


      I do



      masi@raspberrypi:~ $ sudo systemctl disable autologin@tty1

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD
      pi 3496 1 0 09:38 ? 00:00:00 /lib/systemd/systemd --user
      pi 3502 3496 0 09:38 ? 00:00:00 (sd-pam)
      pi 3507 3491 0 09:38 tty1 00:00:00 -bash

      masi@raspberrypi:~ $ sudo kill 3496 3502 3507

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD
      pi 7062 1 1 21:46 ? 00:00:00 /lib/systemd/systemd --user
      pi 7068 7062 0 21:46 ? 00:00:00 (sd-pam)
      pi 7073 7056 6 21:46 tty1 00:00:00 -bash


      The file /etc/systemd/system/autologin@.service



      # This file is part of systemd.
      #
      # systemd is free software; you can redistribute it and/or modify it
      # under the terms of the GNU Lesser General Public License as published by
      # the Free Software Foundation; either version 2.1 of the License, or
      # (at your option) any later version.

      [Unit]
      Description=Getty on %I
      Documentation=man:agetty(8) man:systemd-getty-generator(8)
      Documentation=http://0pointer.de/blog/projects/serial-console.html
      After=systemd-user-sessions.service plymouth-quit-wait.service
      After=rc-local.service

      # If additional gettys are spawned during boot then we should make
      # sure that this is synchronized before getty.target, even though
      # getty.target didn't actually pull it in.
      Before=getty.target
      IgnoreOnIsolate=yes

      # On systems without virtual consoles, don't start any getty. Note
      # that serial gettys are covered by serial-getty@.service, not this
      # unit.
      ConditionPathExists=/dev/tty0

      [Service]
      # the VT is cleared by TTYVTDisallocate
      ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
      Type=idle
      Restart=always
      RestartSec=0
      UtmpIdentifier=%I
      TTYPath=/dev/%I
      TTYReset=yes
      TTYVHangup=yes
      TTYVTDisallocate=yes
      KillMode=process
      IgnoreSIGPIPE=no
      SendSIGHUP=yes

      # Unset locale for the console getty since the console has problems
      # displaying some internationalized messages.
      Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

      [Install]
      WantedBy=getty.target
      DefaultInstance=tty1


      I do



      masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      Done.


      Problems



      • it creates always a new process to the user pi after removing its current processes. How can you prevent this?

      Successful attempt [Stephen]



      Do



      masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD

      masi@raspberrypi:~ $ sudo deluser pi
      ...

      masi@raspberrypi:~ & sudo vim /etc/passwd
      ... pi no longer here!

      masi@raspberrypi:~ & sudo deluser -remove-home pi


      Solution of locale problem is in the thread here.



      Replace autologin-user=pi with autologin-user=masi in /etc/lightdm/lightdm.conf.




      How can you remove the pi user successfully?










      share|improve this question















      I do successfully in Raspbian Jessie of Raspberry Pi 3b



      % http://askubuntu.com/a/227513/25388
      masi@raspberrypi:~ $ sudo locale-gen en_US en_US.UTF-8
      masi@raspberrypi:~ $ sudo dpkg-reconfigure locales


      I run sudo deluser pi but I get



      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 929
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I also tried the fix if polylocale problem unsuccessfully



      for y in $(locale | cut -d '=' -f 2| sort |uniq );do sudo locale-gen $y; done


      I do



      masi@raspberrypi:~ $ ps -fp 929
      UID PID PPID C STIME TTY TIME CMD
      pi 929 1 0 08:54 ? 00:00:00 /usr/lib/menu-cache/menu-cached /tmp/.


      I do



      masi@raspberrypi:~ $ sudo kill 929

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 1174
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

      masi@raspberrypi:~ $ sudo deluser -remove-home pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Looking for files to backup/remove ...
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 1174
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.

      masi@raspberrypi:~ $


      I kill now the process id 1174 but I get exactly same output, but now giving a new process id 1202.
      I do sudo killall -u pi -m . but I get
      Usage: killall [OPTION]... [--] NAME...



      I do



      masi@raspberrypi:~ $ sudo pkill -u pi 

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      ...
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3422
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I do



      masi@raspberrypi:~ $ ps -u pi
      PID TTY TIME CMD
      3422 tty1 00:00:00 bash

      masi@raspberrypi:~ $ sudo kill 3422

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3496
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I do



      masi@raspberrypi:~ $ who
      pi tty1 Jun 4 09:38
      masi pts/0 Jun 4 09:06 (masi)


      I do



      masi@raspberrypi:~ $ sudo skill -KILL -u pi

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3496
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      I do Stephen's proposal but



      masi@raspberrypi:~ $ sudo service lightdm stop

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      userdel: user pi is currently used by process 3496
      /usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.


      My second iteration of the commands included again trying to change the locales by the first step of commands, again unsuccessfully.



      I do



      masi@raspberrypi:~ $ ps -ft tty1
      UID PID PPID C STIME TTY TIME CMD
      root 3491 1 0 09:38 tty1 00:00:00 /bin/login -f
      pi 3507 3491 0 09:38 tty1 00:00:00 -bash


      I do sudo vim /etc/inittab but the file is empty.
      I do masi@raspberrypi:~ $ sudo grep -r "login -f" /etc but nothing as output.



      I do



      masi@raspberrypi:~ $ sudo grep -r autologin /etc
      /etc/lightdm/lightdm.conf:# pam-autologin-service = PAM service to use for autologin
      /etc/lightdm/lightdm.conf:# autologin-guest = True to log in as guest by default
      /etc/lightdm/lightdm.conf:# autologin-user = User to log in with by default (overrides autologin-guest)
      /etc/lightdm/lightdm.conf:# autologin-user-timeout = Number of seconds to wait before loading default user
      /etc/lightdm/lightdm.conf:# autologin-session = Session to load for automatic login (overrides user-session)
      /etc/lightdm/lightdm.conf:# autologin-in-background = True if autologin session should not be immediately activated
      /etc/lightdm/lightdm.conf:#pam-autologin-service=lightdm-autologin
      /etc/lightdm/lightdm.conf:#autologin-guest=false
      /etc/lightdm/lightdm.conf:autologin-user=pi
      /etc/lightdm/lightdm.conf:#autologin-user-timeout=0
      /etc/lightdm/lightdm.conf:#autologin-in-background=false
      /etc/lightdm/lightdm.conf:#autologin-session=UNIMPLEMENTED
      /etc/systemd/system/autologin@.service:ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM


      Content of /etc/lightdm/lightdm.conf



      # General configuration
      #
      # start-default-seat = True to always start one seat if none are defined in the configuration
      # greeter-user = User to run greeter as
      # minimum-display-number = Minimum display number to use for X servers
      # minimum-vt = First VT to run displays on
      # lock-memory = True to prevent memory from being paged to disk
      # user-authority-in-system-dir = True if session authority should be in the system location
      # guest-account-script = Script to be run to setup guest account
      # logind-load-seats = True to automatically set up multi-seat configuration from logind
      # logind-check-graphical = True to on start seats that are marked as graphical by logind
      # log-directory = Directory to log information to
      # run-directory = Directory to put running state in
      # cache-directory = Directory to cache to
      # sessions-directory = Directory to find sessions
      # remote-sessions-directory = Directory to find remote sessions
      # greeters-directory = Directory to find greeters
      #
      [LightDM]
      #start-default-seat=true
      #greeter-user=lightdm
      #minimum-display-number=0
      #minimum-vt=7
      #lock-memory=true
      #user-authority-in-system-dir=false
      #guest-account-script=guest-account
      #logind-load-seats=false
      #logind-check-graphical=false
      #log-directory=/var/log/lightdm
      #run-directory=/var/run/lightdm
      #cache-directory=/var/cache/lightdm
      #sessions-directory=/usr/share/lightdm/sessions:/usr/share/xsessions
      #remote-sessions-directory=/usr/share/lightdm/remote-sessions
      #greeters-directory=/usr/share/lightdm/greeters:/usr/share/xgreeters

      #
      # Seat defaults
      #
      # type = Seat type (xlocal, xremote)
      # xdg-seat = Seat name to set pam_systemd XDG_SEAT variable and name to pass to X server
      # pam-service = PAM service to use for login
      # pam-autologin-service = PAM service to use for autologin
      # pam-greeter-service = PAM service to use for greeters
      # xserver-command = X server command to run (can also contain arguments e.g. X -special-option)
      # xserver-layout = Layout to pass to X server
      # xserver-config = Config file to pass to X server
      # xserver-allow-tcp = True if TCP/IP connections are allowed to this X server
      # xserver-share = True if the X server is shared for both greeter and session
      # xserver-hostname = Hostname of X server (only for type=xremote)
      # xserver-display-number = Display number of X server (only for type=xremote)
      # xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
      # xdmcp-port = XDMCP UDP/IP port to communicate on
      # xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
      # unity-compositor-command = Unity compositor command to run (can also contain arguments e.g. unity-system-compositor -special-option)
      # unity-compositor-timeout = Number of seconds to wait for compositor to start
      # greeter-session = Session to load for greeter
      # greeter-hide-users = True to hide the user list
      # greeter-allow-guest = True if the greeter should show a guest login option
      # greeter-show-manual-login = True if the greeter should offer a manual login option
      # greeter-show-remote-login = True if the greeter should offer a remote login option
      # user-session = Session to load for users
      # allow-user-switching = True if allowed to switch users
      # allow-guest = True if guest login is allowed
      # guest-session = Session to load for guests (overrides user-session)
      # session-wrapper = Wrapper script to run session with
      # greeter-wrapper = Wrapper script to run greeter with
      # guest-wrapper = Wrapper script to run guest sessions with
      # display-setup-script = Script to run when starting a greeter session (runs as root)
      # display-stopped-script = Script to run after stopping the display server (runs as root)
      # greeter-setup-script = Script to run when starting a greeter (runs as root)
      # session-setup-script = Script to run when starting a user session (runs as root)
      # session-cleanup-script = Script to run when quitting a user session (runs as root)
      # autologin-guest = True to log in as guest by default
      # autologin-user = User to log in with by default (overrides autologin-guest)
      # autologin-user-timeout = Number of seconds to wait before loading default user
      # autologin-session = Session to load for automatic login (overrides user-session)
      # autologin-in-background = True if autologin session should not be immediately activated
      # exit-on-failure = True if the daemon should exit if this seat fails
      #
      [SeatDefaults]
      #type=xlocal
      #xdg-seat=seat0
      #pam-service=lightdm
      #pam-autologin-service=lightdm-autologin
      #pam-greeter-service=lightdm-greeter
      #xserver-command=X
      #xserver-layout=
      #xserver-config=
      #xserver-allow-tcp=false
      #xserver-share=true
      #xserver-hostname=
      #xserver-display-number=
      #xdmcp-manager=
      #xdmcp-port=177
      #xdmcp-key=
      #unity-compositor-command=unity-system-compositor
      #unity-compositor-timeout=60
      #greeter-session=example-gtk-gnome
      #greeter-hide-users=false
      #greeter-allow-guest=true
      #greeter-show-manual-login=false
      #greeter-show-remote-login=true
      #user-session=default
      #allow-user-switching=true
      #allow-guest=true
      #guest-session=
      #session-wrapper=lightdm-session
      #greeter-wrapper=
      #guest-wrapper=
      #display-setup-script=
      #display-stopped-script=
      #greeter-setup-script=
      #session-setup-script=
      #session-cleanup-script=
      #autologin-guest=false
      autologin-user=pi
      #autologin-user-timeout=0
      #autologin-in-background=false
      #autologin-session=UNIMPLEMENTED
      #exit-on-failure=false

      #
      # Seat configuration
      #
      # Each seat must start with "Seat:".
      # Uses settings from [SeatDefaults], any of these can be overriden by setting them in this section.
      #
      #[Seat:0]

      #
      # XDMCP Server configuration
      #
      # enabled = True if XDMCP connections should be allowed
      # port = UDP/IP port to listen for connections on
      # key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf)
      #
      # The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn. Alternatively
      # it can be a word and the first 7 characters are used as the key.
      #
      [XDMCPServer]
      #enabled=false
      #port=177
      #key=

      #
      # VNC Server configuration
      #
      # enabled = True if VNC connections should be allowed
      # command = Command to run Xvnc server with
      # port = TCP/IP port to listen for connections on
      # width = Width of display to use
      # height = Height of display to use
      # depth = Color depth of display to use
      #
      [VNCServer]
      #enabled=false
      #command=Xvnc
      #port=5900
      #width=1024
      #height=768
      #depth=8


      I do



      masi@raspberrypi:~ $ sudo systemctl disable autologin@tty1

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD
      pi 3496 1 0 09:38 ? 00:00:00 /lib/systemd/systemd --user
      pi 3502 3496 0 09:38 ? 00:00:00 (sd-pam)
      pi 3507 3491 0 09:38 tty1 00:00:00 -bash

      masi@raspberrypi:~ $ sudo kill 3496 3502 3507

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD
      pi 7062 1 1 21:46 ? 00:00:00 /lib/systemd/systemd --user
      pi 7068 7062 0 21:46 ? 00:00:00 (sd-pam)
      pi 7073 7056 6 21:46 tty1 00:00:00 -bash


      The file /etc/systemd/system/autologin@.service



      # This file is part of systemd.
      #
      # systemd is free software; you can redistribute it and/or modify it
      # under the terms of the GNU Lesser General Public License as published by
      # the Free Software Foundation; either version 2.1 of the License, or
      # (at your option) any later version.

      [Unit]
      Description=Getty on %I
      Documentation=man:agetty(8) man:systemd-getty-generator(8)
      Documentation=http://0pointer.de/blog/projects/serial-console.html
      After=systemd-user-sessions.service plymouth-quit-wait.service
      After=rc-local.service

      # If additional gettys are spawned during boot then we should make
      # sure that this is synchronized before getty.target, even though
      # getty.target didn't actually pull it in.
      Before=getty.target
      IgnoreOnIsolate=yes

      # On systems without virtual consoles, don't start any getty. Note
      # that serial gettys are covered by serial-getty@.service, not this
      # unit.
      ConditionPathExists=/dev/tty0

      [Service]
      # the VT is cleared by TTYVTDisallocate
      ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
      Type=idle
      Restart=always
      RestartSec=0
      UtmpIdentifier=%I
      TTYPath=/dev/%I
      TTYReset=yes
      TTYVHangup=yes
      TTYVTDisallocate=yes
      KillMode=process
      IgnoreSIGPIPE=no
      SendSIGHUP=yes

      # Unset locale for the console getty since the console has problems
      # displaying some internationalized messages.
      Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

      [Install]
      WantedBy=getty.target
      DefaultInstance=tty1


      I do



      masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD

      masi@raspberrypi:~ $ sudo deluser pi
      perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = "en_US.UTF-8",
      LC_PAPER = "fi_FI.UTF-8",
      LC_ADDRESS = "fi_FI.UTF-8",
      LC_MONETARY = "fi_FI.UTF-8",
      LC_NUMERIC = "fi_FI.UTF-8",
      LC_TELEPHONE = "fi_FI.UTF-8",
      LC_IDENTIFICATION = "fi_FI.UTF-8",
      LC_MEASUREMENT = "fi_FI.UTF-8",
      LC_TIME = "fi_FI.UTF-8",
      LC_NAME = "fi_FI.UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      Removing user `pi' ...
      Warning: group `pi' has no more members.
      Done.


      Problems



      • it creates always a new process to the user pi after removing its current processes. How can you prevent this?

      Successful attempt [Stephen]



      Do



      masi@raspberrypi:~ $ sudo systemctl stop autologin@tty1

      masi@raspberrypi:~ $ ps -fu pi
      UID PID PPID C STIME TTY TIME CMD

      masi@raspberrypi:~ $ sudo deluser pi
      ...

      masi@raspberrypi:~ & sudo vim /etc/passwd
      ... pi no longer here!

      masi@raspberrypi:~ & sudo deluser -remove-home pi


      Solution of locale problem is in the thread here.



      Replace autologin-user=pi with autologin-user=masi in /etc/lightdm/lightdm.conf.




      How can you remove the pi user successfully?







      raspberry-pi raspbian






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 13 '17 at 12:36









      Community♦

      1




      1










      asked Jun 4 '16 at 10:05









      Léo Léopold Hertz 준영

      9431144106




      9431144106




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Your pi user is logged in, on tty1; you should log the user out before deleting it. (The menu-cached process is used by the LXDE desktop environment. There are probably other processes running for user pi.)



          If you don't have access to the GUI to log the user out (i.e., you're accessing the Raspberry Pi remotely), the safest bet is probably to stop the desktop manager:



          sudo service lightdm stop


          (assuming you're using the LXDE default); this should kill all of pi's processes.



          You'll also need to de-activate the auto-login (login -f).



          If you have an old-style inittab, edit your /etc/inittab file, and replace the line looking something like



          1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1


          (the important part being /bin/login -f pi tty1) with



          1:2345:respawn:/sbin/getty 115200 tty1


          Then reload init by running



          sudo telinit q


          With a systemd unit for auto-login, such as your autologin service, disable the service:



          sudo systemctl --now disable autologin@tty1


          This will also stop the unit and reload the systemd configuration.



          At this point, if pi still has any running processes (as indicated by ps -fu pi), kill them — they shouldn't respawn any more.






          share|improve this answer






















          • I extend the locale part here unix.stackexchange.com/q/287716/16920.
            – Léo Léopold Hertz 준영
            Jun 4 '16 at 22:01










          • Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
            – Dagrooms
            Aug 9 '17 at 20:21

















          up vote
          0
          down vote













          I ran sudo raspi-config at the command line then under boot options elected for the command line option. After a restart I was able to delete the user pi (note I did this after a fresh install of Raspbian).






          share|improve this answer








          New contributor




          Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f287620%2fwhy-failing-to-delete-user-in-raspbian%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            Your pi user is logged in, on tty1; you should log the user out before deleting it. (The menu-cached process is used by the LXDE desktop environment. There are probably other processes running for user pi.)



            If you don't have access to the GUI to log the user out (i.e., you're accessing the Raspberry Pi remotely), the safest bet is probably to stop the desktop manager:



            sudo service lightdm stop


            (assuming you're using the LXDE default); this should kill all of pi's processes.



            You'll also need to de-activate the auto-login (login -f).



            If you have an old-style inittab, edit your /etc/inittab file, and replace the line looking something like



            1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1


            (the important part being /bin/login -f pi tty1) with



            1:2345:respawn:/sbin/getty 115200 tty1


            Then reload init by running



            sudo telinit q


            With a systemd unit for auto-login, such as your autologin service, disable the service:



            sudo systemctl --now disable autologin@tty1


            This will also stop the unit and reload the systemd configuration.



            At this point, if pi still has any running processes (as indicated by ps -fu pi), kill them — they shouldn't respawn any more.






            share|improve this answer






















            • I extend the locale part here unix.stackexchange.com/q/287716/16920.
              – Léo Léopold Hertz 준영
              Jun 4 '16 at 22:01










            • Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
              – Dagrooms
              Aug 9 '17 at 20:21














            up vote
            3
            down vote



            accepted










            Your pi user is logged in, on tty1; you should log the user out before deleting it. (The menu-cached process is used by the LXDE desktop environment. There are probably other processes running for user pi.)



            If you don't have access to the GUI to log the user out (i.e., you're accessing the Raspberry Pi remotely), the safest bet is probably to stop the desktop manager:



            sudo service lightdm stop


            (assuming you're using the LXDE default); this should kill all of pi's processes.



            You'll also need to de-activate the auto-login (login -f).



            If you have an old-style inittab, edit your /etc/inittab file, and replace the line looking something like



            1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1


            (the important part being /bin/login -f pi tty1) with



            1:2345:respawn:/sbin/getty 115200 tty1


            Then reload init by running



            sudo telinit q


            With a systemd unit for auto-login, such as your autologin service, disable the service:



            sudo systemctl --now disable autologin@tty1


            This will also stop the unit and reload the systemd configuration.



            At this point, if pi still has any running processes (as indicated by ps -fu pi), kill them — they shouldn't respawn any more.






            share|improve this answer






















            • I extend the locale part here unix.stackexchange.com/q/287716/16920.
              – Léo Léopold Hertz 준영
              Jun 4 '16 at 22:01










            • Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
              – Dagrooms
              Aug 9 '17 at 20:21












            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            Your pi user is logged in, on tty1; you should log the user out before deleting it. (The menu-cached process is used by the LXDE desktop environment. There are probably other processes running for user pi.)



            If you don't have access to the GUI to log the user out (i.e., you're accessing the Raspberry Pi remotely), the safest bet is probably to stop the desktop manager:



            sudo service lightdm stop


            (assuming you're using the LXDE default); this should kill all of pi's processes.



            You'll also need to de-activate the auto-login (login -f).



            If you have an old-style inittab, edit your /etc/inittab file, and replace the line looking something like



            1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1


            (the important part being /bin/login -f pi tty1) with



            1:2345:respawn:/sbin/getty 115200 tty1


            Then reload init by running



            sudo telinit q


            With a systemd unit for auto-login, such as your autologin service, disable the service:



            sudo systemctl --now disable autologin@tty1


            This will also stop the unit and reload the systemd configuration.



            At this point, if pi still has any running processes (as indicated by ps -fu pi), kill them — they shouldn't respawn any more.






            share|improve this answer














            Your pi user is logged in, on tty1; you should log the user out before deleting it. (The menu-cached process is used by the LXDE desktop environment. There are probably other processes running for user pi.)



            If you don't have access to the GUI to log the user out (i.e., you're accessing the Raspberry Pi remotely), the safest bet is probably to stop the desktop manager:



            sudo service lightdm stop


            (assuming you're using the LXDE default); this should kill all of pi's processes.



            You'll also need to de-activate the auto-login (login -f).



            If you have an old-style inittab, edit your /etc/inittab file, and replace the line looking something like



            1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1


            (the important part being /bin/login -f pi tty1) with



            1:2345:respawn:/sbin/getty 115200 tty1


            Then reload init by running



            sudo telinit q


            With a systemd unit for auto-login, such as your autologin service, disable the service:



            sudo systemctl --now disable autologin@tty1


            This will also stop the unit and reload the systemd configuration.



            At this point, if pi still has any running processes (as indicated by ps -fu pi), kill them — they shouldn't respawn any more.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 4 '16 at 21:51

























            answered Jun 4 '16 at 10:10









            Stephen Kitt

            152k23338406




            152k23338406











            • I extend the locale part here unix.stackexchange.com/q/287716/16920.
              – Léo Léopold Hertz 준영
              Jun 4 '16 at 22:01










            • Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
              – Dagrooms
              Aug 9 '17 at 20:21
















            • I extend the locale part here unix.stackexchange.com/q/287716/16920.
              – Léo Léopold Hertz 준영
              Jun 4 '16 at 22:01










            • Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
              – Dagrooms
              Aug 9 '17 at 20:21















            I extend the locale part here unix.stackexchange.com/q/287716/16920.
            – Léo Léopold Hertz 준영
            Jun 4 '16 at 22:01




            I extend the locale part here unix.stackexchange.com/q/287716/16920.
            – Léo Léopold Hertz 준영
            Jun 4 '16 at 22:01












            Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
            – Dagrooms
            Aug 9 '17 at 20:21




            Was wondering what implications deleting the pi user would have - I guess this covers all of it. Thanks!
            – Dagrooms
            Aug 9 '17 at 20:21












            up vote
            0
            down vote













            I ran sudo raspi-config at the command line then under boot options elected for the command line option. After a restart I was able to delete the user pi (note I did this after a fresh install of Raspbian).






            share|improve this answer








            New contributor




            Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















              up vote
              0
              down vote













              I ran sudo raspi-config at the command line then under boot options elected for the command line option. After a restart I was able to delete the user pi (note I did this after a fresh install of Raspbian).






              share|improve this answer








              New contributor




              Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.



















                up vote
                0
                down vote










                up vote
                0
                down vote









                I ran sudo raspi-config at the command line then under boot options elected for the command line option. After a restart I was able to delete the user pi (note I did this after a fresh install of Raspbian).






                share|improve this answer








                New contributor




                Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                I ran sudo raspi-config at the command line then under boot options elected for the command line option. After a restart I was able to delete the user pi (note I did this after a fresh install of Raspbian).







                share|improve this answer








                New contributor




                Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 39 mins ago









                Moika Turns

                11




                11




                New contributor




                Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Moika Turns is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f287620%2fwhy-failing-to-delete-user-in-raspbian%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay