How to add a user to a Linux group using the command line?

It’s completely incomprehensible why Linux Ubuntu developers made it very difficult to set up accounts. Because of this, many users cannot add the user to the Linux group. Yes, now you can’t manage groups, and such innovations are not always beneficial. From memory, everyone is trying to add the user to the Linux group by going to the “Accounts” settings, but the usual functionality is missing there. It is not clear why this innovation was made, but there are most likely reasons. Fortunately, this can be done differently.

add user to linux group




Ways to add a user to a Linux group

. useradd usermod. . . : /etc/passwd, /etc/shadow /etc/group.

, . . user1 user1. . .





useradd

linux add user to sudo group




, . , .

Linux sudo, :

sudo useradd -G {group1} username

"-G" . . . : alexey : www, admins, test. :

# useradd -G admins, test, www, alexey

Linux root, , root. alexey .

, . : sudo groupadd group_name

"group_name" .

, ( ) , : # sudo id user_name.

usermod

linux add user to root group




, alexey test. :

# usermod -a -G test alexey

, :

# usermod -g test alexey

Linux. , , , . , , - . . Linux, Ubuntu , . .

. , . .




All Articles