官术网_书友最值得收藏!

Adding group members

Once you have groups in place, you can add existing users as well as new users to that group. All access rights and permissions assigned to the group will be automatically available to all the members of the group.

Getting ready

You will need super user or root privileges to add a group member to the Ubuntu server.

How to do it…

Follow these steps to add group members:

  1. Here, you can use adduser command with two non-option arguments:
    $ sudo adduser john guest
    
  2. Enter your password to complete addgroup with root privileges.

How it works…

As mentioned previously, you can use the adduser command to add an existing user to an existing group. Here, we have passed two non-option arguments:

  • john: This is the name of the user to be added to the group
  • guest: This is the name of the group

There's more…

Alternatively, you can use the command usermod to modify the group assigned to the user:

$ sudo usermod -g <group> <username>

To add a user to multiple groups, use the following command:

$ sudo usermod -a -G <group1>,<group2>,<group3> <username>

This will add <username> to <group1>, <group2>, and <group3>. Without flag –a, any previously assigned groups will be replaced with new groups.

主站蜘蛛池模板: 西昌市| 南和县| 小金县| 华阴市| 时尚| 开鲁县| 增城市| 毕节市| 葫芦岛市| 湘潭市| 平湖市| 沅陵县| 香河县| 常德市| 鄂伦春自治旗| 自贡市| 建阳市| 镇原县| 西和县| 萨嘎县| 揭东县| 河北区| 东乌珠穆沁旗| 芦山县| 南宫市| 越西县| 遂昌县| 平远县| 藁城市| 永新县| 曲周县| 神木县| 贵港市| 孝昌县| 德惠市| 汝南县| 日土县| 丹寨县| 乌苏市| 新泰市| 社会|