What is the difference between -g and -G options in useradd
Clash Royale CLAN TAG#URR8PPP
After I look through the help. I didn't found much difference between them.
-g, --gid GROUP
The group name or number of the user's initial login group. The group
name must exist. A group number must refer to an already existing
group.
-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.
If they are the same. Why both they exist?
linux permissions useradd
add a comment |
After I look through the help. I didn't found much difference between them.
-g, --gid GROUP
The group name or number of the user's initial login group. The group
name must exist. A group number must refer to an already existing
group.
-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.
If they are the same. Why both they exist?
linux permissions useradd
1
See also: GID, current, primary, supplementary, effective and real group IDs?
– Satō Katsura
Jun 29 '16 at 16:49
add a comment |
After I look through the help. I didn't found much difference between them.
-g, --gid GROUP
The group name or number of the user's initial login group. The group
name must exist. A group number must refer to an already existing
group.
-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.
If they are the same. Why both they exist?
linux permissions useradd
After I look through the help. I didn't found much difference between them.
-g, --gid GROUP
The group name or number of the user's initial login group. The group
name must exist. A group number must refer to an already existing
group.
-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.
If they are the same. Why both they exist?
linux permissions useradd
linux permissions useradd
edited Dec 20 '18 at 7:21
Rui F Ribeiro
39k1479130
39k1479130
asked Jun 29 '16 at 11:18
Joe.wang
2081614
2081614
1
See also: GID, current, primary, supplementary, effective and real group IDs?
– Satō Katsura
Jun 29 '16 at 16:49
add a comment |
1
See also: GID, current, primary, supplementary, effective and real group IDs?
– Satō Katsura
Jun 29 '16 at 16:49
1
1
See also: GID, current, primary, supplementary, effective and real group IDs?
– Satō Katsura
Jun 29 '16 at 16:49
See also: GID, current, primary, supplementary, effective and real group IDs?
– Satō Katsura
Jun 29 '16 at 16:49
add a comment |
3 Answers
3
active
oldest
votes
-g
sets the initial, or primary, group. This is what appears in the group field in /etc/passwd
. On many distributions the primary group name is the same as the user name.
-G
sets the supplementary, or additional, groups. These are the groups in /etc/group
that list your user account. This might include groups such as sudo
, staff
, etc.
Thank you kind and quick help . @roaima Did you mean the primary group (-g
) and secondary group(-G
)? Thanks.
– Joe.wang
Jun 29 '16 at 11:33
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with theid
command, I think.
– roaima
Jun 29 '16 at 11:44
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
add a comment |
They are not the same. The -g
option specifies the "primary" group that a user should belong to, while the -G
option specifies one or many supplementary ("secondary") groups.
On a work machine I have access to I have
$ id
uid=1001(me) gid=1001(me) groups=1001(me),27(sudo),110(lxd),1005(theproject)
This shows that my "primary" group is me
(same as my username). However, I'm also member of a number of secondary groups.
Membership of the sudo
group, for example, allows me to use the sudo
command to do scary stuff with the system, due to the way this is configured for sudo
in /etc/sudoers
on this particular machine.
Membership of the theproject
group allows me to modify group-readable/writable files in a project I'm working on with others.
File created will (ordinarily) automatically be assigned to the primary group.
add a comment |
The group applied via -g
is the primary group, so for example when you create a file it will default to making it with your primary group as the group associated with that file. You can however temporarily change which group it uses as default with the sg
or newgrp
commands. All groups in the -G
are secondary groups. More about this here
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f292830%2fwhat-is-the-difference-between-g-and-g-options-in-useradd%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
-g
sets the initial, or primary, group. This is what appears in the group field in /etc/passwd
. On many distributions the primary group name is the same as the user name.
-G
sets the supplementary, or additional, groups. These are the groups in /etc/group
that list your user account. This might include groups such as sudo
, staff
, etc.
Thank you kind and quick help . @roaima Did you mean the primary group (-g
) and secondary group(-G
)? Thanks.
– Joe.wang
Jun 29 '16 at 11:33
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with theid
command, I think.
– roaima
Jun 29 '16 at 11:44
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
add a comment |
-g
sets the initial, or primary, group. This is what appears in the group field in /etc/passwd
. On many distributions the primary group name is the same as the user name.
-G
sets the supplementary, or additional, groups. These are the groups in /etc/group
that list your user account. This might include groups such as sudo
, staff
, etc.
Thank you kind and quick help . @roaima Did you mean the primary group (-g
) and secondary group(-G
)? Thanks.
– Joe.wang
Jun 29 '16 at 11:33
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with theid
command, I think.
– roaima
Jun 29 '16 at 11:44
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
add a comment |
-g
sets the initial, or primary, group. This is what appears in the group field in /etc/passwd
. On many distributions the primary group name is the same as the user name.
-G
sets the supplementary, or additional, groups. These are the groups in /etc/group
that list your user account. This might include groups such as sudo
, staff
, etc.
-g
sets the initial, or primary, group. This is what appears in the group field in /etc/passwd
. On many distributions the primary group name is the same as the user name.
-G
sets the supplementary, or additional, groups. These are the groups in /etc/group
that list your user account. This might include groups such as sudo
, staff
, etc.
answered Jun 29 '16 at 11:23
roaima
42.8k551116
42.8k551116
Thank you kind and quick help . @roaima Did you mean the primary group (-g
) and secondary group(-G
)? Thanks.
– Joe.wang
Jun 29 '16 at 11:33
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with theid
command, I think.
– roaima
Jun 29 '16 at 11:44
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
add a comment |
Thank you kind and quick help . @roaima Did you mean the primary group (-g
) and secondary group(-G
)? Thanks.
– Joe.wang
Jun 29 '16 at 11:33
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with theid
command, I think.
– roaima
Jun 29 '16 at 11:44
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
Thank you kind and quick help . @roaima Did you mean the primary group (
-g
) and secondary group(-G
)? Thanks.– Joe.wang
Jun 29 '16 at 11:33
Thank you kind and quick help . @roaima Did you mean the primary group (
-g
) and secondary group(-G
)? Thanks.– Joe.wang
Jun 29 '16 at 11:33
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with the
id
command, I think.– roaima
Jun 29 '16 at 11:44
@Joe.wang yes. "Supplementary", "secondary", and "additional" are names for the same thing. Kusalananda's answer shows this quite clearly with the
id
command, I think.– roaima
Jun 29 '16 at 11:44
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
Got it ! Thanks your kind help!
– Joe.wang
Jun 29 '16 at 11:49
add a comment |
They are not the same. The -g
option specifies the "primary" group that a user should belong to, while the -G
option specifies one or many supplementary ("secondary") groups.
On a work machine I have access to I have
$ id
uid=1001(me) gid=1001(me) groups=1001(me),27(sudo),110(lxd),1005(theproject)
This shows that my "primary" group is me
(same as my username). However, I'm also member of a number of secondary groups.
Membership of the sudo
group, for example, allows me to use the sudo
command to do scary stuff with the system, due to the way this is configured for sudo
in /etc/sudoers
on this particular machine.
Membership of the theproject
group allows me to modify group-readable/writable files in a project I'm working on with others.
File created will (ordinarily) automatically be assigned to the primary group.
add a comment |
They are not the same. The -g
option specifies the "primary" group that a user should belong to, while the -G
option specifies one or many supplementary ("secondary") groups.
On a work machine I have access to I have
$ id
uid=1001(me) gid=1001(me) groups=1001(me),27(sudo),110(lxd),1005(theproject)
This shows that my "primary" group is me
(same as my username). However, I'm also member of a number of secondary groups.
Membership of the sudo
group, for example, allows me to use the sudo
command to do scary stuff with the system, due to the way this is configured for sudo
in /etc/sudoers
on this particular machine.
Membership of the theproject
group allows me to modify group-readable/writable files in a project I'm working on with others.
File created will (ordinarily) automatically be assigned to the primary group.
add a comment |
They are not the same. The -g
option specifies the "primary" group that a user should belong to, while the -G
option specifies one or many supplementary ("secondary") groups.
On a work machine I have access to I have
$ id
uid=1001(me) gid=1001(me) groups=1001(me),27(sudo),110(lxd),1005(theproject)
This shows that my "primary" group is me
(same as my username). However, I'm also member of a number of secondary groups.
Membership of the sudo
group, for example, allows me to use the sudo
command to do scary stuff with the system, due to the way this is configured for sudo
in /etc/sudoers
on this particular machine.
Membership of the theproject
group allows me to modify group-readable/writable files in a project I'm working on with others.
File created will (ordinarily) automatically be assigned to the primary group.
They are not the same. The -g
option specifies the "primary" group that a user should belong to, while the -G
option specifies one or many supplementary ("secondary") groups.
On a work machine I have access to I have
$ id
uid=1001(me) gid=1001(me) groups=1001(me),27(sudo),110(lxd),1005(theproject)
This shows that my "primary" group is me
(same as my username). However, I'm also member of a number of secondary groups.
Membership of the sudo
group, for example, allows me to use the sudo
command to do scary stuff with the system, due to the way this is configured for sudo
in /etc/sudoers
on this particular machine.
Membership of the theproject
group allows me to modify group-readable/writable files in a project I'm working on with others.
File created will (ordinarily) automatically be assigned to the primary group.
answered Jun 29 '16 at 11:28
Kusalananda
121k16229372
121k16229372
add a comment |
add a comment |
The group applied via -g
is the primary group, so for example when you create a file it will default to making it with your primary group as the group associated with that file. You can however temporarily change which group it uses as default with the sg
or newgrp
commands. All groups in the -G
are secondary groups. More about this here
add a comment |
The group applied via -g
is the primary group, so for example when you create a file it will default to making it with your primary group as the group associated with that file. You can however temporarily change which group it uses as default with the sg
or newgrp
commands. All groups in the -G
are secondary groups. More about this here
add a comment |
The group applied via -g
is the primary group, so for example when you create a file it will default to making it with your primary group as the group associated with that file. You can however temporarily change which group it uses as default with the sg
or newgrp
commands. All groups in the -G
are secondary groups. More about this here
The group applied via -g
is the primary group, so for example when you create a file it will default to making it with your primary group as the group associated with that file. You can however temporarily change which group it uses as default with the sg
or newgrp
commands. All groups in the -G
are secondary groups. More about this here
edited Apr 13 '17 at 12:22
Community♦
1
1
answered Jun 29 '16 at 11:24
Zachary Brady
3,406932
3,406932
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f292830%2fwhat-is-the-difference-between-g-and-g-options-in-useradd%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
See also: GID, current, primary, supplementary, effective and real group IDs?
– Satō Katsura
Jun 29 '16 at 16:49