Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script to add a user to Linux system
- if [ $(id -u) -eq 0 ]; then
- read -p "Masukkan username : " username
- read -s -p "Masukkan password : " password
- egrep "^$username" /etc/passwd >/dev/null
- if [ $? -eq 0 ]; then
- echo "$username Sudah Ada!"
- exit 1
- else
- pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
- useradd -M -p $pass $username
- [ $? -eq 0 ] && echo "User telah berhasil dibuat!" || echo "Gagal menambah user!"
- fi
- else
- echo "gak oleh rek, iki dudu jatah mu gawe user"
- exit 2
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement