How to add existing user to an existing group?
up vote
591
down vote
favorite
I want to add the Apache user (www-data
) to the audio
group. I've read the man page for useradd
, but I'm not having any luck. I'm running xubuntu 11.10. Here's what I'm doing:
$ sudo useradd -G audio www-data
useradd: user 'www-data' already exists
If I leave out the -G
option, bash, prints the help info for useradd
:
$ sudo useradd audio www-data
Usage: useradd [options] LOGIN
Options: -b, --base-dir BASE_DIR base directory for the home directory...
It's not clear to me from the man page what options I should use to make this work.
users groups
add a comment |
up vote
591
down vote
favorite
I want to add the Apache user (www-data
) to the audio
group. I've read the man page for useradd
, but I'm not having any luck. I'm running xubuntu 11.10. Here's what I'm doing:
$ sudo useradd -G audio www-data
useradd: user 'www-data' already exists
If I leave out the -G
option, bash, prints the help info for useradd
:
$ sudo useradd audio www-data
Usage: useradd [options] LOGIN
Options: -b, --base-dir BASE_DIR base directory for the home directory...
It's not clear to me from the man page what options I should use to make this work.
users groups
add a comment |
up vote
591
down vote
favorite
up vote
591
down vote
favorite
I want to add the Apache user (www-data
) to the audio
group. I've read the man page for useradd
, but I'm not having any luck. I'm running xubuntu 11.10. Here's what I'm doing:
$ sudo useradd -G audio www-data
useradd: user 'www-data' already exists
If I leave out the -G
option, bash, prints the help info for useradd
:
$ sudo useradd audio www-data
Usage: useradd [options] LOGIN
Options: -b, --base-dir BASE_DIR base directory for the home directory...
It's not clear to me from the man page what options I should use to make this work.
users groups
I want to add the Apache user (www-data
) to the audio
group. I've read the man page for useradd
, but I'm not having any luck. I'm running xubuntu 11.10. Here's what I'm doing:
$ sudo useradd -G audio www-data
useradd: user 'www-data' already exists
If I leave out the -G
option, bash, prints the help info for useradd
:
$ sudo useradd audio www-data
Usage: useradd [options] LOGIN
Options: -b, --base-dir BASE_DIR base directory for the home directory...
It's not clear to me from the man page what options I should use to make this work.
users groups
users groups
edited Apr 15 '17 at 18:22
Simón
355118
355118
asked Nov 15 '11 at 18:21
Sparky1
4,02971514
4,02971514
add a comment |
add a comment |
7 Answers
7
active
oldest
votes
up vote
915
down vote
accepted
The useradd
command will try to add a new user. Since your user already exists this is not what you want.
Instead: To modify an existing user, like adding that user to a new group, use the usermod
command.
Try this:
sudo usermod -a -G groupName userName
The user will need to log out and log back in to see their new group added.
The
-a
(append) switch is essential. Otherwise, the user will be removed from any groups, not in the list.The
-G
switch takes a (comma-separated) list of additional groups to assign the user to.
67
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline
– Programster
Nov 11 '13 at 14:50
34
I think the preferred way now issudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.
– ctbrown
Aug 14 '14 at 14:20
3
@wilhil:man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."
– Adam Michalik
Jan 26 '16 at 15:03
15
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
9
@con-f-use, if you can runsudo login -f YOURUSERNAME
, it will start a new shell session. Use theid
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible
– Aaron McDaid
Mar 31 '17 at 14:57
|
show 3 more comments
up vote
198
down vote
Adding a user to a group:
sudo adduser user group
Removing a user from a group:
sudo deluser user group
2
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
11
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
11
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
4
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
2
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
|
show 1 more comment
up vote
48
down vote
After adding to a existing user:
usermod -a -G group user
You may need to logout and login to get the groups permissions from /etc/group
.
21
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
FYI: I think theid
command should indicate you were added to the group without needing to exit.id myuser
– ficuscr
Jan 3 '14 at 16:57
5
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
add a comment |
up vote
25
down vote
I normally use
sudo gpasswd -a myuser mygroup
3
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
add a comment |
up vote
5
down vote
On Ubuntu, since logging in as root
is not enabled, users in the sudo
group can elevate privileges for certain restricted commands. Any restricted command must be prepended with sudo
to elevate privilege.
sudo usermod -a -G group user
will add the existing user user
to a supplemental group named group
. The user's primary group will remain unchanged.
add a comment |
up vote
4
down vote
I'm posting this as an answer because I don't have enough reputation to comment. As @dpendolino's mentioned, for the effects of this command to persist:
sudo usermod -a -G groupName userName
...you need to logout/login again.
However, if you need a shortcut to start using your new group membership immediately (and you have the correct sudo privileges) I have found this work-around:
$ sudo su -
# su [userName]
$ groups
Explanation:
sudo su -
will give you a root shell
su [userName]
returns you to a shell with your user
groups
when run now will show the group you added with theusermod -aG
command
In my case I was trying to add the 'docker' group to my user
Before:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd
After:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd docker
add a comment |
up vote
0
down vote
sudo usermod -a -G groupName userName
will work just fine, but I had to reboot entirely, just log out and log in again did not do the job...
New contributor
add a comment |
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
915
down vote
accepted
The useradd
command will try to add a new user. Since your user already exists this is not what you want.
Instead: To modify an existing user, like adding that user to a new group, use the usermod
command.
Try this:
sudo usermod -a -G groupName userName
The user will need to log out and log back in to see their new group added.
The
-a
(append) switch is essential. Otherwise, the user will be removed from any groups, not in the list.The
-G
switch takes a (comma-separated) list of additional groups to assign the user to.
67
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline
– Programster
Nov 11 '13 at 14:50
34
I think the preferred way now issudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.
– ctbrown
Aug 14 '14 at 14:20
3
@wilhil:man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."
– Adam Michalik
Jan 26 '16 at 15:03
15
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
9
@con-f-use, if you can runsudo login -f YOURUSERNAME
, it will start a new shell session. Use theid
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible
– Aaron McDaid
Mar 31 '17 at 14:57
|
show 3 more comments
up vote
915
down vote
accepted
The useradd
command will try to add a new user. Since your user already exists this is not what you want.
Instead: To modify an existing user, like adding that user to a new group, use the usermod
command.
Try this:
sudo usermod -a -G groupName userName
The user will need to log out and log back in to see their new group added.
The
-a
(append) switch is essential. Otherwise, the user will be removed from any groups, not in the list.The
-G
switch takes a (comma-separated) list of additional groups to assign the user to.
67
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline
– Programster
Nov 11 '13 at 14:50
34
I think the preferred way now issudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.
– ctbrown
Aug 14 '14 at 14:20
3
@wilhil:man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."
– Adam Michalik
Jan 26 '16 at 15:03
15
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
9
@con-f-use, if you can runsudo login -f YOURUSERNAME
, it will start a new shell session. Use theid
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible
– Aaron McDaid
Mar 31 '17 at 14:57
|
show 3 more comments
up vote
915
down vote
accepted
up vote
915
down vote
accepted
The useradd
command will try to add a new user. Since your user already exists this is not what you want.
Instead: To modify an existing user, like adding that user to a new group, use the usermod
command.
Try this:
sudo usermod -a -G groupName userName
The user will need to log out and log back in to see their new group added.
The
-a
(append) switch is essential. Otherwise, the user will be removed from any groups, not in the list.The
-G
switch takes a (comma-separated) list of additional groups to assign the user to.
The useradd
command will try to add a new user. Since your user already exists this is not what you want.
Instead: To modify an existing user, like adding that user to a new group, use the usermod
command.
Try this:
sudo usermod -a -G groupName userName
The user will need to log out and log back in to see their new group added.
The
-a
(append) switch is essential. Otherwise, the user will be removed from any groups, not in the list.The
-G
switch takes a (comma-separated) list of additional groups to assign the user to.
edited Dec 18 '17 at 22:41
Sameer
1131
1131
answered Nov 15 '11 at 18:33
dpendolino
9,4141106
9,4141106
67
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline
– Programster
Nov 11 '13 at 14:50
34
I think the preferred way now issudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.
– ctbrown
Aug 14 '14 at 14:20
3
@wilhil:man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."
– Adam Michalik
Jan 26 '16 at 15:03
15
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
9
@con-f-use, if you can runsudo login -f YOURUSERNAME
, it will start a new shell session. Use theid
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible
– Aaron McDaid
Mar 31 '17 at 14:57
|
show 3 more comments
67
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline
– Programster
Nov 11 '13 at 14:50
34
I think the preferred way now issudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.
– ctbrown
Aug 14 '14 at 14:20
3
@wilhil:man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."
– Adam Michalik
Jan 26 '16 at 15:03
15
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
9
@con-f-use, if you can runsudo login -f YOURUSERNAME
, it will start a new shell session. Use theid
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible
– Aaron McDaid
Mar 31 '17 at 14:57
67
67
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline– Programster
Nov 11 '13 at 14:50
sudo usermod -a -G [group-name] [user-name]
: Just a quickie for those who only glance at the answer after reading the headline– Programster
Nov 11 '13 at 14:50
34
34
I think the preferred way now is
sudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.– ctbrown
Aug 14 '14 at 14:20
I think the preferred way now is
sudo adduser user group
. It is simpler and cleaner syntax. See the response from @Bai.– ctbrown
Aug 14 '14 at 14:20
3
3
@wilhil:
man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."– Adam Michalik
Jan 26 '16 at 15:03
@wilhil:
man usermod
: "-a, --append - Add the user to the supplementary group(s). Use only with the -G option.; -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] [...] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list."– Adam Michalik
Jan 26 '16 at 15:03
15
15
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
Is there a way to get around the "logout and back in" part? Some type of update-groups command, maybe?
– con-f-use
Mar 19 '16 at 0:05
9
9
@con-f-use, if you can run
sudo login -f YOURUSERNAME
, it will start a new shell session. Use the id
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible– Aaron McDaid
Mar 31 '17 at 14:57
@con-f-use, if you can run
sudo login -f YOURUSERNAME
, it will start a new shell session. Use the id
command to verify that the new session is in the correct set of groups. However, this isn't "global" - it doesn't apply to terminals that are already open. So, really, logging out is the best option, where possible– Aaron McDaid
Mar 31 '17 at 14:57
|
show 3 more comments
up vote
198
down vote
Adding a user to a group:
sudo adduser user group
Removing a user from a group:
sudo deluser user group
2
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
11
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
11
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
4
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
2
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
|
show 1 more comment
up vote
198
down vote
Adding a user to a group:
sudo adduser user group
Removing a user from a group:
sudo deluser user group
2
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
11
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
11
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
4
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
2
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
|
show 1 more comment
up vote
198
down vote
up vote
198
down vote
Adding a user to a group:
sudo adduser user group
Removing a user from a group:
sudo deluser user group
Adding a user to a group:
sudo adduser user group
Removing a user from a group:
sudo deluser user group
answered Jan 12 '12 at 13:09
Bai
4,4082106
4,4082106
2
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
11
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
11
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
4
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
2
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
|
show 1 more comment
2
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
11
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
11
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
4
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
2
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
2
2
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
not exactly what this question being asked for
– Tejendra
Sep 3 '14 at 8:10
11
11
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
@Tejendra's comment seems to presuppose that using useradd is desirable/mandatory to answer OP's question; Perhaps this answer is just missing words to indicate that adduser/deluser is a better alternative.
– sage
Jul 28 '15 at 19:39
11
11
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
For me simpler interface is better, that's why I like this one.
– Betlista
Aug 11 '16 at 10:35
4
4
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
This is exactly the question being asked. @knocte, yes, I think it is Debian specific
– Auspex
Nov 14 '16 at 12:58
2
2
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
@Auspex I can confirm that it does not work on Red Hat.
– Stibu
Feb 22 '17 at 9:43
|
show 1 more comment
up vote
48
down vote
After adding to a existing user:
usermod -a -G group user
You may need to logout and login to get the groups permissions from /etc/group
.
21
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
FYI: I think theid
command should indicate you were added to the group without needing to exit.id myuser
– ficuscr
Jan 3 '14 at 16:57
5
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
add a comment |
up vote
48
down vote
After adding to a existing user:
usermod -a -G group user
You may need to logout and login to get the groups permissions from /etc/group
.
21
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
FYI: I think theid
command should indicate you were added to the group without needing to exit.id myuser
– ficuscr
Jan 3 '14 at 16:57
5
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
add a comment |
up vote
48
down vote
up vote
48
down vote
After adding to a existing user:
usermod -a -G group user
You may need to logout and login to get the groups permissions from /etc/group
.
After adding to a existing user:
usermod -a -G group user
You may need to logout and login to get the groups permissions from /etc/group
.
edited Dec 17 '13 at 7:36
Jin Kwon
1127
1127
answered Feb 22 '13 at 17:16
Amos Folarin
69959
69959
21
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
FYI: I think theid
command should indicate you were added to the group without needing to exit.id myuser
– ficuscr
Jan 3 '14 at 16:57
5
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
add a comment |
21
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
FYI: I think theid
command should indicate you were added to the group without needing to exit.id myuser
– ficuscr
Jan 3 '14 at 16:57
5
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
21
21
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
Please make it the part "need to logout and login" bold.
– Jin Kwon
Dec 17 '13 at 6:36
FYI: I think the
id
command should indicate you were added to the group without needing to exit. id myuser
– ficuscr
Jan 3 '14 at 16:57
FYI: I think the
id
command should indicate you were added to the group without needing to exit. id myuser
– ficuscr
Jan 3 '14 at 16:57
5
5
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
Logging out and back in was required for me on Ubuntu 14.10.
– A.Danischewski
Apr 1 '15 at 0:32
add a comment |
up vote
25
down vote
I normally use
sudo gpasswd -a myuser mygroup
3
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
add a comment |
up vote
25
down vote
I normally use
sudo gpasswd -a myuser mygroup
3
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
add a comment |
up vote
25
down vote
up vote
25
down vote
I normally use
sudo gpasswd -a myuser mygroup
I normally use
sudo gpasswd -a myuser mygroup
answered Nov 15 '11 at 18:47
enzotib
62.1k5130153
62.1k5130153
3
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
add a comment |
3
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
3
3
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
usermod was not available on my system ubuntu 14.04. This worked great!
– Drew
Jun 24 '14 at 15:45
add a comment |
up vote
5
down vote
On Ubuntu, since logging in as root
is not enabled, users in the sudo
group can elevate privileges for certain restricted commands. Any restricted command must be prepended with sudo
to elevate privilege.
sudo usermod -a -G group user
will add the existing user user
to a supplemental group named group
. The user's primary group will remain unchanged.
add a comment |
up vote
5
down vote
On Ubuntu, since logging in as root
is not enabled, users in the sudo
group can elevate privileges for certain restricted commands. Any restricted command must be prepended with sudo
to elevate privilege.
sudo usermod -a -G group user
will add the existing user user
to a supplemental group named group
. The user's primary group will remain unchanged.
add a comment |
up vote
5
down vote
up vote
5
down vote
On Ubuntu, since logging in as root
is not enabled, users in the sudo
group can elevate privileges for certain restricted commands. Any restricted command must be prepended with sudo
to elevate privilege.
sudo usermod -a -G group user
will add the existing user user
to a supplemental group named group
. The user's primary group will remain unchanged.
On Ubuntu, since logging in as root
is not enabled, users in the sudo
group can elevate privileges for certain restricted commands. Any restricted command must be prepended with sudo
to elevate privilege.
sudo usermod -a -G group user
will add the existing user user
to a supplemental group named group
. The user's primary group will remain unchanged.
edited Jul 7 '17 at 18:03
Eliah Kagan
80.9k20226364
80.9k20226364
answered Feb 25 '16 at 21:58
Debra Butcher McCusker
5612
5612
add a comment |
add a comment |
up vote
4
down vote
I'm posting this as an answer because I don't have enough reputation to comment. As @dpendolino's mentioned, for the effects of this command to persist:
sudo usermod -a -G groupName userName
...you need to logout/login again.
However, if you need a shortcut to start using your new group membership immediately (and you have the correct sudo privileges) I have found this work-around:
$ sudo su -
# su [userName]
$ groups
Explanation:
sudo su -
will give you a root shell
su [userName]
returns you to a shell with your user
groups
when run now will show the group you added with theusermod -aG
command
In my case I was trying to add the 'docker' group to my user
Before:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd
After:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd docker
add a comment |
up vote
4
down vote
I'm posting this as an answer because I don't have enough reputation to comment. As @dpendolino's mentioned, for the effects of this command to persist:
sudo usermod -a -G groupName userName
...you need to logout/login again.
However, if you need a shortcut to start using your new group membership immediately (and you have the correct sudo privileges) I have found this work-around:
$ sudo su -
# su [userName]
$ groups
Explanation:
sudo su -
will give you a root shell
su [userName]
returns you to a shell with your user
groups
when run now will show the group you added with theusermod -aG
command
In my case I was trying to add the 'docker' group to my user
Before:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd
After:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd docker
add a comment |
up vote
4
down vote
up vote
4
down vote
I'm posting this as an answer because I don't have enough reputation to comment. As @dpendolino's mentioned, for the effects of this command to persist:
sudo usermod -a -G groupName userName
...you need to logout/login again.
However, if you need a shortcut to start using your new group membership immediately (and you have the correct sudo privileges) I have found this work-around:
$ sudo su -
# su [userName]
$ groups
Explanation:
sudo su -
will give you a root shell
su [userName]
returns you to a shell with your user
groups
when run now will show the group you added with theusermod -aG
command
In my case I was trying to add the 'docker' group to my user
Before:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd
After:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd docker
I'm posting this as an answer because I don't have enough reputation to comment. As @dpendolino's mentioned, for the effects of this command to persist:
sudo usermod -a -G groupName userName
...you need to logout/login again.
However, if you need a shortcut to start using your new group membership immediately (and you have the correct sudo privileges) I have found this work-around:
$ sudo su -
# su [userName]
$ groups
Explanation:
sudo su -
will give you a root shell
su [userName]
returns you to a shell with your user
groups
when run now will show the group you added with theusermod -aG
command
In my case I was trying to add the 'docker' group to my user
Before:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd
After:
$ groups
userName adm cdrom sudo dip plugdev lpadmin sambashare wireshark lxd docker
answered Mar 25 at 17:49
bluemorpho
512
512
add a comment |
add a comment |
up vote
0
down vote
sudo usermod -a -G groupName userName
will work just fine, but I had to reboot entirely, just log out and log in again did not do the job...
New contributor
add a comment |
up vote
0
down vote
sudo usermod -a -G groupName userName
will work just fine, but I had to reboot entirely, just log out and log in again did not do the job...
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
sudo usermod -a -G groupName userName
will work just fine, but I had to reboot entirely, just log out and log in again did not do the job...
New contributor
sudo usermod -a -G groupName userName
will work just fine, but I had to reboot entirely, just log out and log in again did not do the job...
New contributor
New contributor
answered Nov 26 at 15:34
alex
11
11
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f79565%2fhow-to-add-existing-user-to-an-existing-group%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