1822320 Members
6145 Online
109642 Solutions
New Discussion юеВ

Create new user

 
Pat Peter
Occasional Advisor

Create new user

Hi,

Can anyone please tell me how to create a new user, assign a home directory for the user and create a login, password for the user.

Is there any scripts available which would do this job.

Thanks,
Pat
9 REPLIES 9
Ameer Dixit
Advisor

Re: Create new user

Hi Pat,
Th easiest way is to use SAM, unless you want to do it from the command line using the useradd command

Good Luck.
saju_2
Respected Contributor

Re: Create new user

Hi pat

SAM will guide you for a user creation with all the options you can select.

from command line you can use useradd with switch -u for UID, -g for GID , -d for home directory, -s for shell etc.

For more options look man useradd
Mahesh Kumar Malik
Honored Contributor

Re: Create new user

Hi Pat

SAM is the easiest tool to create new user and set its environment

Regards
Mahesh
Cem Tugrul
Esteemed Contributor

Re: Create new user

Pat,
i am using such a kind of syntax and upto now
never faced a problem;

useradd -u $(expr $(cat /etc/passwd|cut -d ':' -f3|sort -n|tail -1) + 1) -g groupname -d/homedir/loginname -s/usr/bin/sh -c"username,deptname" -m
loginname

let's say;
username:Ted Brown
Dept:Finance
loginname:ut0tb (convention what you want)
group:fnc (from /etc/group which you want add user)

so my syntax must be;

useradd -u $(expr $(cat /etc/passwd|cut -d ':' -f3|sort -n|tail -1) + 1) -g fnc -d/homedir/ut0tb -s/usr/bin/sh -c"Ted Brown,Finance" -m ut0tb

My syntax goes to last id and increase 1
and get new id for my new user(ut0tb)...so this means
let's say My last user id is 878 for user
XYX then My new user Ted Brown(ut0tb) got
879 automatically.

-g means groupname
-d dir (path for the users homedir)
-s users running shell
-c comments(username,surname,dept,Pbx,etc)
-m creates the home directory if not exist...

Good Luck,

i think deserved the points!
:-)





Our greatest duty in this life is to help others. And please, if you can't
Venkatesan_5
Frequent Advisor

Re: Create new user

hi,

you can create user in two ways one is executing commands in command line and another is using SAM .

before creating a new user , you should know all details

Logon name :

user id :

gorup id :

home directory

shell....

------------xxxxxxxxxxxxxxxx------------------
syntax :
# useradd -u -g -d

---------xxxxxxxxxxxxxxxxxx---------------
example :
# useradd -u 100 -g test -d /home/test test

here in the above example the logon name is : test , userid is :100 , group id is : test , home directory is : /home/test.

----------xxxxxxxxxxxxxxxxxxx--------------

if you are executing in command prompt then you have to create the home directory manually and after creating user , execute passwd command to assign the password for the user....

....or else
if you are using SAM then make sure....create home directory option is checked...and it will ask for password option , where you can issue the password....

now check with the new user's logon id : u will be able to logon to the system


regds

Venkatesan.
Manoj_36
Advisor

Re: Create new user

Hi,
You can use use SAM to do it in better way. When you use sam for adding a user it gives you a option for selecting whether you want to creat a home directory or not and while creating a user it allows you to set the passwd too.
If you want to create a user through command promt so you can use useradd command with -m option to create a home directory for the use and can use passwd command to set the passwd for that user.

Regards,
Manoj
Fabio Ettore
Honored Contributor

Re: Create new user

Hi Pat,

by SAM you will do it.
Otherwise I usually use two quick commands (pippo is a new user for example):

1.
useradd -m pippo
2.
passwd pippo

-m option on useradd command creates an home directory following contents of /etc/skel.

Hope this helps you.
Please don't forget to assign points. Thanks for that!

Best regards,
Fabio
WISH? IMPROVEMENT!
Brendan McDonald
Frequent Advisor

Re: Create new user

Hi Pat, try this;

useradd -g -d [or use -m to cretae home directory and copy standard files to it] -c .

You can put the -u switch before the -g if you want to specify a UID but usually its easier to let it default to the next highest unused UID.

Cheers
lawrenzo
Trusted Contributor

Re: Create new user

Hello,

standard command I use:

useradd -g -G -s /usr/bin/ksh -c "name in full, dept info, ext " -m

hth
hello