ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
just wondering, I'm working on a script that add users requesting shell accounts to a system by having the user login as "newuser" which runs the script. But with my novice script programming skills, the only script I"m able to write for this task must run with some root permissions leaveing large sercurity holes in the system, with all that said, has anyone seen any scripts or programs for easiely adding users?
I have a script that easily adds users, but, you must be root, your not going to find a script to add users that doesnt run as root, we'll you might, but its not advised.
The script is at http://www.ccsi.com/~stratus, its called 'useradd.sh', instructions for use are inside the file.
As for running it as a user, you can always allow a group of users by looking into 'sudoers', 'sudo' and 'visudo'.
thanks man, but thats not really what i'm looking for i think more user friendly for the users who dont know any thing about arguments
some thing like this
#!/bin/bash
username=" "
clear
echo "Welcome to n3tlab. this program will help you add an account to our system"
echo "What would you like your username to be?"
read username
if test -e /home/$username
then
echo "sorry but that username is in use, please choose another"
read username
echo "now to change your password"
passwd $username
echo "your account has been succesfully created to start using it telnet to us then login with your new account name"
echo "thank you for using n3tlab"
logout
else
echo "ok, your username is $username"
echo "now to change your password"
passwd $username
echo "Your account has succesfully been created, to begin using it telnet to us and login with your account name"
echo "thank you for using n3tlab"
logout
fi
#done
but i need to know a way to make the script work better, with my skills it will only test to see if the user is taken once then, if the user inputs another used username it will try to add the username any ways, can some one help me out with this?
#!/bin/bash
SUCESS=
PASS=
username=" "
clear
echo "Welcome to n3tlab. this program will help you add an account to our system"
echo "What would you like your username to be?"
read username
if test -e /home/$username; then
SUCESS=1
fi
while [ "$SUCESS" = 1 ]
do
echo "sorry but that username is in use, please choose another"
read username
if ! test -e /home/$username; then
SUCESS=0
fi
done
echo "choose a password, minimum 8 charators"
read TMP
while [ ${#TMP} -lt 7 ] || [ ${#TMP} -gt 50 ]
do
if [ ${#TMP} -lt 7 ]; then
echo "The password needs to be greater than 8 characters"
echo "Please input your password..."
elif [ ${#TMP} -gt 50 ]; then
echo "Your password needs to be less 50 characters..."
echo "Please input your password..."
fi
read TMP
done
PASS=$(openssl passwd -1 "$TMP")
useradd -p "$PASS" "$username"
echo "your account has been succesfully created to start using it telnet to us then login with your new account name"
echo "thank you for using n3tlab"
logout
exit 0
#done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.