LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   can I write a script for creating a user (https://www.linuxquestions.org/questions/linux-networking-3/can-i-write-a-script-for-creating-a-user-241247/)

zameer_india 10-11-2004 04:22 AM

can I write a script for creating a user
 
Hi,
Good After noon, Everybody....

This is Zameer Ahmed Syed... I would like write a script to create a new user .... i am a new one to unix and Linux... OSs .... if some body have script ot create user then please send me in mail i would really appreciate if some body helps me regding this issue....

and onemorething i would like to know

"what are the other interactive capabilities included in 'C' when compare with 'Bourne Shell'"


Thanq very much....
Zameer Ahmed Syed,
Hyd-India.

acid_kewpie 10-11-2004 04:38 AM

this has nothign whatsoever to do with netowrking, please pick your forum more carefully next time.

there are already commands to add users, e.g. useradd. what else do you wish to be able to do?

and that second bit is just a bit of homework right? if so, please don't ask for help with it here. you need to research it yourself.

zameer_india 10-11-2004 04:44 AM

thanx.............

zameer_india 10-11-2004 04:47 AM

sorry sir, In networking we are creating a user only one at a time my ambiton was creating no of users (how many i want using variables..... ) at a time just runnning one script.

thanq very much for u r reply...

rabeea 10-11-2004 05:43 AM

hi zameer,
if u want to add multiple users using only one command......then the desired command is "newuser". To use this command create a file and write the names of the users u wish to make in the format of /etc/passwd.I mean enter the entries in this file......let say "bulkusers" in the way that there are entries in /etc/passwd. tehn apply the command
#newuser bulkuser
see if it works......it worked in my case.
best of luck

zameer_india 10-11-2004 06:08 AM

Rabeea,
I create the file (just by typing the user names ) name 'user'....

and open the file passwd .... here i didn't get any thing (i am not able to understand ) what it is... look
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
rpm:x:37:37::/var/lib/rpm:/bin/bash
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
squid:x:23:23::/var/spool/squid:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/html/usage:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
amanda:x:33:6:Amanda user:/var/lib/amanda:/bin/bash
canna:x:39:39:Canna Service User:/var/lib/canna:/sbin/nologin
wnn:x:49:49:Wnn System Account:/home/wnn:/sbin/nologin
fax:x:78:78:mgetty fax spool user:/var/spool/fax:/sbin/nologin
netdump:x:34:34:Network Crash Dump user:/var/crash:/bin/bash
nut:x:57:57:Network UPS Tools:/var/lib/ups:/bin/false
ldap:x:55:55:LDAP User:/var/lib/ldap:/bin/false
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
ident:x:98:98:pident user:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
mailman:x:41:41:GNU Mailing List Manager:/var/mailman:/bin/false
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
privoxy:x:73:73::/etc/privoxy:/sbin/nologin
pvm:x:24:24::/usr/share/pvm3:/bin/bash
desktop:x:80:80:desktop:/var/lib/menu/kde:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
zameer:x:500:500:zameer ahmed syed:/home/zameer:/bin/bash
icm:x:501:501:icm_secbad:/home/icm:/bin/bash
zameer123:x:502:502:zameer ahmed syed:/home/zameer123:/bin/sh
zam123:x:503:502:duplicate of zameer:/home/zam123:/bin/sh
icm123:x:504:503:company user:/home/icm123:/bin/bash
zameer11:x:505:500:created for example:/home/zameer11:/bin/bash
zameer111:x:506:500:just example:/home/zameer111:/bin/bash


what's next....

rabeea 10-11-2004 06:14 AM

hi zameer,

noe lets suppose ur file name is "bulkuser" and u want to enter a users named Zameer,Ali and Ahmed.
now the syntax for writing in this file will be

zameer:x:510:510:created forexample:/home/zameer:/bin/bash

ali:x:511:511:created for example:/home/ali:/bin/bash

ahmed:x:512:512:created for example:/home/ahmed:/bin/bash

save and exit the file.After putting these entries run the command

#newusers bulkuser

rabeea 10-11-2004 06:15 AM

just create the file using the joe or cat command . enter these entries and run the command.

zameer_india 10-11-2004 06:46 AM

hi, Rabeea.....
I follow u .... I create a file using and i done what ever u said .... after runnint the command newusers it says invalid line... why it was ...


ThanQ
Zameer Ahmed Syed...

zameer_india 10-11-2004 06:49 AM

Rabeea,

should i use this line as first line #!/usr/bin/

rabeea 10-11-2004 06:58 AM

yeah u can

if u cant run this command "newusers" then u can even write usr/bin/newuser.............hey .....do check whether it is newuser or newusers.

zameer_india 10-11-2004 06:59 AM

Could anybody help me what i s the Problem.....

acid_kewpie 10-11-2004 07:01 AM

useradd is more common. personally i'd never recommend editing /etc/passwd directly.

zameer_india 10-11-2004 07:19 AM

still it gives me message like "Invalid line"......

acid_kewpie 10-11-2004 07:22 AM

well forget this silly script... you've still not been able to describe what you actually want to do... just try and run "useradd" as root. sometimes it might be adduser.


All times are GMT -5. The time now is 01:08 AM.