Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I have "adduser -G emails $userinput" in a perl script but I would like to specify what group they are added to. With this command they are added to emails BUT I dont want them to get their own grp.
example being if I add user josh then it creates a group josh.
I would also as a bonus like to know how to get rid of the orphaned group josh. I added him as a test for the script then did a userdel josh but now group josh is vacant and wont let me delete as it is the "primary group for Josh"...
I have "adduser -G emails $userinput" in a perl script but I would like to specify what group they are added to. With this command they are added to emails BUT I dont want them to get their own grp.
example being if I add user josh then it creates a group josh.
You don't say what version/distro of Linux, but most folks user "useradd" to do it. The "-G" is for adding a user to additional groups, other than the main. The "-g" is where you specify the GID of the users primary group. So, look in the /etc/group file for the GID number of the emails group, and use it as the "-g" qualifier.
Quote:
I would also as a bonus like to know how to get rid of the orphaned group josh. I added him as a test for the script then did a userdel josh but now group josh is vacant and wont let me delete as it is the "primary group for Josh"...
=) Thanks
In this case, you'll have to do a "usermod -g <GID number> josh", and move the josh user to a new primary group. Then delete the group with the groupdel command. Man pages are there for all these commands, and will point you to other similar commands (most of the time).
The command to add a user is useradd, to add a group, groupadd, to delete a user, userdel and to delete a group, groupdel. To find out more about how to use them, read
The command to add a user is useradd, to add a group, groupadd, to delete a user, userdel and to delete a group, groupdel. To find out more about how to use them, read
Code:
man useradd
Such a waste of a response. Why do you even bother. I had a PERL issue not a useradd. I also mixed up the -G and -g that I got from reading the man useradd. Don't be such a tool and post "man useradd"
Such a waste of a response. Why do you even bother. I had a PERL issue not a useradd. I also mixed up the -G and -g that I got from reading the man useradd. Don't be such a tool and post "man useradd"
example being if I add user josh then it creates a group josh.
Yes you are correct in this example, but while user josh has his own group, if you add josh to another group, when he accesses the other group files they will belong to the other group, but if josh has newly created items for his group then they are only accessible by josh unless others are added to his group.
Tbones post is quite informative you may want to study it as it looks like it can help you a great deal.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.