jlazkano
Posts: 14
Joined: Wed Nov 13, 2013 8:19 pm

Delete pi user in Raspbian

Mon Jan 15, 2018 8:05 pm

Hello,

Is it possible to delete the default "pi" user in Raspbian?

I want to use same users with they uid and gid.

Regards.

User avatar
HawaiianPi
Posts: 4857
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Delete pi user in Raspbian

Mon Jan 15, 2018 10:12 pm

I did that once by creating a new temporary user, logging in as the temp user, deleting the "pi" user, and then creating my user. There's supposed to be a way to change the name of the pi user as well, but it all seems like more fuss than it's worth, and removing the pi user can have consequences since it is much too integrated into Raspbian OS (more problematic with Desktop than Lite version).

Normally I just create my user and lock the pi account (sudo passwd --lock pi).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

User avatar
DougieLawson
Posts: 36524
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Delete pi user in Raspbian

Mon Jan 15, 2018 11:13 pm

Crude and ugly way is sudo nano /etc/passwd; sudo nano /etc/group; sudo nano /etc/shadow;
Change pi to your new ID in those three files then reboot.

If you use the GUI you'll need to muck about with the lightdm autologin stuff.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: Delete pi user in Raspbian

Tue Jan 16, 2018 1:23 am

You really have to ask yourself why you want to do this.

The short answer is: Yes, you can, but not without a lot of pain.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

jlazkano
Posts: 14
Joined: Wed Nov 13, 2013 8:19 pm

Re: Delete pi user in Raspbian

Tue Jan 16, 2018 8:19 pm

Hello,

I did it enabling root access, then:

Code: Select all

userdel -r -f pi
adduser user1
adduser user2
Regards.

Iznogood1
Posts: 23
Joined: Wed Dec 07, 2016 6:51 pm

Re: Delete pi user in Raspbian

Wed Feb 13, 2019 3:37 pm

It can be done without pain...

1/ Create a new user (named userx here)

Code: Select all

sudo add user userx

2/ Add userx to sudoers (not mandatory, but could be usefull)

Code: Select all

sudo visuo

Append a line under # User previlege specification

Code: Select all

# User privilege specification
root  ALL=(ALL:ALL) ALL
userx ALL=(ALL:ALL) ALL

3/ List groups wich pi is belonging

Code: Select all

sudo cat/etc/group | grep pi
you get something like

Code: Select all

adm:x:4:pi
dialout:x:20:pi
cdrom:x:24:pi
sudo:x:27:pi
audio:x:29:pi
video:x:44:pi
plugdev:x:46:pi
games:x:60:pi
users:x:100:pi
input:x:101:pi
netdev:x:108:pi
4/ Add userx to these groups

Code: Select all

sudo usermod -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev userx
5/ delete pi user

Code: Select all

deluser -r pi

tesdda
Posts: 5
Joined: Thu Apr 18, 2019 5:51 pm

Re: Delete pi user in Raspbian

Thu Apr 18, 2019 6:01 pm

Hi,

"the without pain solution" works fine. But you are not able to add/remove software by desktop gui any more. Just as root ... Is there any way to assign rights to the newuser to appear in that dropdwon menue as pi before was, again?

fbe
Posts: 537
Joined: Thu Aug 17, 2017 9:08 pm

Re: Delete pi user in Raspbian

Fri Apr 19, 2019 9:40 am

Edit /etc/polkit-1/localauthority.conf.d/60-desktop-policy.conf

Hasn't got as much pi in it as pi egg sausage and pi, has it?

Replace "unix-user:pi" by "unix-group:sudo"

Code: Select all

AdminIdentities=unix-group:sudo;unix-user:0

tesdda
Posts: 5
Joined: Thu Apr 18, 2019 5:51 pm

Re: Delete pi user in Raspbian

Fri Apr 19, 2019 11:57 am

OMG... Thanks... searched for hours before ... great support 8-)

CompleteTeresa
Posts: 1
Joined: Wed Jul 03, 2019 1:57 pm

Re: Delete pi user in Raspbian

Sun Jul 07, 2019 5:08 pm

I tried a number of suggestions to get rid of pi but the one that worked the best was to change pi to the newuser in the following files:

sudo nano /etc/ightdm/lightdm.cong

sudo nano /etc/passwd

sudo nano /etc/group

sudo nano /etc/shadow

There were a couple of files where changing pi to newuser created duplicate entries so I just deleted the pi one. After completing the changes I tried:

sudo deluser pi and got the no such user response so I assume I did everything correctly.

Return to “Beginners”