•  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

如何將用戶添加到組中的CentOS?

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

  • 科學Linux和其功能
  • 數據中心設計的最佳實踐
  • 專門的WordPress主機
  • 努力促進全球寬帶接入賺不了多少班次
  • 低成本專用服務器
  • cPanel專用服務器託管
  • Unable to Access The Server Via SSH
  • Tools That Make Kubernetes Easier
  • SSH Keys - Create
  • Psychz Networks Launches New Data Center in Moscow, Russia
  • MariaDB雲主機
  • How to setup a dedicated server for 7 days to die
  • How to register a domain name with DNS service?
  • DDoS保護定價
  • CDN Routes
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