-4

Was wondering if someone could point me in the right direction.

I'm wanting to create a simple bash script to create user account.

The script will need to prompt the admin for a username and password for the new user. The user will need to be assigned to a group and their home directory needs to be changed to a standard default one that all users will use.

Any help would be great.

Thanks, G

closed as off-topic by Iain, EEAA, MadHatter, Zoredache, Ward Jul 1 '14 at 18:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – EEAA, MadHatter
If this question can be reworded to fit the rules in the help center, please edit the question.

2

You're in luck! that "script" is already on your system)

[alexus@wcmisdlin02 ~]$ useradd 
Usage: useradd [options] LOGIN

Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the
                                new account
  -c, --comment COMMENT         GECOS field of the new account
  -d, --home-dir HOME_DIR       home directory of the new account
  -D, --defaults                print or change default useradd configuration
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -f, --inactive INACTIVE       password inactivity period of the new account
  -g, --gid GROUP               name or ID of the primary group of the new
                                account
  -G, --groups GROUPS           list of supplementary groups of the new
                                account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           use this alternative skeleton directory
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -l, --no-log-init             do not add the user to the lastlog and
                                faillog databases
  -m, --create-home             create the user's home directory
  -M, --no-create-home          do not create the user's home directory
  -N, --no-user-group           do not create a group with the same name as
                                the user
  -o, --non-unique              allow to create users with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       encrypted password of the new account
  -r, --system                  create a system account
  -s, --shell SHELL             login shell of the new account
  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping

[alexus@wcmisdlin02 ~]$ 
  • The questioner doesn't say (s)he's on ubuntu. – MadHatter Jul 1 '14 at 15:53
  • @MadHatter What is Ubuntu has to do with anything?? – alexus Jul 1 '14 at 15:55
  • RedHat and variants don't have adduser. – MadHatter Jul 1 '14 at 15:56
  • Actually OP didn't specified OS (REDHAT OR Ubuntu) and I'm on REDHAT (that's where I copy and paste output of adduser command). – alexus Jul 1 '14 at 15:57
  • (1) I agree, which is why I thought a distro-specific answer that didn't spell out the limitation was a bit naff, and (2) that looks an awful lot like the output from useradd --help. Is there any possibility that you're just using an alias? – MadHatter Jul 1 '14 at 15:59
0

Why do you create a script ? Configure correctely /etc/adduser.conf and use adduser...

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