•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

Centos - 将用户添加到组

  • Home
  • Client
  • Qa Forum
  • Centos - 将用户添加到组

Posted By: Fernando | 1 Replies | Last Reply On: May 29, 2017 05:22:11

如何将用户添加到群组中?

Psychz - Nikhil

Votes: 0Posted On: May 29, 2017 05:22:11
 

您可以通过多种方法的帮助将任何用户添加到组中。您可以在创建用户本身时将用户添加到组中,或将现有用户添加到组。您还可以将用户添加到多个组。以下是用户可以添加到组中的一些方法和有用的命令。

先决条件

CentOS操作系统 - 在这种情况下,我们使用CentOS 7。

创建用户时添加组。

在创建用户时可以将任何组添加到用户。一般的语法是“useradd -G group username” 。在这种情况下,我们将创建一个用户“test”并将其添加到组“linux”中。

useradd -G linux测试

(注意:“-G”选项用于将组添加为辅助组,如果要将组添加为主要组件,请使用“-g”选项。)

将现有用户添加到组

现有用户也可以通过使用“usermod”命令添加到组中。将用户添加到组的一般语法如下所示。

usermod -aG组用户名

例如,我们将用户“test1”添加到“linux”组中。下面显示一个样品供您参考。

usermod -aG linux test1

(注:“-a”选项用于将用户添加到补充组中,应始终与“-G”选项一起使用)

将多个组添加到单个用户

也可以使用“usermod”命令将多个组添加到单个用户。以下语法用于以下内容。

usermod -a -G group1,group2,group3用户名

有一些有用的命令可以帮助您列出组,找出哪些组被分配给用户等。其中一些列在下面。

“getent group” - 此命令用于列出操作系统中的所有组。

2.“组” - 此命令用于查看用户名被分配给的所有组。 (语法:“groups username”)

3.“id” - 您还可以通过运行id命令并指定用户名来查看与每个组相关联的数字ID。 (语法:“id username”)

这些是在CentOS操作系统中将用户添加到组中的一些命令。我们建议您浏览这些命令的手册页,以便详细了解其所有变体。

Was this reply helpful?

Related topics

  • CentOS的7:“叫它RED HAT 7 LITE”
  • 如何在CentOS 7配置IP范围是多少?
  • 如何在CentOS 7 MongoDB的安全?
  • Is Centos 8 the last stable OS release?
  • Centos 7 Static IP
  • Add user to sudoers Centos
  • Setup VPN on CentOS 8
  • Yum Update Not Working on Centos 7
  • Upgrade Centos 6 to Centos 7
  • 顶级主机控制面板对于Linux
  • Installation of Lamp Stack on CentOS 7
  • sBlock - Backup on RHEL, CentOS, AlmaLinux & Rocky Linux
  • EasyApache 4:比以前更好?
  • 开源代理服务器解决方案
  • 在对比:在FreeBSD VS Linux的
Copyright © 2025 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nCDN
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801