Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
09-10-2004, 12:37 AM
|
#1
|
LQ Newbie
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9
Rep:
|
why can't i create new group
Hi all, i'm making a script to add user from an input file, it work fine until adding the user to a group name where it says that the group name i want to create is not valid
how do i create new group??
i use the groupadd command and working under red hat fedora core 1
|
|
|
09-10-2004, 03:51 AM
|
#2
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
maybe you did try to add a new group with a gid that already exist ?
Could you post your complete command (with options if any) that you use to create a new group ?
|
|
|
09-10-2004, 06:51 AM
|
#3
|
LQ Newbie
Registered: Sep 2004
Location: New Zealand
Distribution: Fedora Core 1
Posts: 13
Rep:
|
what have you written as the line of script to add the new group??
|
|
|
09-10-2004, 06:10 PM
|
#4
|
LQ Newbie
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9
Original Poster
Rep:
|
here is the line of code:
gawk -F: 'BEGIN {n=0}
{system("groupadd " $3);}
{print "Adding user " $1; system("useradd -c " $4 " " $1); n=1}
do u need to specify the gid to make new group??
|
|
|
09-10-2004, 08:08 PM
|
#5
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
and what are the parameters you pass to your script ?
why is "$2" not used ?
|
|
|
09-10-2004, 09:30 PM
|
#6
|
LQ Newbie
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9
Original Poster
Rep:
|
What i want to pass is
Username:Password:Groupname:Fullname
i used $2 in the line of code with the password which i didn't post
|
|
|
09-11-2004, 01:36 AM
|
#7
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
Did you try to set -g (primary group) to useradd command with $3 value ?
|
|
|
09-11-2004, 03:32 AM
|
#8
|
LQ Newbie
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9
Original Poster
Rep:
|
i tried the useradd -g $3
but it sill doesn't create groups, it says useradd: unknown group groupname
|
|
|
09-11-2004, 03:58 AM
|
#9
|
LQ Newbie
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9
Original Poster
Rep:
|
I finally got it working by using the groupadd command first to create new group if needed
then using the useradd -n -g $3
|
|
|
09-11-2004, 03:59 AM
|
#10
|
LQ Newbie
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9
Original Poster
Rep:
|
thanks Cedrik the -g put me on the right track
|
|
|
09-11-2004, 04:15 AM
|
#11
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
good 
|
|
|
All times are GMT -5. The time now is 04:11 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|