Letak semua nama-nama pengguna di dalam satu teks file name "file" macam nie
rayyan
arrizq
alweena
qistina
Kemudian larikan script yang berikut. Skrip ini akan buat pengguna berdasarkan teks file tadi. Nama dan kata kekunci sama.
#!/usr/bin/bash
# Author: Jeffry Johar
# Date: 6th April 2020
# About: To create multiple linux users with the default password same with the user name
#if no list of user exit
if [ -z $1 ]; then
echo "This \"myusers\" requires list of users"
exit 1
fi
#if user not root exit
if [ "$(id -u)" != "0" ]; then
echo "This \"myusers\" must be run as root"
exit 1
fi
for i in `cat $1`;
do
echo $i;
useradd $i;
echo $i | passwd --stdin $i
done
Contoh penggunaan skirp nie:-
No comments:
Post a Comment