aristosv
Posts: 159
Joined: Mon Dec 08, 2014 7:47 pm

Add user silently

Mon Dec 08, 2014 7:54 pm

Hello,

I am using Raspbian Wheezy Version: September 2014. I would like to create a script or a one-liner if possible, to add a new user silently/unattendedly. I want this user to have root privileges. Is this possible to do?

From what I could gather, I need one command to add the user, one command to add the user to the root group, and I also need to modify a file. Can all this be done automatically/silently?

User avatar
rpdom
Posts: 17450
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Add user silently

Mon Dec 08, 2014 8:18 pm

man adduser ?

beta-tester
Posts: 1385
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Add user silently

Mon Dec 08, 2014 9:01 pm

aristosv wrote:Hello,

I am using Raspbian Wheezy Version: September 2014. I would like to create a script or a one-liner if possible, to add a new user silently/unattendedly. I want this user to have root privileges. Is this possible to do?

From what I could gather, I need one command to add the user, one command to add the user to the root group, and I also need to modify a file. Can all this be done automatically/silently?

Code: Select all

sudo adduser mrX && sudo adduser mrX sudo
or with quiet

Code: Select all

sudo adduser --quiet mrX && sudo adduser --quiet mrX sudo
or direct output to null

Code: Select all

sudo adduser mrX 1>/dev/null 2>/dev/null && sudo adduser mrX sudo 1>/dev/null 2>/dev/null
... mrX will be member of sudo or do you really want root?
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

aristosv
Posts: 159
Joined: Mon Dec 08, 2014 7:47 pm

Re: Add user silently

Tue Dec 09, 2014 9:10 am

Thanks for the info. I really want the user to be a member of root, not sudo.
Will the commands you provided prompt for password?

beta-tester
Posts: 1385
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Add user silently

Tue Dec 09, 2014 9:28 am

aristosv wrote:Thanks for the info. I really want the user to be a member of root, not sudo.
Will the commands you provided prompt for password?
don't be so shy or lazy... try it out yourself!
(not, if you are logged in and am a sudoer)

btw: you also may generate an account and its membership offline if you edit /etc/password, password-, group, group-, shadow, shadow- files ;)
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

User avatar
DougieLawson
Posts: 39613
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Add user silently

Tue Dec 09, 2014 9:39 am

man adduser

use adduser with --uid 0 --gid 0 to add a root user.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Return to “Raspberry Pi OS”