用户组及添加用户到组

In Linux users may have different groups registered. By default adding a user to the Linux system will create new user. There are different commands to change user group one of them is useradd which actually create new user and sets given group to the newly created user. As always we need root privileges to change user group.

在Linux中,用户可能注册了不同的组。 默认情况下,将用户添加到Linux系统将创建新用户。 有不同的命令来更改用户组,其中之一是useradd ,它实际上创建了新用户并将给定组设置为新创建的用户。 与往常一样,我们需要root特权才能更改用户组。

列出用户 (List Users)

Before starting to add user into a group we will list currently existing user accounts. There are a lot of different ways to list user accounts but I like to use following command.

在开始将用户添加到组中之前,我们将列出当前现有的用户帐户。 列出用户帐户的方法有很多,但是我喜欢使用以下命令。

$ cat /etc/passwd | cut -d ':' -f 1

List Users
列出用户

清单群组(List Groups)

We will also list currently existing groups which is stored in a file /etc/group .

我们还将列出存储在文件/etc/group中的当前现有/etc/group

$ cat /etc/group | cut -d ':' -f 1

List Groups
清单群组

更改主要组(Change Primary Group)

Linux users may have more than one group. We call them primary and other groups. We will change user test primary group to mysql. Primary group is used to assign group to the files and directories user created.

Linux用户可能有多个组。 我们称它们为主要群体和其他群体。 我们将用户测试主组更改为mysql。 主组用于将组分配给用户创建的文件和目录。

In this example we will change user test primary group to the test

在此示例中,我们将用户测试主要组更改为测试

$ usermod -g mysql test
  • usermod command will mdify usergroup

    usermod命令将mdify用户组

  • -g mysql provides group parameter named mysql 

    -g mysql提供名为mysql的组参数

  • test is the user the group will be changed.

    测试是要更改组的用户。

添加其他组 (Add Other Groups)

We can add user to the other groups. In this example we will add user test to the group root. Group root is not primary group of the test . We will use -G option in order to specify other group.

我们可以将用户添加到其他组。 在此示例中,我们将用户测试添加到组root中。 组不是测试的主要组 我们将使用-G选项以指定其他组。

$ usermod -G root test
  • usermod is command that will change other group memebership

    usermod是将更改其他组成员身份的命令

  • -G root provides change for test user other group

    -G root为测试用户其他组提供更改

  • test is username

    测试是用户名

.u4d6742a0e629d2b453b53cc6b792b6b2 , .u4d6742a0e629d2b453b53cc6b792b6b2 .postImageUrl , .u4d6742a0e629d2b453b53cc6b792b6b2 .centered-text-area { min-height: 80px; position: relative; } .u4d6742a0e629d2b453b53cc6b792b6b2 , .u4d6742a0e629d2b453b53cc6b792b6b2:hover , .u4d6742a0e629d2b453b53cc6b792b6b2:visited , .u4d6742a0e629d2b453b53cc6b792b6b2:active { border:0!important; } .u4d6742a0e629d2b453b53cc6b792b6b2 .clearfix:after { content: ""; display: table; clear: both; } .u4d6742a0e629d2b453b53cc6b792b6b2 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u4d6742a0e629d2b453b53cc6b792b6b2:active , .u4d6742a0e629d2b453b53cc6b792b6b2:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u4d6742a0e629d2b453b53cc6b792b6b2 .centered-text-area { width: 100%; position: relative; } .u4d6742a0e629d2b453b53cc6b792b6b2 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u4d6742a0e629d2b453b53cc6b792b6b2 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u4d6742a0e629d2b453b53cc6b792b6b2 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u4d6742a0e629d2b453b53cc6b792b6b2:hover .ctaButton { background-color: #E67E22!important; } .u4d6742a0e629d2b453b53cc6b792b6b2 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u4d6742a0e629d2b453b53cc6b792b6b2 .u4d6742a0e629d2b453b53cc6b792b6b2-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u4d6742a0e629d2b453b53cc6b792b6b2:after { content: ""; display: block; clear: both; }

LEARN MORE  Linux Whoami Command Tutorial To Find Current User

.u4d6742a0e629d2b453b53cc6b792b6b2 , .u4d6742a0e629d2b453b53cc6b792b6b2 .postImageUrl , .u4d6742a0e629d2b453b53cc6b792b6b2 .centered-text-area { min-height: 80px; position: relative; } .u4d6742a0e629d2b453b53cc6b792b6b2 , .u4d6742a0e629d2b453b53cc6b792b6b2:hover , .u4d6742a0e629d2b453b53cc6b792b6b2:visited , .u4d6742a0e629d2b453b53cc6b792b6b2:active { border:0!important; } .u4d6742a0e629d2b453b53cc6b792b6b2 .clearfix:after { content: ""; display: table; clear: both; } .u4d6742a0e629d2b453b53cc6b792b6b2 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u4d6742a0e629d2b453b53cc6b792b6b2:active , .u4d6742a0e629d2b453b53cc6b792b6b2:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u4d6742a0e629d2b453b53cc6b792b6b2 .centered-text-area { width: 100%; position: relative; } .u4d6742a0e629d2b453b53cc6b792b6b2 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u4d6742a0e629d2b453b53cc6b792b6b2 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u4d6742a0e629d2b453b53cc6b792b6b2 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u4d6742a0e629d2b453b53cc6b792b6b2:hover .ctaButton { background-color: #E67E22!important; } .u4d6742a0e629d2b453b53cc6b792b6b2 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u4d6742a0e629d2b453b53cc6b792b6b2 .u4d6742a0e629d2b453b53cc6b792b6b2-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u4d6742a0e629d2b453b53cc6b792b6b2:after { content: ""; display: block; clear: both; }

了解更多Linux Whoami命令教程以查找当前用户

添加到多个组(Add To Multiple Groups)

Some times we may need to add single user to the multiple groups in a single command. We can use -G options with multiple group names like below. the group names are delimited with command. In this example we will add usertestto the groups namedrootandmysql`

有时我们可能需要在单个命令中将单个用户添加到多个组中。 我们可以将-G选项与多个组名一起使用,如下所示。 组名用命令定界。 在这个例子中,我们将user测试添加to the groups named root and mysql` to the groups named

$ usermod -G root,mysql test
  • usermod is command

    usermod是命令

  • -G root,mysql will change test user group memberships

    -G root,mysql将更改测试用户组成员身份

如何将用户添加到组? 信息移植 (How To Add A User To A Group? Infografic)

翻译自: https://www.poftut.com/linux-add-user-to-group/

用户组及添加用户到组

用户组及添加用户到组_如何将用户添加到组?相关推荐

  1. groupdel 删除组_如何在Linux中删除组– groupdel命令

    groupdel 删除组 Linux groupdel command is used to delete a group. This is a very powerful command, so u ...

  2. MySQL怎么导出用户权限表_导出MySQL用户权限_MySQL

    在对MySQL数据库进行迁移的时候,有时候也需要迁移源数据库内的用户与权限.对于这个迁移我们可以从mysql.user表来获取用户的相关权限来生成相应的SQL语句,然后在目标服务器上来执行生成的SQL ...

  3. 快手通过标签添加你什么意思_快手通过发现添加是什么意思

    快手通过发现添加是指作品内容优越上了热门,被别人看到以后把你添加为关注,所以就叫通过发现添加.发现添加的提示跟关注添加是不一样的,也就是添加方式不一样.一个是通过发现,一个是通过关注添加. 扩展资料: ...

  4. html添加单选按钮组,怎么插入单选按钮和单选按钮组_如何插入单选按钮和单选按钮组_飞翔教程...

    一.插入单个单选按钮 1. 点击鼠标,将光标定位在表单框线内,点击"插入"菜单,选择"表单"项,在弹出的子菜单中选择"单选按钮"命令. 或者 ...

  5. mysql使用新建用户的好处_入门MySQL——用户与权限

    前言: 前面几篇文章为大家介绍了各种SQL语法的使用,本篇文章将主要介绍MySQL用户及权限相关知识,如果你不是DBA的话可能平时用的不多,但是了解下也是好处多多. 1.创建用户 官方推荐创建语法为: ...

  6. 在文件编辑器中添加dock菜单项_将应用程序添加到Mac 的Dock的简便方法

    在OS X和较新的macOS中,Dock是Mac上最受认可的用户界面元素之一.Dock是一个方便的应用启动器,通常会拥抱屏幕底部.根据Dock中图标的数量,它可能会覆盖Mac显示屏的整个宽度. 苹果于 ...

  7. python解三元一次方程组_关于实现求解三元一次方程组的小程序的一点小研究

    引入 在今年的暑假,作者利用空闲时间阅读了gilbert strange的introduction to linear algebra.作为享誉国际学界多年的MIT教材,该书以高斯消元法求解二三元方程 ...

  8. mysql里添加不了中文_为什么MySQL不能添加中文

    我的MYSQL的编码配置是没有什么问题的!..但是当我在WEB程序中往MySQL中添加数据时他就是会报错!在浏览器中的错误是: org.springframework.jdbc.Uncategoriz ...

  9. ai电磁组属于什么组_飞思卡尔智能车电磁组分区算法介绍

    写在之前的话: 1.目前我是一名在校学生,这也是我第一次写博客,不周之处,请多谅解: 2.此算法并非原创,借鉴自山东德州学院第八届白杨队(PS:个人看法,对于一些人把别人的开源东西改头换面一下就说是自 ...

最新文章

  1. php跨域共享session
  2. mac java web_mac os安装java web开发环境配置
  3. 编程之美2.12 快速寻找满足条件的两个数
  4. 字符串或打印输出乱码
  5. pdo 连接数据库 报错 could not find driver 解决方法
  6. PartnerSet in IBASE
  7. python3 dict 排序_Python 3.9 新增功能展望
  8. 第三章:使用email-ext替换Jenkins的默认邮件通知
  9. Java中如何循环删除一个集合(如List)中的多个元素
  10. C++类引用中的构造函数与析构函数的执行顺序练习
  11. 克里斯坦森:管理水平高的公司往往离崩塌不远
  12. 空调开关html,酒店墙上空调开关图解—酒店墙上空调开关图案是什么意思
  13. MATLAB自带插值函数
  14. Servlet请求与响应
  15. 华为又招了一名天才少年!
  16. Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组
  17. java 微信转账 ca_error_java,微信支付退款_微信支付退款接口调用证书出现错误,java,微信支付退款,ssl - phpStudy...
  18. 《学生问题行为矫正实践研究》立项申请
  19. C语言字符串后追加数字
  20. 【机器学习自学笔记4】朴素贝叶斯分类器

热门文章

  1. Java字节流与字符流,断点续传实现分片下载、上传、合并
  2. jquery 触发 dropdownlist SelectedIndexChanged
  3. MySQL 时区异常
  4. 特征提取(Feature Detect)、特征描述(Feature Descriptor)、特征匹配(Feature Match)
  5. C++的get()函数使用详解
  6. java中如何表示负数?
  7. Spark基础操作(一)
  8. 超分辨率硕士论文阅读
  9. Android性能优化:那些关于Bitmap图片资源优化的小事
  10. 卷积神经网络中二维卷积核与三维卷积核有什么区别?