Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
> Writing shell script
post May 4 2015, 04:48 AM
Post #1

Whats this Lie-nix Thing?

Group: Members
Posts: 2
Joined: 4-May 15
Member No.: 18,879

I am trying to write a script that creates users and adds them to groups.
The script to automate the creation of users is:
# Script to add a user to Linux system
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
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!"
echo "Only root may add a user to the system"
exit 2

How could I modify this so that this shell script also additionally adds people to 2 specific groups?
Go to the top of the page
+Quote Post
Start new topic
post May 4 2015, 06:28 AM
Post #2

Its GNU/

Group: Support Specialist
Posts: 1,806
Joined: 23-January 03
Member No.: 360

You can add a menu.
Go to the top of the page
+Quote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 18th March 2018 - 08:18 PM