How to add Group


group di dalam linux  adalah suatu kelompok pengguna user dalam lingkungan linux,  group ini bisa berguna saat suatu kelompok yang didefinisaikan untuk menggunakan suatu file atau direktori yang terotorisasi, atau penggunaan penggunaan komponen lainnya, misalkan printer, internet dsb. 

Nama Perintah :

groupadd  :  artinya perintah ini membuat sebuah grup baru


Synopsis pemakainannya :

groupadd [-g gid [-o]] [-r] [-f] [-K KEY=VALUE] group




Perintah groupadd membuat sebuahaccount  grup baru menggunakan nilai yan gdi spesifikan dalam baris perintah dan nilai default dari sistem. Sebuah grup baru akan dimasukan kedalam sistem file yang diperlukan.

Optional / Pilihan Option-option yang di perbolehkan dalam perintah group adalah:


Option ini menyebabkan untuk keluar dengan status sukses jika group khusus sudah ada.. Dengan -g, jika GID khusus sudah ada, lain (unik) GID telah di pilih (contoh: -g di matikan)(tapi dengan perintah ini saya belum mengerti kalau ada yang tw mohon di komentari atau di sharing apa arti dari -f ini)


Flag ini memerintahkan groupadd untuk menambahkan sebuah account sistem. Nilai GID tersedia Yang pertama lebih rendah dari 499 akan secara otomatis terpilih kecuali jika – g pilihan adalah juga berdampingan. Ini adalah suatu pilihan yang ditambahkan oleh Red Hat.


GID Nilai Numerik pada ID grup. Nilai ini harus unik, kecuali jika pilihan – o digunakan. Nilai harus bukan bilangan negatif. Default yang digunakan untuk nilai ID terkecil lebih besar dari 500 dan lebih besar dari goup lainnya. Nilai antara 0-999 adalah nilai yan disediakan untuk system account.

-h, –help Display help message and exit. -K KEY=VALUE Mengesampingkan default dari / etc/login.defs ( GID_MIN, GID_MAX dan yang lain). pilihan Multiple – K dapat diterapkan. Example: -K GID_MIN=100 -K GID_MAX=499 Note: -K GID_MIN=10,GID_MAX=499 doesn’t work yet.


pilihan ini mengijinkan untuk menambah grup dengan non unik GID

File group ini disimpan di : /etc/group

Group account informasinya terletak di file : /etc/gshadow

Secure group account informasinya : /etc/login.defs

Aturan Penamaan Group

  • Nama grup harus dimulai dengan huruf kecil atau sebuah garis bawah, dan hanya pilihan huruf kecil, garis bawah, dash dan dolar seperti berikut. Dalam nilai ekpres reguler : [a-z_][a-z0-9_-]*[$] 
  • Panjang Nama grup boleh sampai dengan 16 karakter 
  • Jika nama grup sudah ada dalam ekternal database seperti NIS, perintah akan menolak pembuatan grup


Cuplikan : 


useradd example – Add a new user to secondary group

Use useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. Syntax:
useradd -G {group-nameusername
Create a new user called vivek and add it to group called developers. First login as a root user (make sure group developers exists), enter:
# grep developers /etc/group


If you do not see any output then you need to add group developers using groupadd command:
# groupadd developers
Next, add a user called vivek to group developers:
# useradd -G developers vivek
Setup password for user vivek:
# passwd vivek
Ensure that user added properly to group developers:
# id vivekOutput:

uid=1122(vivek) gid=1125(vivek) groups=1125(vivek),1124(developers)

Please note that capital G (-G) option add user to a list of supplementary groups. Each group is separated from the next by a comma, with no intervening whitespace. For example, add user jerry to groups admins, ftp, www, and developers, enter:
# useradd -G admins,ftp,www,developers jerry

useradd example – Add a new user to primary group

To add a user tony to group developers use following command:
# useradd -g developers tony
# id tony

uid=1123(tony) gid=1124(developers) groups=1124(developers)
Please note that small -g option add user to initial login group (primary group). The group name must exist. A group number must refer to an already existing group.

usermod example – Add a existing user to existing group

Add existing user tony to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
# usermod -a -G ftp tonyChange existing user tony primary group to www:
# usermod -g www tony

Want to read Linux tips and tricks, but don’t have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don’t miss a single tip/tricks. Subscribe to our weekly newsletter here

{ 46 comments… read them below or add one }

1praj 03.26.06 at 4:05 pm

How can i run the passwd command
non-interactively in linux . I want to change the password through a script file….How can i
invoke the passwd command thru a script file non-interactively.
If thats not possible then suggest
some alternative…

2nixcraft 03.26.06 at 8:02 pm

See shell script example here

3BackSeat 08.14.06 at 3:41 pm

praj: see chpasswd(8)

4BnK 12.06.06 at 8:51 pm


time saving tip for new admin. I can read man page but it is full of shit-load and no examples at all. keep it up good work!

5Søren 06.19.07 at 10:37 am

I find the easiest way to add a user to a group is using gpasswd like this:
gpasswd -a

6Søren 06.19.07 at 10:38 am

This editor bugs me :) The command should be:
gpasswd -a user group

7Frogbert 07.11.07 at 6:52 am

This is wrong, usermod -G ftp tony will take you out of all your existing groups. Not add a new one.

8vivek 07.12.07 at 6:13 pm

Yes I’m adding a existing user to existing group, but to keep user in other old group you need to use:

usermod -G oldgroup1, oldgroup2, ftp tony
9vim 07.14.07 at 2:41 am

Actually, it’s easier to go like this:

usermod -a -G ftp tony

The -a causes your old groups to be kept. At least in the newer versions. I was looking into this and found an old manpage where the -a function is not documented.

Since I don’t know when this feature was introduced, you should check for it on the man pages before using it.

10vivek 07.14.07 at 10:15 pm


-a seems to a new option. This FAQ has been updated to include -a.

Appreciate your post!

11derry 08.07.07 at 10:25 pm

I recommend that when you need to add people to an existing group to use

gpasswd -a USER GROUP

12Steve Francia 08.19.07 at 6:24 pm

usermod (pwdutils) 3.1.2

there is no -a option available, so that options is a fairly new one, it also appears to be nonstandard across *NIX.

13rupa 08.22.07 at 9:06 am

thanks for -a option, it saved my time on centos

14suresh 01.07.08 at 12:01 pm

why this command didnt work on sun solaris 10 ?
#useradd -u 100 -g other -d /export/home/newuser1 -m -s /bin/ksh -c “Regular User Account ” newuser1

Error :uid 100 already in use

15soliver 01.25.08 at 9:20 pm


how can I give a usergroup root rights?
I would like to create a group “developer” but they need root access as well.


16soliver 01.25.08 at 9:23 pm

I also want to give another user root access.
That way you can do PermitRootLogin yes, which is more secure.

17Nilesh 01.26.08 at 3:09 pm

install sudo.

then edit /etc/sudoers (or other location)

and append the line-

%developer ALL=(ALL) NOPASSWD: ALL

This will give the users in group developer the root access but will need to type


The above setup will not demand root password

18chris 03.11.08 at 6:47 pm

Now that I foolishly ran:
usermod -G ftp chris

Is there anyway I get access back to all the groups I had before?

I am using Ubuntu so I don’t have a password for the root user.

19vivek 03.11.08 at 7:31 pm

See if you have backup in /etc/group- or restore it from your tape backup.


20chris 03.11.08 at 7:50 pm

no tape backup and unless the etc/group file is auto backedup I don’t have one of those either.

21vivek 03.12.08 at 5:28 am
22LiLo 04.30.08 at 8:34 am


Is there a way to automatically create a MySQL database when creating the user?

(the new database would be named after the user and with the same login / password)

23vivek 04.30.08 at 12:48 pm

You need to write a shell script; there is no built in option to create mysql db.

24LiLo 04.30.08 at 2:04 pm

OK, so for instance, with webmin which allows the creation of users from a text using useradd, it would not be possible to automatically add a database for each call of useradd without modifying webmin…

That’s not making my life any easier :)

25toti 05.02.08 at 4:19 am

Hi… newb here ;)
I have a quick question: in CentOS 5, when I type usermod -a -G ftp tony I always get the error “invalid numeric argument ‘ftp’ why is that?

26toti 05.02.08 at 4:20 am

sorry just read the disclaimer on “leave reply” disregard my question :|

27RobM 06.06.08 at 8:27 pm

If you modified your own user account while logged in with it, the changes will not have an effect until you next login.

If you don’t want to logout, you can replace your current BASH shell with a new one to achieve the same thing by running the follow:

su –preserve-environment –command “$(which $SHELL) –login -i” $(whoami)

This will switch-user to yourself, replacing your current shell with a new instance of itself. You will be prompted for your password.

If you don’t specify a command to run you’ll probably get an error to the effect of “cannot execute bash: file not found” because it won’t be on the environment. You could use –shell to point su at it, but your shell wouldn’t be a “login” shell and therefore won’t read your .bash_profile etc.

28kishore 06.19.08 at 9:58 am

Hi friends,

I want to say thanks for u.Because of this post i created the users myself without anyones help.

Thanks and Regards

29helpneeded 06.26.08 at 11:30 am

why do we need to add new users in linux?

30vivek 06.26.08 at 1:31 pm

Linux is multiuser operating system. User can maintain their privacy and security.

31HAMEED 06.27.08 at 9:18 am


32itsadok 07.05.08 at 6:16 am

There are simpler commands (at least on Ubuntu):

adduser user group
will add an existing user to an existing group

deluser user group
will remove a user from a specified group

33David Brown 07.06.08 at 9:04 pm

In the past when I’ve upgraded to the latest edition of Ubuntu I’ve added any existing users by entering the user name, real name, password etc. into the Users and Groups dialogue boxes and all worked fine.

However with upgrading to Hardy when I do the same an error flags up saying “Home Directory Already Exists – Please enter a different home directory path” and I’ve been unable to re-instate the users.

Can anyone tell me how to add these users

34JuLian henDra 07.08.08 at 4:06 am

How do I listed all existing users and group by command line in Ubuntu, thanks

35vishwas 07.08.08 at 5:45 am

how to add two groups in a group
for eg: group1 and group2 these group should be added to another group called group3

36functionsys 08.21.08 at 5:16 am

whyyyyyyyyy how i can fix it

FunctionSys@FunctionSys-PC ~/mysql
$ groupadd
bash: groupadd: command not found

FunctionSys@FunctionSys-PC ~/mysql
$ /usr/sbin/groupadd
bash: /usr/sbin/groupadd: No such file or directory

FunctionSys@FunctionSys-PC ~/mysql
$ useradd -G {mysql} mysql
bash: useradd: command not found

FunctionSys@FunctionSys-PC ~/mysql

37Suresh 09.22.08 at 10:06 am

Hi Vivek,

your tutorial is really nice to follow.

I have a scenario, where i need to create a super user and subuser(1,2,3) for accessing ftp in our webserver it is linux with redhat on it. so that super user can access all the subuser folders, and subusers can access only their folders respectively.

I haven’t created any of the groups, so i would like to know from scratch like defining users and creating permissions.

since I am new to this linux environment, it would be great if you could post commands like the one above for the scenario i explained.

Many Thanks.

38eve 10.22.08 at 1:38 pm

i have 2 group. Group A and Group B.
I have a existing user in Group A.
Now i want to add this existing user to Group B too.
What should i do?

Thanks You.

39Aksuli 10.31.08 at 9:43 pm

Ive managed to add account.

richard@richard-desktop:~$ sudo useradd -G admin,dialout,cdrom,floppy,audio,dip,video,plugdev,fuse,lpadmin aksu
richard@richard-desktop:~$ sudo passwd aksu
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
richard@richard-desktop:~$ id aksu
uid=1001(aksu) gid=1001(aksu) groups=1001(aksu),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),109(lpadmin),115(admin)

Now I have a problem, when I connect the server says:

Could not chdir to home directory /home/aksu: No such file or directory

How can I manage that to work out right. ATM I can’t use TAB for filling in file/folder names etc.. PLZ help me out :)

40vishwas 11.03.08 at 4:00 am

Aksuli type this command it will help u

1) richard@richard-desktop:~$ sudo useradd -G admin,dialout,cdrom,floppy,audio,dip,video,plugdev,fuse,lpadmin aksu -d /home/aksu

2) mkdir /home/aksu

41kenny 11.14.08 at 7:01 pm

i type in useradd command but i get the response command not found.what is the problem

42Pratik Patel 11.15.08 at 5:10 am

Please tell me how can i add multiple users to one group at a single shot.

43Ryan 11.20.08 at 11:59 pm

To add a user to multiple groups – ‘man useradd’

-G, –groups GROUP1[,GROUP2,…[,GROUPN]]]
A list of supplementary groups which the user is also a member of.
Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option.
The default is for the user to belong only to the initial group.

44junaid 01.21.09 at 9:10 am

thanks a alot buddy for help……. keep it up

plz insert search tool with in website…….

GOD bless YOU

45hyacinth 02.04.09 at 3:01 am

How to delete and add a group..
please help me..


46dunno 02.13.09 at 9:41 pm

complete noob with linux here…

what are the actual groups that you can add users to?

i know there’s the ‘users’ group for standard users… but what else is there? can i add a user as a sysadmin with full control over the system? or is that the same as logging in as root?

i also understand it’s apperently a “bad idea” to login as root into KDE… but why?

sorry, like i said, complete noob. just installed yesterday.

oh, and also, even though i realize this isn’t the right place to ask this, i have no idea where else to ask and i’ve been seraching for this for hours… how do you mount a new hard drive? there’s plenty of info telling how to mount a cdrom or a floppy drive, or even a usb thumb drive, but NOWHERE does anything or anyone say how to mount a simple hard drive…. is it not possible to add an additional hard drive? i can’t believe that that would be impossible, so there’s got to be a way.


~ oleh desktopku pada Februari 24, 2009.

Satu Tanggapan to “How to add Group”

  1. I see you share interesting things here, you can earn some
    additional cash, your website has big potential,
    for the monetizing method, just type in google – K2 advices how to monetize a website

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )


Connecting to %s

%d blogger menyukai ini: