Page 1 of 1

Add user silently

Posted: Mon Dec 08, 2014 7:54 pm
by aristosv
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?

Re: Add user silently

Posted: Mon Dec 08, 2014 8:18 pm
by rpdom
man adduser ?

Re: Add user silently

Posted: Mon Dec 08, 2014 9:01 pm
by beta-tester
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?

Re: Add user silently

Posted: Tue Dec 09, 2014 9:10 am
by aristosv
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?

Re: Add user silently

Posted: Tue Dec 09, 2014 9:28 am
by beta-tester
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 ;)

Re: Add user silently

Posted: Tue Dec 09, 2014 9:39 am
by DougieLawson
man adduser

use adduser with --uid 0 --gid 0 to add a root user.