Beruflich Dokumente
Kultur Dokumente
ME NU
nixCraft
LinuxandUnixtutorialsfornewandseasonedsysadmin.
Howto:LinuxAddUserToGroup
byV I V E K GI TE onMA RCH 14, 2006 las t updat ed A P RI L 21, 2014
inB A S H S HE LL,LI NUX ,US E R MA NA GE ME NT
H
owcanIaddausertoagroupunderLinuxoperatingsystem
usingcommandlineoptions?Howtoaddanexistinguserinto
agroupinLinuxusingcommandlineoptions?
Youcanusetheuseraddorusermodcommandstoaddausertoa
group.Theuseraddcommandcreatesanewuserorupdatedefaultnewuser
information.Theusermodcommandmodifiesauseraccountanditisusefultoadduser
toexistinggroups.TherearetwotypesofgroupsunderLinuxoperatingsystems:
1.Primaryusergroup.
2.Secondaryorsupplementaryusergroup.
Alluseraccountrelatedinformationarestoredinthefollowingfiles:
1./etc/passwdContainsonelineforeachuseraccount.
2./etc/shadowContainsthepasswordinformationinencryptedformatforthe
systemsaccountsandoptionalaccountaginginformation.
3./etc/groupDefinesthegroupsonthesystem.
4./etc/default/useraddThisfilecontainsavalueforthedefaultgroup,ifnoneis
specifiedbytheuseraddcommand.
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 1/50
4/14/2016 Howto:LinuxAddUserToGroup
5./etc/login.defsThisfiledefinesthesitespecificconfigurationfortheshadow
passwordsuitestoredin/etc/shadowfile.
useraddExampleAddanewusertosecondarygroup
Youneedtotheuseraddcommandtoaddnewuserstoexistinggroup(orcreateanew
groupandthenadduser).Ifgroupdoesnotexist,createit.Thesyntaxisasfollows:
useraddG{groupname}username
Inthisexample,createanewusercalledvivekandaddittogroupcalleddevelopers.
Firstloginasarootuser(makesuregroupdevelopersexists),enter:
#grepdevelopers/etc/group
Output:
developers:x:1124:
Ifyoudonotseeanyoutputthenyouneedtoaddgroupdevelopersusingthegroupadd
command:
#groupadddevelopers
Next,addausercalledvivektogroupdevelopers:
#useraddGdevelopersvivek
Setuppasswordforuservivek:
#passwdvivek
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 2/50
4/14/2016 Howto:LinuxAddUserToGroup
Ensurethatuseraddedproperlytogroupdevelopers:
#idvivek
Output:
uid=1122(vivek)gid=1125(vivek)groups=1125(vivek),1124(developers)
PleasenotethatcapitalG(G)optionaddusertoalistofsupplementarygroups.Each
groupisseparatedfromthenextbyacomma,withnointerveningwhitespace.For
example,adduserjerrytogroupsadmins,ftp,www,anddevelopers,enter:
#useraddGadmins,ftp,www,developersjerry
useraddexampleAddanewusertoprimarygroup
Toaddausertonytogroupdevelopersusethefollowingcommand:
#useraddgdeveloperstony
#idtony
Sampleoutputs:
uid=1123(tony)gid=1124(developers)groups=1124(developers)
Pleasenotethatsmallg(g)optionaddusertoinitiallogingroup(primarygroup).The
groupnamemustexist.Agroupnumbermustrefertoanalreadyexistinggroup.
usermodexampleAddaexistingusertoexistinggroup
Addexistingusertonytoftpsupplementary/secondarygroupwiththeusermod
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 3/50
4/14/2016 Howto:LinuxAddUserToGroup
commandusingtheaoption~i.e.addtheusertothesupplementalgroup(s).Useonly
withGoption:
#usermodaGftptony
Inthisexample,changetonyusersprimarygrouptowww,enter:
#usermodgwwwtony
usermodcommandoptionssummary
Option Purpose
a Addtheusertothesupplementarygroup(s).UseonlywiththeG
append option.
gGROUP
UsethisGROUPasthedefaultgroup.
gidGROUP
GGRP1,GRP2
groups AddtheusertoGRP1,GRP2secondarygroup.
GRP1,GRP2
Anoteaboutsecurity
Ifyouaddordeleteusertoexistinggroup,youmustchangetheownerofanycrontab
filesoratjobsmanually.YoumustmakeanychangesinvolvingNISontheNISserver
too.
AnoteaboutGUItool
YouwillprobablyfindtheuseoftheGUItooleasy.KDEusercanuseKUsertooland
theGNOMEusercanuseusersadmintoolcalledsystemconfigusers:
#systemconfigusers
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 4/50
4/14/2016 Howto:LinuxAddUserToGroup
Sampleoutputs:
Fig.01:UserManagerToolinaction(imagecreditFedoraproject)
Seealso
Formoreinformationtypethefollowingcommandattheshellprompt:
$manusermod
$manuseradd
Morelikethis:
Howto:Linuxcreatinguseraccountundergroup
UbuntuLinux:AddaUserToGroup
FreeBSDaddausertogroup
HowTo:UNIXAddAUserToAGroup
UbuntuLinux:AddaUserToGroupwwwdata(ApacheGroup)
Linuxaddauserusingcommandlinetools
RemoveLinuxUserFromaSecondaryGroup(SupplementaryGroups)
FreeBSDAddaUserToWheelGroupCommand
Linux:ShowTheGroupsaUserIsIn
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 5/50
4/14/2016 Howto:LinuxAddUserToGroup
Understanding/etc/groupFile
{129commentsaddone}
praj March26,2006,4:05pm
Howcanirunthepasswdcommand
noninteractivelyinlinux.Iwanttochangethepasswordthroughascriptfile.How
cani
invokethepasswdcommandthruascriptfilenoninteractively.
Ifthatsnotpossiblethensuggest
somealternative
RE P LY LI NK
manoj May6,2011,2:18pm
Multipleentriesnamedaudioin/etc/group.Pleasefixthiswithpwckorgrpck.
usermod:erroraddingnewgroupentry
RE P LY LI NK
nixcraft March26,2006,8:02pm
Seeshellscriptexamplehere
RE P LY LI NK
BackSeat August14,2006,3:41pm
praj:seechpasswd(8)
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 6/50
4/14/2016 Howto:LinuxAddUserToGroup
RE P LY LI NK
BnK December6,2006,8:51pm
thanks!
timesavingtipfornewadmin.Icanreadmanpagebutitisfullofshitloadandno
examplesatall.keepitupgoodwork!
RE P LY LI NK
Sren June19,2007,10:37am
Ifindtheeasiestwaytoaddausertoagroupisusinggpasswdlikethis:
gpasswda
RE P LY LI NK
Sren June19,2007,10:38am
Thiseditorbugsme:)Thecommandshouldbe:
gpasswdausergroup
RE P LY LI NK
Frogbert July11,2007,6:52am
Thisiswrong,usermodGftptonywilltakeyououtofallyourexistinggroups.Notadd
anewone.
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 7/50
4/14/2016 Howto:LinuxAddUserToGroup
nixCraft July12,2007,6:13pm
YesImaddingaexistingusertoexistinggroup,buttokeepuserinotheroldgroupyou
needtouse:
usermodGoldgroup1,oldgroup2,ftptony
RE P LY LI NK
lefty.crupps October15,2014,5:39pm
Youresuggestingwedneedtoknoweachgroupfirst?Perhapstellingusthat
abovewouldbegood,alsoincludingthecommandtofindthecurrentoldgroup1
oldgroup1stuff:
groupslefty
Also,whatsthedifferencebetweenuseraddandadduser?
Whatsthedifferencesbetweendistros?
Thearticlecouldusesomereorganizationaswelltomaketheconceptflowbetter,
butthearticlehasgoodinfo,justnotlaidoutsuperclearly.IMHO.
RE P LY LI NK
vim July14,2007,2:41am
Actually,itseasiertogolikethis:
usermodaGftptony
Theacausesyouroldgroupstobekept.Atleastinthenewerversions.Iwaslooking
intothisandfoundanoldmanpagewheretheafunctionisnotdocumented.
SinceIdontknowwhenthisfeaturewasintroduced,youshouldcheckforitontheman
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 8/50
4/14/2016 Howto:LinuxAddUserToGroup
pagesbeforeusingit.
RE P LY LI NK
nixCraft July14,2007,10:15pm
vim,
aseemstoanewoption.ThisFAQhasbeenupdatedtoincludea.
Appreciateyourpost!
RE P LY LI NK
Themba March16,2015,8:06am
Theaoptionisnotworkingonubuntu14.04
RE P LY LI NK
Sterex January30,2016,1:14pm
Itworksjustfine.
RE P LY LI NK
derry August7,2007,10:25pm
Irecommendthatwhenyouneedtoaddpeopletoanexistinggrouptouse
gpasswdaUSERGROUP
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 9/50
4/14/2016 Howto:LinuxAddUserToGroup
SteveFrancia August19,2007,6:24pm
Using:
usermod(pwdutils)3.1.2
thereisnoaoptionavailable,sothatoptionsisafairlynewone,italsoappearstobe
nonstandardacross*NIX.
RE P LY LI NK
rupa August22,2007,9:06am
thanksforaoption,itsavedmytimeoncentos
RE P LY LI NK
emiat February1,2011,4:43am
tnxalot
RE P LY LI NK
ratna December16,2011,11:51am
RustillinsameDomain?
Regards
Ratna
RE P LY LI NK
suresh January7,2008,12:01pm
whythiscommanddidntworkonsunsolaris10?
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 10/50
4/14/2016 Howto:LinuxAddUserToGroup
#useraddu100gotherd/export/home/newuser1ms/bin/kshcRegularUser
Accountnewuser1
Error:uid100alreadyinuse
RE P LY LI NK
soliver January25,2008,9:20pm
Hello,
howcanIgiveausergrouprootrights?
Iwouldliketocreateagroupdeveloperbuttheyneedrootaccessaswell.
thanks,
Oliver
RE P LY LI NK
Ryan March13,2012,1:13am
Nooneneedstoassignrootaccesstotheirownaccount.Notevenyou.Addthem
tothewheelgroup.
RE P LY LI NK
soliver January25,2008,9:23pm
Ialsowanttogiveanotheruserrootaccess.
ThatwayyoucandoPermitRootLoginyes,whichismoresecure.
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 11/50
4/14/2016 Howto:LinuxAddUserToGroup
Nilesh January26,2008,3:09pm
installsudo.
thenedit/etc/sudoers(orotherlocation)
andappendtheline
%developerALL=(ALL)NOPASSWD:ALL
Thiswillgivetheusersingroupdevelopertherootaccessbutwillneedtotype
sudo
Theabovesetupwillnotdemandrootpassword
RE P LY LI NK
chris March11,2008,6:47pm
NowthatIfoolishlyran:
usermodGftpchris
IsthereanywayIgetaccessbacktoallthegroupsIhadbefore?
IamusingUbuntusoIdonthaveapasswordfortherootuser.
RE P LY LI NK
nixCraft March11,2008,7:31pm
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 12/50
4/14/2016 Howto:LinuxAddUserToGroup
Seeifyouhavebackupin/etc/grouporrestoreitfromyourtapebackup.
HTH
RE P LY LI NK
chris March11,2008,7:50pm
notapebackupandunlesstheetc/groupfileisautobackedupIdonthaveoneofthose
either.
RE P LY LI NK
nixCraft March12,2008,5:28am
Maybethiswillhelp
RE P LY LI NK
LiLo April30,2008,8:34am
Hi,
IsthereawaytoautomaticallycreateaMySQLdatabasewhencreatingtheuser?
(thenewdatabasewouldbenamedaftertheuserandwiththesamelogin/password)
RE P LY LI NK
nixCraft April30,2008,12:48pm
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 13/50
4/14/2016 Howto:LinuxAddUserToGroup
Youneedtowriteashellscriptthereisnobuiltinoptiontocreatemysqldb.
RE P LY LI NK
LiLo April30,2008,2:04pm
OK,soforinstance,withwebminwhichallowsthecreationofusersfromatextusing
useradd,itwouldnotbepossibletoautomaticallyaddadatabaseforeachcallof
useraddwithoutmodifyingwebmin
Thatsnotmakingmylifeanyeasier:)
RE P LY LI NK
toti May2,2008,4:19am
Hinewbhere)
Ihaveaquickquestion:inCentOS5,whenItypeusermodaGftptonyIalwaysget
theerrorinvalidnumericargumentftpwhyisthat?
RE P LY LI NK
toti May2,2008,4:20am
sorryjustreadthedisclaimeronleavereplydisregardmyquestion:|
RE P LY LI NK
RobM June6,2008,8:27pm
Ifyoumodifiedyourownuseraccountwhileloggedinwithit,thechangeswillnothave
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 14/50
4/14/2016 Howto:LinuxAddUserToGroup
aneffectuntilyounextlogin.
Ifyoudontwanttologout,youcanreplaceyourcurrentBASHshellwithanewoneto
achievethesamethingbyrunningthefollow:
supreserveenvironmentcommand$(which$SHELL)logini$(whoami)
Thiswillswitchusertoyourself,replacingyourcurrentshellwithanewinstanceof
itself.Youwillbepromptedforyourpassword.
Ifyoudontspecifyacommandtorunyoullprobablygetanerrortotheeffectofcannot
executebash:filenotfoundbecauseitwontbeontheenvironment.Youcoulduse
shelltopointsuatit,butyourshellwouldntbealoginshellandthereforewontread
your.bash_profileetc.
RE P LY LI NK
kishore June19,2008,9:58am
Hifriends,
Iwanttosaythanksforu.Becauseofthisposticreatedtheusersmyselfwithout
anyoneshelp.
ThanksandRegards
Kishore
RE P LY LI NK
helpneeded June26,2008,11:30am
whydoweneedtoaddnewusersinlinux?
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 15/50
4/14/2016 Howto:LinuxAddUserToGroup
RE P LY LI NK
nixCraft June26,2008,1:31pm
Linuxismultiuseroperatingsystem.Usercanmaintaintheirprivacyandsecurity.
RE P LY LI NK
HAMEED June27,2008,9:18am
WHATISTHECOMMANDTOCHECKTHEEXISTINGGROUPSINTHESYSTEM
ANDALSOCOMMANDTOCHECKTHEUSERS???
RE P LY LI NK
itsadok July5,2008,6:16am
Therearesimplercommands(atleastonUbuntu):
adduserusergroup
willaddanexistingusertoanexistinggroup
deluserusergroup
willremoveauserfromaspecifiedgroup
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 16/50
4/14/2016 Howto:LinuxAddUserToGroup
DavidBrown July6,2008,9:04pm
InthepastwhenIveupgradedtothelatesteditionofUbuntuIveaddedanyexisting
usersbyenteringtheusername,realname,passwordetc.intotheUsersandGroups
dialogueboxesandallworkedfine.
HoweverwithupgradingtoHardywhenIdothesameanerrorflagsupsayingHome
DirectoryAlreadyExistsPleaseenteradifferenthomedirectorypathandIvebeen
unabletoreinstatetheusers.
Cananyonetellmehowtoaddtheseusers
RE P LY LI NK
JuLianhenDra July8,2008,4:06am
HowdoIlistedallexistingusersandgroupbycommandlineinUbuntu,thanks
RE P LY LI NK
vishwas July8,2008,5:45am
howtoaddtwogroupsinagroup
foreg:group1andgroup2thesegroupshouldbeaddedtoanothergroupcalledgroup3
RE P LY LI NK
functionsys August21,2008,5:16am
whyyyyyyyyyhowicanfixit
FunctionSys@FunctionSysPC~/mysql
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 17/50
4/14/2016 Howto:LinuxAddUserToGroup
$groupadd
bash:groupadd:commandnotfound
FunctionSys@FunctionSysPC~/mysql
$/usr/sbin/groupadd
bash:/usr/sbin/groupadd:Nosuchfileordirectory
FunctionSys@FunctionSysPC~/mysql
$useraddG{mysql}mysql
bash:useradd:commandnotfound
FunctionSys@FunctionSysPC~/mysql
$
RE P LY LI NK
Suresh September22,2008,10:06am
HiVivek,
yourtutorialisreallynicetofollow.
Ihaveascenario,whereineedtocreateasuperuserandsubuser(1,2,3)foraccessing
ftpinourwebserveritislinuxwithredhatonit.sothatsuperusercanaccessallthe
subuserfolders,andsubuserscanaccessonlytheirfoldersrespectively.
Ihaventcreatedanyofthegroups,soiwouldliketoknowfromscratchlikedefining
usersandcreatingpermissions.
sinceIamnewtothislinuxenvironment,itwouldbegreatifyoucouldpostcommands
liketheoneaboveforthescenarioiexplained.
ManyThanks.
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 18/50
4/14/2016 Howto:LinuxAddUserToGroup
Suresh
RE P LY LI NK
eve October22,2008,1:38pm
ihave2group.GroupAandGroupB.
IhaveaexistinguserinGroupA.
NowiwanttoaddthisexistingusertoGroupBtoo.
Whatshouldido?
ThanksYou.
RE P LY LI NK
Aksuli October31,2008,9:43pm
Ivemanagedtoaddaccount.
richard@richarddesktop:~$sudouseraddG
admin,dialout,cdrom,floppy,audio,dip,video,plugdev,fuse,lpadmin
aksu
richard@richarddesktop:~$sudopasswdaksu
EnternewUNIXpassword:
RetypenewUNIXpassword:
passwd:passwordupdatedsuccessfully
richard@richarddesktop:~$idaksu
uid=1001(aksu)gid=1001(aksu)
groups=1001(aksu),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video
NowIhaveaproblem,whenIconnecttheserversays:
Couldnotchdirtohomedirectory/home/aksu:Nosuchfileordirectory
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 19/50
4/14/2016 Howto:LinuxAddUserToGroup
HowcanImanagethattoworkoutright.ATMIcantuseTABforfillinginfile/folder
namesetc..PLZhelpmeout:)
RE P LY LI NK
vishwas November3,2008,4:00am
Aksulitypethiscommanditwillhelpu
1)richard@richarddesktop:~$sudouseraddG
admin,dialout,cdrom,floppy,audio,dip,video,plugdev,fuse,lpadminaksud/home/aksu
2)mkdir/home/aksu
RE P LY LI NK
kenny November14,2008,7:01pm
itypeinuseraddcommandbutigettheresponsecommandnotfound.whatisthe
problem
RE P LY LI NK
PratikPatel November15,2008,5:10am
Pleasetellmehowcaniaddmultipleuserstoonegroupatasingleshot.
RE P LY LI NK
Ryan November20,2008,11:59pm
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 20/50
4/14/2016 Howto:LinuxAddUserToGroup
Toaddausertomultiplegroupsmanuseradd
G,groupsGROUP1[,GROUP2,[,GROUPN]]]
Alistofsupplementarygroupswhichtheuserisalsoamemberof.
Eachgroupisseparatedfromthenextbyacomma,withnointerveningwhitespace.
Thegroupsaresubjecttothesamerestrictionsasthegroupgivenwiththegoption.
Thedefaultisfortheusertobelongonlytotheinitialgroup.
RE P LY LI NK
junaid January21,2009,9:10am
thanksaalotbuddyforhelp.keepitup
Suggestions::
plzinsertsearchtoolwithinwebsite.
GODblessYOU
RE P LY LI NK
hyacinth February4,2009,3:01am
Howtodeleteandaddagroup..
pleasehelpme..
Thanks
RE P LY LI NK
dunno February13,2009,9:41pm
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 21/50
4/14/2016 Howto:LinuxAddUserToGroup
completenoobwithlinuxhere
whataretheactualgroupsthatyoucanaddusersto?
iknowtherestheusersgroupforstandardusersbutwhatelseisthere?caniadda
userasasysadminwithfullcontroloverthesystem?oristhatthesameasloggingin
asroot?
ialsounderstanditsapperentlyabadideatologinasrootintoKDEbutwhy?
sorry,likeisaid,completenoob.justinstalledyesterday.
oh,andalso,eventhoughirealizethisisnttherightplacetoaskthis,ihavenoidea
whereelsetoaskandivebeenserachingforthisforhourshowdoyoumountanew
harddrive?theresplentyofinfotellinghowtomountacdromorafloppydrive,oreven
ausbthumbdrive,butNOWHEREdoesanythingoranyonesayhowtomountasimple
harddrive.isitnotpossibletoaddanadditionalharddrive?icantbelievethatthat
wouldbeimpossible,sotheresgottobeaway.
RE P LY LI NK
wasim March9,2009,12:14pm
toadduserinmultiplegroup
usermodGgroup1,group2username
RE P LY LI NK
Patrick March29,2009,6:04pm
ihave3sites.MainSiteTestSiteandFileSite.MainandTestneedtobeapartofthe
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 22/50
4/14/2016 Howto:LinuxAddUserToGroup
FileSitegrouptobeabletoread/write/deletefiles.
usermodaGMainSite,TestSiteFileSite
isthatright?
RE P LY LI NK
AheebwaEdgar May19,2009,6:16pm
plizthanxsomuchforyourideasbutmyquestionwashowtoaddoneusertothelinux
group.amwaitingrightnow.
Godblessyou
RE P LY LI NK
AheebwaEdgar May19,2009,6:46pm
ineedjustacommandtoaddusertoagroup.thankyou
RE P LY LI NK
Snap June5,2009,2:44am
IfIhaveauserthatisonlyusedtorunscripts(startedbyfetchmail),butIdonotactually
everloginassuchuserintheconsole.Ihaveaddedthatusertoagrouptogetaccess
toafolder,butitdoesnotseemtowork..ifitwasanormaluser,Iwouldsimplylogout
andloginagaintoactivatemymembershipinthisgroup..butsinceIneverloginwith
thisuser,howcanImakesurethatitisactuallyamemberofthegroup?
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 23/50
4/14/2016 Howto:LinuxAddUserToGroup
baluphani July29,2009,6:18am
hi
iwanttocreateausersaytestusrandidontwanttogethomedirectoryforhimand
hisindividualgroup(generallyhewillbelongtohisgrouptestusrgroupidontwantit)
butihavealreadyhaveacommongroupsaycmngrpsoheshouldbelongtoitonly.
ithinkmypointisclear
createtestusrwithouthomedirectoryandwithouthisowngroupbutbelongsto
cmngrp.
RE P LY LI NK
baluphani July29,2009,7:29am
igotit
useraddNgM
RE P LY LI NK
wasim July29,2009,11:38am
youcancheckexistinggroupbythiscommand
cat/etc/group|cutd:f1
RE P LY LI NK
yogeshkolte October28,2009,8:29am
itwasveryhelpfultousermodcommandtomodifiedchangestheuser
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 24/50
4/14/2016 Howto:LinuxAddUserToGroup
RE P LY LI NK
VladtheImpaler November8,2009,9:26am
Tocheckgroupsandwhoisinthegroup,theeasiestiscat/etc/group.Smile!
RE P LY LI NK
karim November21,2009,9:18am
Hi,
Sayihaveagroupcalledmusic.
Iwanteverynewuserhenceforthcreatedtoautomaticallyhavethemusicgroupas
theirsecondarygroupontopoftheprimarygroupthatwillbeaddedbythesystem.
Isthispossible?
Thanks
RE P LY LI NK
AlB.. January15,2010,8:56pm
sonofmonkeysunclethereisnousermodaoptionisSUSEEnt10
RE P LY LI NK
esraa March24,2010,7:47pm
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 25/50
4/14/2016 Howto:LinuxAddUserToGroup
thanks
RE P LY LI NK
esraa March28,2010,7:31pm
iwanteclearedcodeinshellscriptprogrammingtoadduserandaddgroupe
thanks
RE P LY LI NK
zerc May5,2010,2:15pm
Hi,
Thankyouforthistutorial!
RE P LY LI NK
Arvind May19,2010,5:37am
Thankyouforthistutorial!
RE P LY LI NK
umerahmed June5,2010,5:39pm
goodtutorial
thanks
:)
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 26/50
4/14/2016 Howto:LinuxAddUserToGroup
RE P LY LI NK
Andey June5,2010,10:16pm
iveprobablyusedthispagelike50timesbecauseimstilltolazytolearnusermod
RE P LY LI NK
BrianMaskell June9,2010,7:11pm
Thispage(http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/)hasareference
tothegroupfile/etc/group,thetargetofthelinkbeing:
http://www.cyberciti.biz/faq/understandingetcpasswdfileformat/
Itshouldbe:
http://www.cyberciti.biz/faq/understandingetcgroupfile/
RE P LY LI NK
nixCraft June10,2010,6:05am
Thanksfortheheadsup!
RE P LY LI NK
uzer July4,2010,7:51pm
Hey,Imgetting
[user@localhost~]$sudosu
[sudo]passwordforuser:
userisnotinthesudoersfile.Thisincidentwillbereported.
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 27/50
4/14/2016 Howto:LinuxAddUserToGroup
shanewilliamson July7,2010,2:03am
OkaythesecommandsDONOTWORK!!!!!!!!!!!!!!
RE P LY LI NK
indir July9,2010,6:25am
thanks,itsworksforme:)
RE P LY LI NK
selven September15,2010,7:44pm
seriously,thisissogay!inmydaystoaddausertoagroup,wejusthadtoadditin
/etc/group!idontunderstandwhythereshouldbeatooltocomplicateit!
RE P LY LI NK
nic September16,2010,2:49pm
Iliketouseaforloopforthis.Forexampled
foriingroup1group2group3...;doadduser$i;done
RE P LY LI NK
TomO'Connell October7,2010,3:22pm
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 28/50
4/14/2016 Howto:LinuxAddUserToGroup
IamusingMint9andhavenoknowledgeofeithercommandlineorarchivemanager.
Canyousteermetotheeasiesttutorial.
Thanks,
RE P LY LI NK
dx November4,2010,10:06am
howmanyuserscanbeinagroup?iwanttoadd500userstogroupmailusers.wont
thatbeslowingdownmymailserver?
regards
RE P LY LI NK
syed December9,2010,7:53pm
ihaveneedinoneaccountandmultiplesign
RE P LY LI NK
NURULHUDA January9,2011,4:04pm
Ihavelostmyallinboxmailsunexpectedly.Isitpossibletoretriveagain?pleasehelp
me.
RE P LY LI NK
emiat February1,2011,4:52am
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 29/50
4/14/2016 Howto:LinuxAddUserToGroup
whatisthe1ststeponhowtoaddgroupinactivedirectory2003?And1ststepofhow
toaddgroupinactivedirectory?
emiat.
RE P LY LI NK
RodislavMoldovan April3,2011,10:01pm
#worksinDebian6
Addusertoanewgroup,bykeepingoldgroups
usermodaGAdditionalGroupUser
aappend
Ggroupname
RE P LY LI NK
Rashid May12,2011,10:50am
thanksforsharingusefulandknowledgeabletopic
RE P LY LI NK
Extra June27,2011,8:02am
Ohyeahman!Thisisthebestsiteievermeet,onhelpinguserstoquickfindthe
answertoconcreteQuestion!ThankyousomuchfortheFAQarchive!wishyouthe
bestthinks.
thisistheprimarysite,thatisearchforresponsestoLinuxQs.
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 30/50
4/14/2016 Howto:LinuxAddUserToGroup
LaxmanRana September20,2011,4:37am
thanksthistutorialtolearnaboutuseraddwithgroupsmodification
nicelythisizworkingonmypcinlinux
RE P LY LI NK
NethKong October8,2011,4:16pm
Hiall,IwouldliketowriteascriptinLinuxtomanageUserandGroup.
***theyareabletoadd,delete,modify,,,,,,
Wouldyoupleasehelpme?
RE P LY LI NK
da_fatfinger October20,2011,10:48pm
Imadethemistakeofnotincludingainusermodaswell,nowimlockedofdoing
anythingusefulinubuntu.Grantedimalinuxnewbie,sohardlessonslikethisare
boundtohappen,butyouwouldsavemanyheadacheswithjustasmall,clear
explanationatthetopabouthowflags(especiallya)arevitaltohowusermodworks.
SinceyouareTHEtopgooglehitforlinuxaddusertogroup,youwouldsavealotof
peoplesomeseriouspain.
RE P LY LI NK
Vivek November9,2011,2:04pm
Anyideahowtoaddexistinggroupintoanotherexistinggroup?
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 31/50
4/14/2016 Howto:LinuxAddUserToGroup
Ex:test1grouphas5users
test2grouphas3users
iwanttoaddtest1grouptobepartoftest2,insteadofaddingtheusers.
RE P LY LI NK
vladtheimpaler December8,2011,12:43pm
Canyoupleaseemboss,movetotop,highlight,makeitredandblinkFFS!!!
99%ofthepeoplewantanuseraddedtoanexistinggroup,notmoved.
OnlyonLinux,addisaspecialtypeofmove(sarcasm).
Please,forthistutorialofyours,thatcomesupongoogle,thisiswhatwewant:
usermodaGftptony
notthis:
usermodGftptony
MaybewithtimewewilllearnLinuxandfacethisissuesmorebravely,butmostofus
thatcomeherehaverathertrivialexperiencewithLinux,wewanttolearn..butwewant
tolearnhowtoaddanusertoagroup(ofcourseexisting,isthenaturalway)nohowto
damageoursystems.
Callmestupid,butitisthe2ndtimeIrevisitthisissue,beingforcedtoagainreinstallmy
linuxboxbecauseofdamagingmysudoerslist.
Please,putabigredorwhateverflashywarningontopofthearticle,notifyingpeople
aboutthesudeoersbite.
RE P LY LI NK
miquel January12,2012,8:11am
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 32/50
4/14/2016 Howto:LinuxAddUserToGroup
Niceexplanation
RE P LY LI NK
dipteshmaity February22,2012,3:02pm
howtocreateuserunderuserinlinux??notfromsuperuser.
RE P LY LI NK
SubratN January10,2013,6:03pm
Youshouldknowtherootpassword.
$sucuseraddu_name
orthroughsudo
RE P LY LI NK
marc March26,2012,8:22am
IknewthatuseraddcouldaddausertothesystembutIdidnotknowthatitwouldfora
groupaswell.Thanksforthishowtothen.
RE P LY LI NK
removethis April10,2012,3:28pm
Thispostiswronganditsthetopsearchresultongoogle.Youshouldeditorremoveit.
ThecorrectwaytoaddausertoagroupisusermodaGgroupnameusername.
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 33/50
4/14/2016 Howto:LinuxAddUserToGroup
RE P LY LI NK
nitiratnanikalje April25,2012,1:19pm
itsmindblowingsolutionforaddingusertoanygroup.wecanaddmultipleexisting
userstoanexistinggroupbythismethod#gpasswdMniti,gauri,lina,nidhimasti
=addeduserniti,gauri,linaandnidhitogroupmasti
RE P LY LI NK
Jeremy June11,2012,5:03pm
Thanks,thisishelpfulforpeoplelikemyselfjuststartingoutwithRHEL.
RE P LY LI NK
dhani September18,2012,8:21am
Thankyou,thisreallysolvemyproblemsinsambashare.
RE P LY LI NK
BijayManandhar September20,2012,6:24am
reallynicetutorial..
thanxmillions..
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 34/50
4/14/2016 Howto:LinuxAddUserToGroup
Valerio October15,2012,6:41pm
HiItryedyourhint,butIhavegotsomeerrosbelow:
root@ibeji:/etc#testparm
Loadsmbconfigfilesfrom/etc/samba/smb.conf
Unknownparameterencountered:clientcodepage
Ignoringunknownparameterclientcodepage
Unknownparameterencountered:characterset
Ignoringunknownparametercharacterset
Unknownparameterencountered:domainadmingroup
Ignoringunknownparameterdomainadmingroup
Unknownparameterencountered:domainadminusers
Ignoringunknownparameterdomainadminusers
Processingsection[netlogon]
Processingsection[home]
Processingsection[publico]
Processingsection[contabil]
Processingsection[suporte]
Processingsection[tmp]
LoadedservicesfileOK.
Serverrole:ROLE_DOMAIN_PDC
Pressentertoseeadumpofyourservicedefinitions
RE P LY LI NK
Sequoia December18,2012,5:05pm
Youshouldreallychangethisarticletoeither
a)usetheaswitchinthefirstexampleor
b)addaBIGREDWARNINGthatthecommandyougivewillREMOVETHEUSER
FROMALLCURRENTGROUPS
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 35/50
4/14/2016 Howto:LinuxAddUserToGroup
Thiscomesup#1ongoogleforlinuxaddusertogroupandIsuspectImnottheonly
onewhocompletelyscreweduptheiruserbyrunningthecommandyouhavelisted
heretoaddausertoagroup
PerhapsthearticleshouldbetitledHowtoremoveauserfromallgroupsandadd
themtoanewgroup
RE P LY LI NK
SubratN January10,2013,5:52pm
HiGeeks,
HowcanIaddmultipleusersintoagroupatatimewithoutremovingtheoldusers
belongstothatparticulargroup.
Ihavetriedthefollowingcommand
#gpasswdMuser1,user2,user3group_name
But,thethingisthat,afteraddingtheseusers,theprevioususersbelongstothisgroup
beingremoved.
Iwanttheprevioususerstobeexist.
Please,help..
Thanksinadvance..
RE P LY LI NK
LuisMompoHanden January22,2013,1:35pm
Ibuiltabashscripttoaddmultipleusersfromacsvfiletoanexistinggroupwithout
creatingahomedir.Thepasswordsincsvfilearecleartext.
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 36/50
4/14/2016 Howto:LinuxAddUserToGroup
#!/bin/bash
FILE=/root/test.csv
cat$FILE|whilereadline;do
USER=$(echo$line|awkF\;'{print$1}')
PASS_TMP=$(echo$line|awkF\;'{print$2}'|sed's/\//g')
useraddMGcvs_usr$USER
echo$USER:$PASS_TMP|chpasswd
done
RE P LY LI NK
Landis January27,2013,7:30pm
InSuSElinux,thereisNoa(thisarticlestatesthatthearetainsexistinggroupsand
addsnewgroupG),butinopenSuSE12.2atleast,thereisnoaoptiontousermod,
itkeepsexistinggroups,bydefaultiguess
#usermodGGroupNameUserName
eg,
#idlunar
uid=1002(lunar)gid=100(users)groups=100(users)
#usermodGsshdlunar
#idlunar
uid=1002(lunar)gid=100(users)groups=100(users),102(sshd)
Landis.
RE P LY LI NK
VaibhavGupta January31,2013,3:09pm
Hi,
Ihavebuiltax86rootfsusingbuildrootwithbothifuse,imobiledevice,usbmuxd.idid
chroot(directory:/var/prj_ca/)tothegeneratedfilesystemandmountedthefollowing
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 37/50
4/14/2016 Howto:LinuxAddUserToGroup
mountbind/dev/var/prj_ca/dev
mountbind/dev/pts/var/prj_ca/dev/pts
mountbind/dev/fuse/var/prj_ca/dev/fuse
mountbind/proc/var/prj_ca/proc
mountbind/sys/var/prj_ca/sys
mountbind/media/var/prj_ca/media
whenirun.
lsusbv|grepiiSerialiamgettingtheIPODserialidbut.
ifuseisfailingwithfollowingerror.
ifuse/tmp/apple_inc._ipod_b067d003ed1b22a9fffa47e3654a00e6386a6c9a/
usbmuxd_get_device_list:erroropeningsocket!
Nodevicefound,isitconnected?
Ifitismakesurethatyouruserhaspermissionstoaccesstherawusbdevice.
Ifyourestillhavingissuestryunpluggingthedeviceandreconnectingit.
Iamstuckcanupleasehelp.
RE P LY LI NK
MuhammadUsmanMajeed April22,2013,7:46am
#usermodaGftptony
whatdidtheaswitchdo?
Regards
RE P LY LI NK
prashanth July12,2013,12:35pm
isthereanywaytoaddmultipleuserstoaexistinggroupwithdisturbingordeleting
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 38/50
4/14/2016 Howto:LinuxAddUserToGroup
existingusersinthatgroup
RE P LY LI NK
GeorgeHuebschman July16,2013,5:49pm
Thanks,
Averyclearthoroughanswertothequestion!
Whenyouhaveachoice,spendyourmoneywhereyoudprefertoworkifyouhadNO
choice.
RE P LY LI NK
bb November7,2013,1:52pm
addusernotuseradd
RE P LY LI NK
Jose December31,2013,10:24pm
Excellentbro!,ImusingfedoraandthisisveryusefullforHTTPDdirectories!
RE P LY LI NK
GolandajS February5,2014,6:45am
adduseraccount
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 39/50
4/14/2016 Howto:LinuxAddUserToGroup
GolandajSaddam February5,2014,6:47am
groupadd
RE P LY LI NK
NaveenSharma April25,2014,12:45pm
Igotthisquestionlatelyinaninterview.
OneUserIDcanbelongtomaximumhowmanysecondarygroups.?
Isthereadefiniteno?
RE P LY LI NK
JET April25,2014,11:45pm
Theformatofthisposttookoutanimportantpartofthecommands.PLEASE
DISREGARDABOVE.Hereisanammendedpost:
Asimplemanusermodwillprovidetheoptionsavailable.TheAoptiondoesnot
removeanygroups,itonlyadds.Foraddingausertoagroup,MYpreferredmethodis:
usermodusernameAgroup
Ifyouwishtoaddusertoalistofgroups,youmayuseacommaasdelimiter,asin:
usermodusernameAgroup1,group2,group3
TheGoptionisnotpreferredinmyopinion,itisusedtospecifyallgroupstowhichthe
userwillbelongto,andhastheabilitytoREMOVEauserfromunspecifiedgroups.As
manyhavepointedout,theabilitytoremoveauserfromgroupscanhavenastyresults
ifnotcarefullyused.
So,justusetheAoptiontoaddyourexistinguserstoexistinggroups,andyoushould
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 40/50
4/14/2016 Howto:LinuxAddUserToGroup
beallset.Goodluck!
RE P LY LI NK
Extra December18,2014,10:51am
GoodpointJet!ThankYou!
RE P LY LI NK
raja May19,2014,2:45am
iamcreatethecreatetotheroupbdbaanuseraddbuthewasnotaddtotheusermod
command.
usermodu1000gdbad|d01|oracle
RE P LY LI NK
lliseil January1,2015,5:26pm
#Postsoriginalcommand(doesnotwork):
useraddGGROUPUSER
useradd:user'USER'alreadyexists
#Workingcommand:
gpasswdaUSERGROUP
AddinguserUSERtogroupGROUP
#Help:
gpasswdh
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 41/50
4/14/2016 Howto:LinuxAddUserToGroup
Usage:gpasswd[option]GROUP
Options:
a,addUSERaddUSERtoGROUP
d,deleteUSERremoveUSERfromGROUP[/code]
Archlinuxhere.
RE P LY LI NK
pandiyan January3,2015,12:10pm
thanksfriends..
RE P LY LI NK
CraigRMorton January13,2015,3:33pm
Excellent,thankyou.
RE P LY LI NK
HarryHinsonlikeserica February23,2015,12:00pm
completenoobwithlinuxhere
whataretheactualgroupsthatyoucanaddusersto?
iknowtherestheusersgroupforstandardusersbutwhatelseisthere?caniadda
userasasysadminwithfullcontroloverthesystem?oristhatthesameasloggingin
asroot?
ialsounderstanditsapperentlyabadideatologinasrootintoKDEbutwhy?
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 42/50
4/14/2016 Howto:LinuxAddUserToGroup
sorry,likeisaid,completenoob.justinstalledyesterday.
oh,andalso,eventhoughirealizethisisnttherightplacetoaskthis,ihavenoidea
whereelsetoaskandivebeenserachingforthisforhourshowdoyoumountanew
harddrive?theresplentyofinfotellinghowtomountacdromorafloppydrive,oreven
ausbthumbdrive,butNOWHEREdoesanythingoranyonesayhowtomountasimple
harddrive.isitnotpossibletoaddanadditionalharddrive?icantbelievethatthat
wouldbeimpossible,sotheresgottobeaway.
RE P LY LI NK
harryhindson February24,2015,2:25pm
IpromiseIdofancyhernojoke
RE P LY LI NK
pradeep July16,2015,3:34am
Goodcommandexplanations
RE P LY LI NK
Nina July16,2015,1:18pm
Hi,Iwanttoknowhowtocreateagroupinredhadbuttobesurethatthisgroupis
createdinthelocalmachineandnotinthegridwhereIamconnectedat.Isawman
andfoundoptiongroupaddrthatseesmtoaddtheusertothesystemaccount.How
couldIbesurethatthenewgroupiscreatedinthelocalsystem?Thanks
RE P LY LI NK
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 43/50
4/14/2016 Howto:LinuxAddUserToGroup
Reddy August19,2015,3:55pm
Thisjustsavedmyday.Thankyou.
RE P LY LI NK
angiekarix September29,2015,5:11am
Hi
IwantedtoknowhowIcanaddmultipleusersatonceandnotnecessarilyinone
group.
RE P LY LI NK
ROhit February18,2016,5:56pm
hiAll
HowtocreateGroupinCentos6.7
GroupnameProjectManager
whatistheclicommands
Pleaseshareasap.
RE P LY LI NK
VasanthMuthu February25,2016,9:40pm
Fantastic!!!Yourblogisfullofinformation.Ifinallyaddedausertoagroupinlinux..
Thanks,
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 44/50
4/14/2016 Howto:LinuxAddUserToGroup
RE P LY LI NK
Peter March29,2016,8:06pm
Greatthankyou,tiredoflookingongoogleeverytimelolhittingbacktoschoolthis
summer!
RE P LY LI NK
LeaveaComment
Name
Comment
Submit
Taggedwith:usermodcommand,Intermediate
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 45/50
4/14/2016 Howto:LinuxAddUserToGroup
NextFAQ:HowToCompilingCProgramAndCreatingExecutableFileUnderaLinux/
UNIX/*BSD
PreviousFAQ:LinuxStartOracleAsaService
AdvertiseHere
Tosearch,typeandhitenter
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 46/50
4/14/2016 Howto:LinuxAddUserToGroup
AdvertiseHere
30CoolOpenSourceSoftwareIDiscoveredin2013
30HandyBashShellAliasesForLinux/Unix/MacOSX
Top30NmapCommandExamplesForSys/NetworkAdmins
25PHPSecurityBestPracticesForSysAdmins
20LinuxSystemMonitoringToolsEverySysAdminShouldKnow
20LinuxServerHardeningSecurityTips
Linux:20IptablesExamplesForNewSysAdmins
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 47/50
4/14/2016 Howto:LinuxAddUserToGroup
Top20OpenSSHServerBestSecurityPractices
Top20NginxWebServerBestSecurityPractices
20Examples:MakeSureUnix/LinuxConfigurationFilesAreFreeFromSyntaxErrors
15GreatestOpenSourceTerminalApplicationsOf2012
My10UNIXCommandLineMistakes
Top10OpenSourceWebBasedProjectManagementSoftware
Top5EmailClientForLinux,MacOSX,andWindowsUsers
TheNoviceGuideToBuyingALinuxLaptop
dstat: Monitoring
Linux Systems
Performance B...
UNIX / Linux
Command To Check
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 48/50
4/14/2016 Howto:LinuxAddUserToGroup
Command To Check
Existing Groups a...
How to Change a
USER and GROUP ID
on Linux For ...
multitail: View
Multiple Files Like
GetnixCraftinyourinbox.It'sfree:
Youremailaddress
Subscribe
F O LLO W U S
nixCraft
Follow +1
+ 246,467
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 49/50
4/14/2016 Howto:LinuxAddUserToGroup
nixCraft
LikePage 108Klikes
Bethefirstofyourfriendstolikethis
Follow@nixcraft 56.7Kfollowers
20002016nixCraft.Allrightsreserved.PrivacyTermsofServiceQuestionsorComments
http://www.cyberciti.biz/faq/howtolinuxaddusertogroup/ 50/50