Results 1 to 3 of 3
hey guys,
I am new to the Linux world and am trying to create the following script...
I want to create an interactive script that prompts the user for the ...
- 06-06-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 1
Adding user through script
hey guys,
I am new to the Linux world and am trying to create the following script...
I want to create an interactive script that prompts the user for the following:
user name
user home directory
user login shell
user comment
the script then needs to read those variables that are entered by the user and actually create the user account. and of course, would like the script to display what user account was just created so that i know in fact the script worked successful.
any help would be appreciated - thanks.
- 06-06-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
Only root can create a user, and the guy logged in as root is expected to be skillful with the
utility. It does all that you want to do by specifying options in a command line. There is no real need to write a scipt for keyboard input, things wil just get overloaded.Code:useradd man useradd
If you really want to get user input at the prompt, use the read command, it captures a keyboard input and assign it to a variable that you specify.
Here, the user is prompted with "Be explicit : ", what he types in is assigned to INPUT1 variable.Code:read -p "Be explicit : " INPUT1
Be aware that a user created by the useradd command does not have login privileges (unless you specify the -p option). You must next assign him a password with the passwd command.0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.
- 06-06-2010 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi, kidtech.
Welcome to the forum.
Some distributions of Linux may make life easier for this task. For example, on Debian:
Good luck ... cheers, drlCode:DESCRIPTION adduser and addgroup add users and groups to the system according to command line options and configuration information in /etc/adduser.conf. They are friendlier front ends to the low level tools like useradd, groupadd and usermod programs, by default choosing Debian policy conformant UID and GID values, creating a home directory with skeletal configuration, running a custom script, and other fea- tures. -- excerpt from man adduser, q.v.Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote