<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux and Open Source Blog &#187; linux user</title>
	<atom:link href="http://linewbie.com/tag/linux-user/feed" rel="self" type="application/rss+xml" />
	<link>http://linewbie.com</link>
	<description>News, Reviews, Thoughts and Trends in Linux and Open Source World.</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Bash Script to Mass Create Users And Change Passwords</title>
		<link>http://linewbie.com/2007/11/using-bash-script-to-mass-create-users-and-change-passwords.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-bash-script-to-mass-create-users-and-change-passwords</link>
		<comments>http://linewbie.com/2007/11/using-bash-script-to-mass-create-users-and-change-passwords.html#comments</comments>
		<pubDate>Thu, 08 Nov 2007 06:40:27 +0000</pubDate>
		<dc:creator>Linewbie.com</dc:creator>
				<category><![CDATA[guides]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[change password]]></category>
		<category><![CDATA[create user]]></category>
		<category><![CDATA[force password change]]></category>
		<category><![CDATA[linux create user]]></category>
		<category><![CDATA[linux user]]></category>

		<guid isPermaLink="false">http://www.linewbie.com/2007/11/using-bash-script-to-mass-create-users-and-change-passwords.html</guid>
		<description><![CDATA[These two scripts are very important for the system admin who regularly works with mail servers and somehow forgets to backup his system username and password! Letâ€™s say somehow we lost the usernames and passwords of the mail server. In &#8230; <a href="http://linewbie.com/2007/11/using-bash-script-to-mass-create-users-and-change-passwords.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>These two scripts are very important for the system admin who regularly  works with mail servers and somehow forgets to backup his system  username and password! Letâ€™s say somehow we lost the usernames and passwords of the mail server. In this case the admin has  to manually create all the users and then change the passwords for  all the users. Tedious job. Letâ€™s make our life easier.</p>
<p>First create a file which contains all the user name. Something like this:</p>
<p><code>nurealam<br />
nayeem<br />
mrahman<br />
farid<br />
rubi<br />
sankar</code></p>
<p>Save the file as <span class="system">userlist.txt</span>. Now  create the following bash file:</p>
<p><code>#!/bin/sh<br />
for i in `more userlist.txt `<br />
do<br />
echo $i<br />
adduser $i<br />
done</code></p>
<p>Save the file and exit.</p>
<p class="command">chmod 755 userlist.txt</p>
<p>Now run the file:</p>
<p class="command">./userlist.txt</p>
<p>This will add all the users to the system. Now we have to change the  passwords. Let&#8217;s say we want <span class="system">username123</span> as password. So for user <span class="system">nayeem</span>  the password will be <span class="system">nayeem123</span>, <span class="system">rubi123</span> for user <span class="system">rubi</span> and so on.</p>
<p>Create another bash file as follows:</p>
<p><code>#!/bin/sh<br />
for i in `more userlist.txt `<br />
do<br />
echo $i<br />
echo $i"123" | passwd â€“-stdin "$i"<br />
echo; echo "User $usernameâ€™s password changed!"<br />
done</code></p>
<p>Run the file. All the passwords are changed.</p>
<p>If you want to force all your users to change password, use the following code:</p>
<p>Force all your users to change their passwords because the temporary password is a security risk</p>
<p><code>#!/bin/sh<br />
for i in `more userlist.txt `<br />
do<br />
echo $i<br />
echo $i | change -d 0 "$i"<br />
echo; echo "User $i will be forced to change password on next login!"<br />
done</code></p>
<p>I then log as that user and see this</p>
<p>WARNING: Your password has expired.<br />
You must change your password now and login again!<br />
Changing password for user amcorona.<br />
Changing password for amcorona<br />
(current) UNIX password:</p>
]]></content:encoded>
			<wfw:commentRss>http://linewbie.com/2007/11/using-bash-script-to-mass-create-users-and-change-passwords.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

