본문 바로가기

Linux

사용자생성 스크립트

사용자 생성 스크립트

 

# vi createuser.sh

아래의 내용을 입력한 후 저장하고 빠져 나온다.

 

#!/bin/bash
while true
do
echo -n "Insert into ID:"
read id
echo -n "Insert into your full name:"
read fn
echo -n "Insert into password:"
read pa
useradd -c "$fn" -p `openssl passwd -1 $pa` "$id"
echo -n "An account was completed as the $id"
echo ""
done
echo "END"

 

#sh createuser.sh 

를 실행하여 사용자를 생성하고 더 이상 만들 필요가 없는 경우 Ctrl+c 로 빠져 나온다.