Basic Bash Scripting in Linux (Part-1)

 


Script for adding users and their password:

====================================

(1) Method-1

=============

[root@itbd ~]# vim users.sh

for a in `seq 1 5`; do

useradd ituser$a;

echo pass$a | passwd --stdin ituser$a;

chage -d 0 ituser$a;

done

[root@itbd ~]# chmod +x user.sh

[root@itbd ~]# bash users.sh

(2) Method-2

============

[root@itbd ~]# vim admin-user.txt mamun imran shazzad

[root@itbd ~]# vim users.sh

#!/bin/sh for a in `more admin-user.txt` do echo "$a" useradd $a echo "123" | passwd --stdin "$a" chage -d 0 $a done [root@itbd ~]# chmod +x user.sh [root@itbd ~]# bash users.sh


Method-3:

==========

#vim  user-list.txt

mushfiq:mushfiq123:1003:1003::/home/mushfiq:/bin/bash

testuser:testuser123:1004:1004::/home/testuser:/bin/bash

demouser:demouser123:1005:1005::/home/demouser:/bin/bash


# newusers user-list.txt                                                                                  [to create bulk users from given files in Linux system.]

# grep "mushfiq\|testuser\|demouser"  /etc/passwd                         [To check those users]

Comments

  1. Great Post. Very informative. Keep Sharing!!

    Apply Now for MCSA Training in Noida

    For more details about the course fee, duration, classes, certification, and placement call our expert at 70-70-90-50-90

    ReplyDelete

Post a Comment

Popular posts from this blog

Some Questions for MTCNA Exam

ডিপ্লোমা লেভেল এর ইন্ডাস্ট্রিয়াল এটাচমেন্ট এ আসার পূর্বে একটু ভেবে আসার অনুরোধ রইলো

Basic Router & Switch IOS commands