Scripts to create logins from bash command – for creating multiple accounts
Heres the script:
cat «EOF > login.sh
for i in `cat logins` ; do
login=`echo ”$i”|awk -F”:” '{print $2}’`;
comment=”`echo ”$i”|awk -F”:” '{print $1}’`”;
gr=”`echo ”$i”|awk -F”:” '{print $3}’`”;
echo ”login –» $login –Comment –» $comment –Group –»$gr –”;
echo ”useradd -c ”$comment” -d /export/home/$login -m -g $gr -s /bin/bash $login”
useradd -c ”$comment” -d /export/home/$login -m -g $gr -s /bin/bash $login
done
You would need to create file called logins to store the comment, login name and the group. The group must have already been created. Here is an example of the file:
cat logins
Amit Agarwal:amitag:test
Related Articles:
- 2010/05/24 Menu driven ssh.
- 2010/05/19 bash script to change icon theme to check out all the installed themes (personal)
- 2010/05/07 bash script to periodically change the cursor theme.
- 2010/02/10 bash script with sql to get the number of records from multiple tables.
- 2010/06/06 bash completion not working on Fedora
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.