How to add bulk user in linux

Step-1:  Create a list for user.
[root@server ~]# vim userlist
test
tset1
test2

Step-2: write useradd command in a file name as useradd
[root@server ~]# vim useradd
useradd
useradd
useradd

[root@server ~]# paste useradd userlist > hi
[root@server ~]# cat hi
useradd test
useradd tset1
useradd test2

[root@server ~]# sh hi

[root@server ~]# cat /etc/passwd

Now, Create password for bulk user:
Make password file
[root@server ~]# cp  userlist  pass
[root@server ~]# paste -d":" userlist pass > hi2

[root@server ~]# cat hi2
test:test
tset1:test1
test2:test2

[root@server ~]# chpasswd < hi2

How to delete bulk user in linux:
[root@server ~]# vim del
userdel -rf
userdel -rf
userdel –rf

[root@server ~]# cat userlist
test
tset1
test2
[root@server ~]# paste del userlist >hi3
[root@server ~]# cat hi3
userdel -rf     test
userdel -rf     tset1
userdel -rf     test2
[root@server ~]# sh hi3
[root@server ~]# cat /etc/passwd


Post a Comment

Mới hơn Cũ hơn