Delete pi user in Raspbian
Hello,
Is it possible to delete the default "pi" user in Raspbian?
I want to use same users with they uid and gid.
Regards.
Is it possible to delete the default "pi" user in Raspbian?
I want to use same users with they uid and gid.
Regards.
- HawaiianPi
- Posts: 7585
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: Delete pi user in Raspbian
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).
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?
lots of pop-ups, and where is that annoying music coming from?
- DougieLawson
- Posts: 42313
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Delete pi user in Raspbian
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.
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.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Delete pi user in Raspbian
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.
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!
G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:
Epmu Sn!
J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!
Re: Delete pi user in Raspbian
Hello,
I did it enabling root access, then:
Regards.
I did it enabling root access, then:
Code: Select all
userdel -r -f pi
adduser user1
adduser user2
Re: Delete pi user in Raspbian
It can be done without pain...
1/ Create a new user (named userx here)
2/ Add userx to sudoers (not mandatory, but could be usefull)
Append a line under # User previlege specification
3/ List groups wich pi is belonging
you get something like
4/ Add userx to these groups
5/ delete pi user
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
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
Code: Select all
sudo usermod -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev userx
Code: Select all
deluser -r pi
Re: Delete pi user in Raspbian
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?
"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?
Re: Delete pi user in Raspbian
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"
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
Re: Delete pi user in Raspbian
OMG... Thanks... searched for hours before ... great support 

-
- Posts: 1
- Joined: Wed Jul 03, 2019 1:57 pm
Re: Delete pi user in Raspbian
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.
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.
Re: Delete pi user in Raspbian
Just out of curiosity, I am following this guide :
https://www.raspberrypi.org/documentati ... ecurity.md
It says you can remove the PI user by following the steps, I did all the prep work, log in to my other (new) user and tried the
and then the
But there was always some program running, preventing me to do this, And I tried to kill the tasks manually but it was keep on reopening the programs again and again.
Is that article on securing PI not good ? I mean I want to remove PI and make sure I only have one user but it seems the PI user is heavily baked in.
I want to use the PI for my banking so I want it as tight and locked as possible, but maybe just using the PI user with a good long password would be good ?
https://www.raspberrypi.org/documentati ... ecurity.md
It says you can remove the PI user by following the steps, I did all the prep work, log in to my other (new) user and tried the
Code: Select all
sudo pkill -u pi
Code: Select all
sudo deluser pi
Is that article on securing PI not good ? I mean I want to remove PI and make sure I only have one user but it seems the PI user is heavily baked in.
I want to use the PI for my banking so I want it as tight and locked as possible, but maybe just using the PI user with a good long password would be good ?
- HawaiianPi
- Posts: 7585
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: Delete pi user in Raspbian
What running programs are associated with the pi user?
What version of Raspbian?
Is auto-login still enabled?
Removing the pi user shouldn't be a problem any longer. It used to be a big problem, but those issues should have been resolved by now. I usually just create my own user and lock the pi account, but I thought I'd give deleting pi a try. I had recently made a full backup of my test system, so I went ahead and removed the pi user with the following command.
Code: Select all
sudo deluser --remove-home 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?
lots of pop-ups, and where is that annoying music coming from?
Re: Delete pi user in Raspbian
Easiest is just renaming user pi to whatever you want, via "usermod" command. The trick is to be running at the console. Assuming nothing else is running with your username other then the shell on the console - no X session, no ssh login, etc, the following works:
If you desperately want to do it with the full GUI up you need to give root a password, and then log in as root to make the changes. You can remove the root password if you want the default (and crazy in my opinion) sudo behaviour afterwards.
Code: Select all
exec sudo -s
cd /
usermod -l newname -d /home/newname -m oldname
Re: Delete pi user in Raspbian
I managed to remove the PI user after disabling the auto login and rebooting and doing the Pkill commandHawaiianPi wrote: ↑Fri Jun 12, 2020 11:56 pmWhat running programs are associated with the pi user?
What version of Raspbian?
Is auto-login still enabled?
Removing the pi user shouldn't be a problem any longer. It used to be a big problem, but those issues should have been resolved by now. I usually just create my own user and lock the pi account, but I thought I'd give deleting pi a try. I had recently made a full backup of my test system, so I went ahead and removed the pi user with the following command.Then rebooted, and that seemed to work okay. I enabled "Login as user pi" in the Raspberry Pi Configuration utility to see what would happen, and was pleasantly surprised when it auto-logged in as my user after a reboot. So it seems removing pi isn't a problem, as far as I could tell. If you are having a specific issue with removing the pi user, we need a detailed description of the problem, and how to re-create it.Code: Select all
sudo deluser --remove-home pi
Code: Select all
sudo pkill -u pi
Code: Select all
sudo deluser pi
Code: Select all
sudo deluser -remove-home pi
/usr/sbin/deluser The user 'pi' does not exist
I can see you are using -- instead of - but I ended up removing the home/pi/ directory using rm -dr /home/pi and that worked.
Now I am facing new issue likely related, I am trying to install keepass from the
MENU>Preferences>Add remove programs
I find my software and its asking me put in ROOT password, there is a small arrow button on the root like to let you select other user to install as but its not showing any other users
And my sudo password for my new user I created does not work for there. Do I need to add my new user to ROOT group or something ?
Please be gentle on my I this is first week of me playing with linux.
The os Is RASPBERRY OS 10 fresh from here https://www.raspberrypi.org/downloads/raspberry-pi-os/
(re)installed today after I totally screwed up my previous attempts with removing the pi user.
bjtheone seems to be touching up on this root password not sure if it related. Again please be gentle on my I am not a power user.
- HawaiianPi
- Posts: 7585
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: Delete pi user in Raspbian
For future reference, the option --remove-home is supposed to be added to the deluser command when removing a user (not a separate step).
For your troubles with Add / Remove software, you probably need to edit /etc/polkit-1/localauthority.conf.d/60-desktop-policy.conf. Either change unix-user:pi to your new user, or replace it with unix-group:sudo (AdminIdentities=unix-group:sudo;unix-user:0).
For your troubles with Add / Remove software, you probably need to edit /etc/polkit-1/localauthority.conf.d/60-desktop-policy.conf. Either change unix-user:pi to your new user, or replace it with unix-group:sudo (AdminIdentities=unix-group:sudo;unix-user:0).
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?
lots of pop-ups, and where is that annoying music coming from?
Re: Delete pi user in Raspbian
HawaiianPI the first suggestion worked flawlessly, all is now well, the PI user is gone and I can work on my last tweaks. Thank you very much for your help. I will need to put all of this into some sort of TXT document in case I need to rebuild the PIHawaiianPi wrote: ↑Sun Jun 14, 2020 4:16 pmFor future reference, the option --remove-home is supposed to be added to the deluser command when removing a user (not a separate step).
For your troubles with Add / Remove software, you probably need to edit /etc/polkit-1/localauthority.conf.d/60-desktop-policy.conf. Either change unix-user:pi to your new user, or replace it with unix-group:sudo (AdminIdentities=unix-group:sudo;unix-user:0).

-
- Posts: 1
- Joined: Mon Jun 22, 2020 6:29 pm
Re: Delete pi user in Raspbian
The pkill trick doesn't seem to work anymore:
Looks like systemd is spawning a new process immediately after I kill the previous ones.
I found which piece of configuration was responsible for it. There was a line that ensured that the first console (CTRL+ALT+F1) was always logged in. I guess it was to make the first experience of beginners a little less frustrating.
I edited this file:
I commented out the two ExecStart lines. Then I needed to tell systemd to reload the configuration, and restart the CTRL+ALT+F1 service.
Then I could remove the user with .
Code: Select all
myuser@raspberrypi:~ $ sudo pkill -u pi
myuser@raspberrypi:~ $ sudo deluser --remove-home pi
Looking for files to backup/remove ...
Removing user `pi' ...
Warning: group `pi' has no more members.
userdel: user pi is currently used by process 1915
/usr/sbin/deluser: `/usr/sbin/userdel pi' returned error code 8. Exiting.
Code: Select all
myuser@raspberrypi:~ $ pgrep -a -u pi
1915 /lib/systemd/systemd --user
1918 (sd-pam)
1931 -bash
I edited this file:
Code: Select all
sudo nano /etc/systemd/system/getty@tty1.service.d/autologin.conf
Code: Select all
sudo systemctl daemon-reload
sudo systemctl restart getty@tty1.service
Code: Select all
sudo deluser --remove-home pi
-
- Posts: 1
- Joined: Wed Jul 15, 2020 5:54 pm
Re: Delete pi user in Raspbian
It seems this is an ongoing problem. I've also removed my "pi" user and updated the /etc/polkit_1/localauthority.conf.d/60-desktop_policy.conf file so instead of directly referencing the "pi" user it references the "unix-group:sudo". However, upon doing a apt update/apt upgrade, this file reverted to the original setting. There should not be such a direct dependency on the "pi' user. This totally breaks the software install GUI tool, as it then requires a root password.
I am running Raspberry Pi OS on a Pi 4; uname -a = 4.19.118-v7L+ #1311
I am running Raspberry Pi OS on a Pi 4; uname -a = 4.19.118-v7L+ #1311