Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I'd like to use the adduser command to add a user (with disabled password) via a shell script.

By default, adduser prompts you for various values (e.g., Full Name). Is there any way to submit these values via command line? Or will I need to useradd instead?

share|improve this question
have a look at the man page for adduser. It will help you out. – Zoke Jan 9 '12 at 14:01
@Zoke I couldn't find the info I was looking for on the man page. – Lorin Hochstein Jan 9 '12 at 14:06

2 Answers 2

up vote 85 down vote accepted

Use the --gecos option to skip the chfn interactive part.

adduser --disabled-password --gecos "" username

It's all in the man page. Not the most obvious formulation tho.

--gecos GECOS
          Set  the  gecos field for the new entry generated.  adduser will
          not ask for finger information if this option is given.

The GECOS field is a comma separated list as such: Full name,Room number,Work phone,Home phone

Hope this helps you.

share|improve this answer
Yeah, I can see how I missed that. "gecos" is not an obvious description – Lorin Hochstein Jan 9 '12 at 14:26

useradd can also add users and does not appear to have any form of prompting built in.

useradd -m -p <password> -s /bin/bash <user>
  • -m, --create-home: Create user home director
  • -p, --password: Specify user password
  • -s, --shell: Default shell for logon user.

    Blank will use default login shell specified by the SHELL variable in /etc/default/useradd

  • Substitute <user> Is the login name
  • Substitute <password> Is the login password
share|improve this answer
The options you mention don’t exist for adduser on my (recent) version of Ubuntu. – ᴠɪɴᴄᴇɴᴛ Sep 22 at 20:30
@ᴠɪɴᴄᴇɴᴛ adduser is distinct from useradd, confusing I know. – ThorSummoner Sep 22 at 21:01
Oops, indeed missed that you use its almost namesake … isn’t there a BDFL protecting the command line namespace? ;p – ᴠɪɴᴄᴇɴᴛ Sep 23 at 9:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.