搜索

此内容没有您所选择的语言版本。

3.4.2. Attaching New Users to Groups

download PDF
The useradd command creates a User Private Group (UPG, a group assigned to a user account to which that user exclusively belongs) whenever a new user is added to the system and names the group after the user. For example, when the account robert is created, an UPG named robert is created at the same time, the only member of which is the user robert.
If you do not want to create a User Private Group for a user for whatever reason, execute the useradd command with the following option:
useradd -N username
Instead of automatically creating UPG or not creating it at all, you can specify the user's group membership with -g and -G options. While the -g option specifies the primary group membership, -G refers to supplementary groups into which the user is also included. The group names you specify must already exist on the system.

Example 3.7. Adding a User to a Group

~]# useradd -g "friends" -G "family,schoolmates" emily
The useradd -g "friends" -G "family,schoolmates" emily command creates the user emily but emily's primary group is set to friends as specified by the -g option. emily is also a group member of the supplementary groups family and schoolmates.
Provided the user already exists and you want to add them to certain supplementary group(s), use the usermod command with the -G option and a list of groups divided by commas, no spaces:
usermod -G group_1,group_2,group_3
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.