LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-06-2018, 10:09 PM   #1
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Rep: Reputation: Disabled
Where does SystemD and bash decide what user to run as? RASBIAN


Hi guys,
First time poster. w00t. I have been playing around with Rasbian(for the raspberry pi 3 b model) and have ran into a bit of odd trouble. Something that would normally be quite simple is unreasonably difficult on this distro. I go into a bit more depth than really needed on the setup I have done so far in case any lurkers need a hand.

I am trying to simply make a new user and delete the default. Sounds easy enough except that rasbian was made by the devil. Haha

I am able to add the user with
=
Code:
sudo useradd -m USERNAME
and have no trouble setting up the shell with
Code:
sudo usermod -s /bin/bash
no issues when I add sudo permissions to the account with
Code:
sudo usermod -aG sudo USERNAME
but this is where I hit problems, the next line I try is to
Code:
sudo userdel --remove pi
Which SHOULD just remove the user named pi, the default user on rasbian, as well as his home directory. But instead I have this error pop up
Code:
userdel: user pi is currently used by process 615
after using this to determine the process
Code:
ps -p 615 -o comm=
it said it was named Bash and other occasions it has said (with different numbers) SystemD



What have I tried

obviously a kill all by username, which kicked me all the way out to a login screen, and then upon relogging in a similar result

Code:
killall -u pi
Code:
userdel: user pi is currently used by process 2677
which turned out to be bash again.

I really am not sure what I could do to continue, but I know it can be done.

What I would like is the location of whatever folder I could nano the USERNAME in the place of pi or even set it as root if that is better, these processes seem to my untrained eye should be running as root
 
Old 12-07-2018, 03:24 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 10,184
Blog Entries: 7

Rep: Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520
unless raspbian (sic) works very much differently than normal debian or ubuntu, you are overthinking all this.
creating a new user is simple:
  • find a tutorial suitable for your base distro (usually debian or ubuntu for raspbian)
  • follow it
it's probably only one or two commands.

logging in is easy:
at the login prompt, you choose the new user.
 
Old 12-07-2018, 05:27 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,831

Rep: Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402
Do you have autologin configured? Make sure you change it for your new user.

Have you configured your new user for sudo privileges and add it to the same groups as pi?

Once sudo is configured for your new user you should log out and log back in as the new user. Make sure that you can use sudo as your new user and then you should be able to delete pi.
 
Old 12-07-2018, 05:45 AM   #4
fred44nl
LQ Newbie
 
Registered: Aug 2018
Location: the Netherlands
Distribution: Debian 9 - Stretch
Posts: 16

Rep: Reputation: Disabled
if you run top -u pi you will see what processes are running as pi
I never deleted user pi, but instead I prevented the ability to log in
and I gave pi an impossible password.
 
Old 12-07-2018, 11:15 AM   #5
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
unless raspbian (sic) works very much differently than normal debian or ubuntu, you are overthinking all this.
creating a new user is simple:
  • find a tutorial suitable for your base distro (usually debian or ubuntu for raspbian)
  • follow it
it's probably only one or two commands.

logging in is easy:
at the login prompt, you choose the new user.
Yeah Rasbian doesn't operate very differently, it is debian based. However it is CONFIGURED in a very strange way in what seems like an attempt to stop you from doing exactly what I'm doing. The few lines would in any other debian system take me half a minute to setup a user. This is a unique issue.
 
Old 12-07-2018, 11:20 AM   #6
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Do you have autologin configured? Make sure you change it for your new user.

Have you configured your new user for sudo privileges and add it to the same groups as pi?

Once sudo is configured for your new user you should log out and log back in as the new user. Make sure that you can use sudo as your new user and then you should be able to delete pi.
yes I have autologin configured, and it correctly logs in the USERNAME on boot instead of pi. But many functions automatically start as pi regardless, yes I gave sudo privileges (see op) and if you read above I also go into the specific error that happens when I try to delete pi
 
Old 12-07-2018, 11:38 AM   #7
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fred44nl View Post
I prevented the ability to log in
and I gave pi an impossible password.
How did you do that?

(and yes I ran top and it confirms that even after auto login the other user and a reboot, or killing all pi's user processes, they are still running. This makes me think they are happening as part of the boot process. This is why I feel they must be running as some kind of default user and would like to change which user these run in)
 
Old 12-07-2018, 11:41 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,831

Rep: Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402
It was not obvious from your OP that you were running the userdel command as the new user.

In addition to adding the new user to the sudo group I think you also need add it to the /etc/sudoers file via visudo.

Not sure if this is your problem but check your /etc/systemd/system/autologin@.service to see if it configured for the pi user.

You can lock a user's password using the passwd or chage commands.

Last edited by michaelk; 12-07-2018 at 11:44 AM.
 
Old 12-07-2018, 11:54 AM   #9
fred44nl
LQ Newbie
 
Registered: Aug 2018
Location: the Netherlands
Distribution: Debian 9 - Stretch
Posts: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by DrunkenTimelord View Post
How did you do that?
not sure, as it was done with WebMin, which has a browser gui
there was an option to disable a user to log in.
if you look around on internet, there are several ways of disabling a user.
 
Old 12-07-2018, 12:17 PM   #10
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
It was not obvious from your OP that you were running the userdel command as the new user.

In addition to adding the new user to the sudo group I think you also need add it to the /etc/sudoers file via visudo.

Not sure if this is your problem but check your /etc/systemd/system/autologin@.service to see if it configured for the pi user.

You can lock a user's password using the passwd or chage commands.
Sorry for any confusion. I probably worded it weird. Ok I will check the autologin@.service and get back with results in case this works and anyone else needs help with this issue
 
Old 12-07-2018, 12:35 PM   #11
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Ok in the etc/systemd/system/autologin@.service it has these lines (which to my untrained eyes sound like the right things)

Quote:
ExecStart=-/sbin/agentty --autologin pi --noclear %I $TERM
Type=idle
Restart=always
and later in the list of configurations it says

Quote:
KillMode=process
If I am understanding the Moderator correctly, I should be changing "--autologin pi" to " --autologin USERNAME", is that correct?
 
Old 12-07-2018, 12:47 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,831

Rep: Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402
Yes.
 
Old 12-07-2018, 01:41 PM   #13
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
Well I tried that and now it wont power on all the way, I'm remoting in and its not back online. I guess I will have to reimage. Rasbian really is its own beast when it comes to simple little things like this. I think after I reimage I will just take fred44nl's advice and just disable pi. Thank you everyone for your help
 
Old 12-07-2018, 02:21 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,831

Rep: Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402Reputation: 2402
Sorry, That probably the best way and easiest. You should be able to access the file system and edit the file on the card without reimagining.
 
Old 12-07-2018, 02:23 PM   #15
DrunkenTimelord
LQ Newbie
 
Registered: Dec 2018
Posts: 8

Original Poster
Rep: Reputation: Disabled
will do so, thanks man. Valiant effort
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create desktop links in Rasbian dtref Linux - Desktop 1 09-28-2018 04:17 PM
Persian character are shown reverse and disconnected by C# application running on rasbian jessie OS via MONO Cross Compiler sheelamanatec Linux - Software 6 02-02-2017 05:49 AM
Can't access full journalctl from script via systemd service even though user is in systemd-journal group iwtbf Linux - Newbie 0 02-19-2016 03:44 PM
RPi, Rasbian, how to start transmission on boot? bigwheel Linux - Embedded & Single-board computer 9 02-23-2015 10:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration