<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Linux Shell script to add a user with a password to the system</title> <atom:link href="http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: please help me</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-175439</link> <dc:creator>please help me</dc:creator> <pubDate>Thu, 03 Nov 2011 20:29:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-175439</guid> <description>The student should write a bash program named myuseradd that accepts a list of users as argument
Script syntax: myuseradd  [ [ ..]]
At least one  argument must be provided and must not exceed 10 alphanumeric characters.
The script must not use the usedadd or similar commands. It must:
1-	Check if user is root. If not the script cannot be run and it exits.
2-	Check the number of arguments. If none the script exits.
3-	Check if  is already used, if yes the script exits.
4-	Ask the user to provide the following data:
a. Home directory:
Default is /home/
The script accepts either /home/ or /.  must
not exceed 10 alphanumeric characters and the entered home directory
must not exist already.
b. Login shell
Default is /bin/bash
The script can accept one of the shells as listed in /etc/shells.
If provided data does not meet conditions, the user is asked to enter the data again
5-	Add user with name , provided home directory and login shell to the system&#039;s users (/etc/passwd file).
6-	Assign userid (must be the first available userid greater or equal to 500).
7-	Create a new group with group name  and gid same as uid and assign it as primary group. This must be done by adding an entry to /etc/group.If the group already exists, no change is done.
8-	Create home directory and set required permissions.
9-	Copy startup scripts to the home directory (from /etc/skel).
10-	Create a line in /etc/shadow that corresponds to the user with a blank password.
11-	Call the passwd program to set the password.
12-	Produce an output the summarize what it did.</description> <content:encoded><![CDATA[<p>The student should write a bash program named myuseradd that accepts a list of users as argument</p><p>Script syntax: myuseradd  [ [ ..]]</p><p>At least one  argument must be provided and must not exceed 10 alphanumeric characters.</p><p>The script must not use the usedadd or similar commands. It must:</p><p>1-	Check if user is root. If not the script cannot be run and it exits.<br
/> 2-	Check the number of arguments. If none the script exits.<br
/> 3-	Check if  is already used, if yes the script exits.<br
/> 4-	Ask the user to provide the following data:<br
/> a. Home directory:<br
/> Default is /home/<br
/> The script accepts either /home/ or /.  must<br
/> not exceed 10 alphanumeric characters and the entered home directory<br
/> must not exist already.<br
/> b. Login shell<br
/> Default is /bin/bash<br
/> The script can accept one of the shells as listed in /etc/shells.</p><p>If provided data does not meet conditions, the user is asked to enter the data again</p><p>5-	Add user with name , provided home directory and login shell to the system&#8217;s users (/etc/passwd file).</p><p>6-	Assign userid (must be the first available userid greater or equal to 500).</p><p>7-	Create a new group with group name  and gid same as uid and assign it as primary group. This must be done by adding an entry to /etc/group.If the group already exists, no change is done.</p><p>8-	Create home directory and set required permissions.<br
/> 9-	Copy startup scripts to the home directory (from /etc/skel).</p><p>10-	Create a line in /etc/shadow that corresponds to the user with a blank password.</p><p>11-	Call the passwd program to set the password.</p><p>12-	Produce an output the summarize what it did.</p> ]]></content:encoded> </item> <item><title>By: franka</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-174591</link> <dc:creator>franka</dc:creator> <pubDate>Mon, 03 Oct 2011 06:42:57 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-174591</guid> <description>we really appreciate your useful code</description> <content:encoded><![CDATA[<p>we really appreciate your useful code</p> ]]></content:encoded> </item> <item><title>By: jyothi</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-173380</link> <dc:creator>jyothi</dc:creator> <pubDate>Thu, 18 Aug 2011 05:07:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-173380</guid> <description>pass=$(perl -e &#039;print crypt($ARGV[0], &quot;password&quot;)&#039; $password)
in this block what does $ARGV[0] stores and how it will work</description> <content:encoded><![CDATA[<p>pass=$(perl -e &#8216;print crypt($ARGV[0], &#8220;password&#8221;)&#8217; $password)<br
/> in this block what does $ARGV[0] stores and how it will work</p> ]]></content:encoded> </item> <item><title>By: John</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-170841</link> <dc:creator>John</dc:creator> <pubDate>Sat, 23 Apr 2011 05:13:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-170841</guid> <description>i just want to know the script
Write a shell script that can be used to:
Detailed requirements
1.	The script can only be executed by the root user, administrator or users with administrative rights.
2.	If the root user starts the program as specified, it should read the input file and check the new users’ information one by one. If a new user’s information is valid, it should create the account for the user and write the account information to a report file. The report file should have the following format:
account_name;user_id;group_name;group_id;created_date;user_fullname
3.	If a new user’s information is not valid, it should not create the account for the user. The error should be written to an error report file. You need to specify the file format.
4.	If the root user executes the script incorrectly, e.g., without the necessary parameters or with incorrect parameters, it should provide an appropriate help message to the user. For example, it could show the correct usage of the command.
5.	If the root user executes the command with the –h switch, the program should give detailed information about the program and the file structure of the input file.
6.	The input file should have the following structure:
•	Each line is a user record.
•	Each record has four fields separated by commas (,) as follows:
Username,password,groupname,fullname
Note:   The password field must be between 9 and 12 characters long. The field for the user’s full name may contain blank spaces. You must specify the features of the other fields. If a group does not exist, the program should create a default group automatically.</description> <content:encoded><![CDATA[<p>i just want to know the script<br
/> Write a shell script that can be used to:<br
/> Detailed requirements<br
/> 1.	The script can only be executed by the root user, administrator or users with administrative rights.<br
/> 2.	If the root user starts the program as specified, it should read the input file and check the new users’ information one by one. If a new user’s information is valid, it should create the account for the user and write the account information to a report file. The report file should have the following format:<br
/> account_name;user_id;group_name;group_id;created_date;user_fullname<br
/> 3.	If a new user’s information is not valid, it should not create the account for the user. The error should be written to an error report file. You need to specify the file format.<br
/> 4.	If the root user executes the script incorrectly, e.g., without the necessary parameters or with incorrect parameters, it should provide an appropriate help message to the user. For example, it could show the correct usage of the command.<br
/> 5.	If the root user executes the command with the –h switch, the program should give detailed information about the program and the file structure of the input file.<br
/> 6.	The input file should have the following structure:<br
/> •	Each line is a user record.<br
/> •	Each record has four fields separated by commas (,) as follows:<br
/> Username,password,groupname,fullname<br
/> Note:   The password field must be between 9 and 12 characters long. The field for the user’s full name may contain blank spaces. You must specify the features of the other fields. If a group does not exist, the program should create a default group automatically.</p> ]]></content:encoded> </item> <item><title>By: naushad</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-168686</link> <dc:creator>naushad</dc:creator> <pubDate>Thu, 10 Feb 2011 09:29:27 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-168686</guid> <description>OR
As a root
vim usershow
1 #!/bin/bash
2 #this script displays the users in machine.
3 egrep -v ^xyz /etc/passwd &#124; cut -d&quot;:&quot; -f1 &#124;less
esc:wq
cp usershow /usr/local/sbin/
chmod -R +x /usr/local/sbin
Thats it...Enjoymaadi
usershow</description> <content:encoded><![CDATA[<p>OR<br
/> As a root<br
/> vim usershow<br
/> 1 #!/bin/bash<br
/> 2 #this script displays the users in machine.<br
/> 3 egrep -v ^xyz /etc/passwd | cut -d&#8221;:&#8221; -f1 |less<br
/> esc:wq<br
/> cp usershow /usr/local/sbin/<br
/> chmod -R +x /usr/local/sbin<br
/> Thats it&#8230;Enjoymaadi<br
/> usershow</p> ]]></content:encoded> </item> <item><title>By: naushad</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-168685</link> <dc:creator>naushad</dc:creator> <pubDate>Thu, 10 Feb 2011 09:15:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-168685</guid> <description>egrep -v ^xyz /etc/passwd &#124; cut -d&quot;:&quot; -f1
Add this line in a script which displays all the users in your machine
i have used ^xyz , Starting with that. genarally user names will never start with that , so we get the desired result as output becouse of the option -v .</description> <content:encoded><![CDATA[<p>egrep -v ^xyz /etc/passwd | cut -d&#8221;:&#8221; -f1</p><p>Add this line in a script which displays all the users in your machine<br
/> i have used ^xyz , Starting with that. genarally user names will never start with that , so we get the desired result as output becouse of the option -v .</p> ]]></content:encoded> </item> <item><title>By: hemanth</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-168125</link> <dc:creator>hemanth</dc:creator> <pubDate>Fri, 07 Jan 2011 11:26:34 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-168125</guid> <description>hi guys
can any one tell me how to write a script such that the script reads the password and enters to tat user</description> <content:encoded><![CDATA[<p>hi guys<br
/> can any one tell me how to write a script such that the script reads the password and enters to tat user</p> ]]></content:encoded> </item> <item><title>By: Anil</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-165326</link> <dc:creator>Anil</dc:creator> <pubDate>Thu, 23 Dec 2010 13:14:23 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-165326</guid> <description>Very good script.</description> <content:encoded><![CDATA[<p>Very good script.</p> ]]></content:encoded> </item> <item><title>By: soumyav</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-159198</link> <dc:creator>soumyav</dc:creator> <pubDate>Thu, 26 Aug 2010 15:58:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-159198</guid> <description>Hey I need a scrip to add 100 users to UNIX server using an Input file which has two input one full name the other username . But i need to generate password in the script which gets incremented  with each added user ....
Thanks a lot in advance ....
soumya</description> <content:encoded><![CDATA[<p>Hey I need a scrip to add 100 users to UNIX server using an Input file which has two input one full name the other username . But i need to generate password in the script which gets incremented  with each added user &#8230;.</p><p>Thanks a lot in advance &#8230;.</p><p>soumya</p> ]]></content:encoded> </item> <item><title>By: Servando</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-159005</link> <dc:creator>Servando</dc:creator> <pubDate>Wed, 18 Aug 2010 18:25:51 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-159005</guid> <description>It was very useful your sample,
thanks
Servando</description> <content:encoded><![CDATA[<p>It was very useful your sample,</p><p>thanks</p><p>Servando</p> ]]></content:encoded> </item> <item><title>By: majo053</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-153371</link> <dc:creator>majo053</dc:creator> <pubDate>Sat, 06 Feb 2010 23:23:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-153371</guid> <description>simple:  echo PASSWORD &#124; passwd USER --stdin</description> <content:encoded><![CDATA[<p>simple:  echo PASSWORD | passwd USER &#8211;stdin</p> ]]></content:encoded> </item> <item><title>By: Harold Osborn</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-152920</link> <dc:creator>Harold Osborn</dc:creator> <pubDate>Fri, 15 Jan 2010 04:30:50 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-152920</guid> <description>i need to help me. i want to good 100% user email, password and forget password.
frisrt sign user email then get get password number in then open in base.
if forget password then send email get password
Can anyone help me thank harold</description> <content:encoded><![CDATA[<p>i need to help me. i want to good 100% user email, password and forget password.<br
/> frisrt sign user email then get get password number in then open in base.<br
/> if forget password then send email get password<br
/> Can anyone help me thank harold</p> ]]></content:encoded> </item> <item><title>By: Ravi Sajjan</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-151180</link> <dc:creator>Ravi Sajjan</dc:creator> <pubDate>Fri, 23 Oct 2009 08:25:55 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-151180</guid> <description>Hello Everyone,
My self Ravi and I am trying to make one PHP page, from which i can able to create
new user in linux. where in php code will show three boxes
1.) New User Name:
2.) Password:
3.) Botton: Add now
with this php code i want to add new user in linux through web interface.
Kindly please help me out to do that so.
Regadrs,
Ravi</description> <content:encoded><![CDATA[<p>Hello Everyone,<br
/> My self Ravi and I am trying to make one PHP page, from which i can able to create<br
/> new user in linux. where in php code will show three boxes<br
/> 1.) New User Name:<br
/> 2.) Password:<br
/> 3.) Botton: Add now<br
/> with this php code i want to add new user in linux through web interface.</p><p>Kindly please help me out to do that so.</p><p>Regadrs,<br
/> Ravi</p> ]]></content:encoded> </item> <item><title>By: Dnyan</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-150181</link> <dc:creator>Dnyan</dc:creator> <pubDate>Mon, 17 Aug 2009 16:50:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-150181</guid> <description>Hi all,
Can someone let me know, How to write script for password expiry notification in solaries.</description> <content:encoded><![CDATA[<p>Hi all,</p><p>Can someone let me know, How to write script for password expiry notification in solaries.</p> ]]></content:encoded> </item> <item><title>By: Charanjit Singh</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-149335</link> <dc:creator>Charanjit Singh</dc:creator> <pubDate>Sun, 05 Jul 2009 08:59:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-149335</guid> <description>Hi Vivek(nixcraft)
Your mentioned shell script giving me an error message while executing it
&quot;line 19: syntex error: unexpected end of the file&quot;
Please check and where it is get stuck..
Thanks
Charanjit Singh</description> <content:encoded><![CDATA[<p>Hi Vivek(nixcraft)<br
/> Your mentioned shell script giving me an error message while executing it<br
/> &#8220;line 19: syntex error: unexpected end of the file&#8221;<br
/> Please check and where it is get stuck..<br
/> Thanks<br
/> Charanjit Singh</p> ]]></content:encoded> </item> <item><title>By: Gordon</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-148802</link> <dc:creator>Gordon</dc:creator> <pubDate>Tue, 02 Jun 2009 22:29:34 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-148802</guid> <description>Sample shell script to add a user
How do I change this to add the users full name ans login shell</description> <content:encoded><![CDATA[<p>Sample shell script to add a user</p><p>How do I change this to add the users full name ans login shell</p> ]]></content:encoded> </item> <item><title>By: Mukundan</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-148744</link> <dc:creator>Mukundan</dc:creator> <pubDate>Thu, 28 May 2009 15:01:17 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-148744</guid> <description>HI
I like to add bulk of user using bash scripting taking the user name from a text file from a given location and also want to set a sample passwd for the all user who have been created. and also the script has to mail to the corresponding user regarding the username and passwd .  Can anyone help me out
Thanks in advance</description> <content:encoded><![CDATA[<p>HI</p><p>I like to add bulk of user using bash scripting taking the user name from a text file from a given location and also want to set a sample passwd for the all user who have been created. and also the script has to mail to the corresponding user regarding the username and passwd .  Can anyone help me out</p><p>Thanks in advance</p> ]]></content:encoded> </item> <item><title>By: palani</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-147834</link> <dc:creator>palani</dc:creator> <pubDate>Wed, 25 Mar 2009 07:23:20 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-147834</guid> <description>hi
how to create new user to assign perssion to particular shell and set userid and groupid make this one line command</description> <content:encoded><![CDATA[<p>hi<br
/> how to create new user to assign perssion to particular shell and set userid and groupid make this one line command</p> ]]></content:encoded> </item> <item><title>By: rapsa</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-147683</link> <dc:creator>rapsa</dc:creator> <pubDate>Mon, 16 Mar 2009 14:32:33 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-147683</guid> <description>how about this one liner script
# useradd -m -p `perl -e &#039;print crypt(&quot;your_password&quot;, &quot;salt&quot;),&quot;\n&quot;&#039;` your_username</description> <content:encoded><![CDATA[<p>how about this one liner script</p><p># useradd -m -p `perl -e &#8216;print crypt(&#8220;your_password&#8221;, &#8220;salt&#8221;),&#8221;\n&#8221;&#8216;` your_username</p> ]]></content:encoded> </item> <item><title>By: laknath</title><link>http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-147365</link> <dc:creator>laknath</dc:creator> <pubDate>Sat, 21 Feb 2009 19:41:57 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html#comment-147365</guid> <description>hi,
i compile this program but when i move to the second part I cant execute it in root . I got a error???
No  such  file or directory
why is   that ???
pls reply me....</description> <content:encoded><![CDATA[<p>hi,<br
/> i compile this program but when i move to the second part I cant execute it in root . I got a error???</p><p>No  such  file or directory</p><p>why is   that ???<br
/> pls reply me&#8230;.</p> ]]></content:encoded> </item> </channel> </rss>
