LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 08-22-2016, 06:28 AM   #1
emiinfo
LQ Newbie
 
Registered: Sep 2015
Location: Bangalore(india)
Distribution: Redhat5/6/,centos,ubuntu.
Posts: 14

Rep: Reputation: Disabled
creating multiple groups in one line of command


how can i create multiple secondary groups, without script.

can you tell me the command used ?

example:
#]groupadd -r group1 group2 group3


Thanks
Amit
 
Old 08-22-2016, 06:39 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Code:
for group in group1 group2 group3;do groupadd -r ${group};done
 
Old 08-22-2016, 06:54 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
or you can use xargs:
Code:
echo group1 group2 group3 | xargs -n 1 groupadd -r
(not tested)
 
Old 08-22-2016, 07:04 AM   #4
emiinfo
LQ Newbie
 
Registered: Sep 2015
Location: Bangalore(india)
Distribution: Redhat5/6/,centos,ubuntu.
Posts: 14

Original Poster
Rep: Reputation: Disabled
multiple groups without code

Thanks for the reply but I need command not code.

Please help me with some terminal commands, example
]# Groupadd -r





Thanks
 
Old 08-22-2016, 07:08 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Quote:
Originally Posted by TenTenths View Post
Code:
for group in group1 group2 group3;do groupadd -r ${group};done
Quote:
Originally Posted by pan64 View Post
Code:
echo group1 group2 group3 | xargs -n 1 groupadd -r
(not tested)
Quote:
Originally Posted by emiinfo View Post
Thanks for the reply but I need command not code.

Please help me with some terminal commands, example
]# Groupadd -r
Those are both command line / terminal commands.
 
1 members found this post helpful.
Old 08-22-2016, 07:33 AM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,609

Rep: Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702
Groupadd only adds one group at a time.
 
1 members found this post helpful.
Old 08-22-2016, 08:03 AM   #7
emiinfo
LQ Newbie
 
Registered: Sep 2015
Location: Bangalore(india)
Distribution: Redhat5/6/,centos,ubuntu.
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks, ten tenths, smalpond.



Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating multiple groups linuxmantra Linux - Newbie 3 12-15-2013 08:53 PM
Creating a singe line entry from data from multiple other sources ml41782 Linux - Newbie 9 06-21-2009 02:28 PM
Command line client for usenet news groups... s2cuts Linux - Software 1 12-03-2008 03:23 AM
Command Line for creating shortcut icons indraveni Linux - General 20 05-09-2006 12:46 AM
How do I create accounts, groups and so on only using the command line? brynjarh Linux - Newbie 2 07-07-2004 02:42 PM


All times are GMT -5. The time now is 08:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration