Thursday, March 19, 2015

Create User in Linux from Bash Script


To create user in Linux system use below script.



root@nirmal-desktop:~# vim userscript.sh

#!/bin/bash
for USER in test1 test2 test3 test4
do
useradd  -s /bin/bash $USER
mkdir -p /home/$USER
chown $USER:$USER -R /home/$USER
PASSINPUT=`echo $USER|cut -c1-3`123
echo "$USER:$PASSINPUT" | chpasswd
echo "$USER successfully created "
done




##################### Enjoy ########################

No comments:

Post a Comment

Linux server hardening | Secure Linux Servers

 Linux server hardening is the process of securing a Linux server by reducing its attack surface and mitigating security risks. The goal is ...