You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash# Script to add a user to Linux systemif [ $(id -u)-eq 0 ];thenread -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $?-eq 0 ];thenecho"$username exists!"exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")'$password)
useradd -m -p $pass$username
[ $?-eq 0 ] &&echo"User has been added to system!"||echo"Failed to add a user!"fielseecho"Only root may add a user to the system"exit 2
fi