添加用户username到sudo组:

  1. sudo usermod -aG sudo username
  1. USERMOD(8) 系统管理命令 USERMOD(8)
  2.  

  3. usermod - 修改一个用户账户
  4.  

  5. usermod [选项] 登录
  6.  

  7. usermod 修改系统账户文件和在命令行上指定的相关更改。
  8.  

  9. usermod 可以接受的选项有:
  10.  
  11. -a, --append
  12. 将用户添加到附加组。只能和 -G 选项一起使用。
  13.  
  14. -c, --comment COMMENT
  15. 用户密码文件中注释字段的新值。通常使用 chfn(1) 工具对其进行修改。
  16.  
  17. -d, --home HOME_DIR
  18. 用户的新登录目录。
  19.  
  20. 如果给了 -m 选项,当前主目录的内容将会移动到新主目录中,如果不存在,则创建。
  21.  
  22. -e, --expiredate EXPIRE_DATE
  23. 用户账户将被禁用的日期。日期以 YYYY-MM-DD 格式指定。
  24.  
  25. EXPIRE_DATE 参数将禁用账户过期。
  26.  
  27. 此选项需要一个 /etc/passwd 文件。如果没有,将会创建一条 /etc/shadow 项目。
  28.  
  29. -f, --inactive INACTIVE
  30. 密码过期之后,账户被彻底禁用之前的天数。
  31.  
  32. 0 表示密码过期时,立即禁用账户;-1 表示不使用这个功能。
  33.  
  34. 此选项需要一个 /etc/passwd 文件。如果没有,将会创建一条 /etc/shadow 项目。
  35.  
  36. -g, --gid GROUP
  37. 用户的新初始登录组的组名或数字代号。此组必须存在。
  38.  
  39. 用户主目录中,属于原来的主组的文件将转交新组所有。
  40.  
  41. 主目录之外的文件所属的组必须手动修改。
  42.  
  43. -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
  44. 用户还属于的附加组列表。组之间使用逗号分隔,没有空格。这些组需要遵守和 -g 选项中给的组同
  45. 样的限制。
  46.  
  47. 如果用户当前是一个组的成员,而这个组没有列在这里,用户将被从那个组里便删除。这个行为可以
  48. 通过 -a 选项修改,这使用户追加到给出的附加组列表中。
  49.  
  50. -l, --login NEW_LOGIN
  51. 用户的名称将会从 LOGIN 修改为 NEW_LOGIN。不会更改别的任何东西。特别是,用户的主目录名和
  52. 邮件池也需要手动修改以和新登录名对应。
  53.  
  54. -L, --lock
  55. 锁定用户的密码。这会在用户加密的密码之前放置一个“!”,可以快速禁用密码。您可以和 -p -U
  56. 配合使用此选项。
  57.  
  58. 注意:如果希望锁定账户(不仅仅是通过密码访问),您也需要设置 EXPIRE_DATE 1
  59.  
  60. -m, --move-home
  61. 将用户的主目录移动到新位置。
  62.  
  63. 这个选项只有和 -d (或 --home) 选项组合使用时才有效。
  64.  
  65. usermod 会改写文件的属主并复制模式、ACL 和扩展属性,但是稍后也可能需要手动修改。
  66.  
  67. -o, --non-unique
  68. 使用 -u 选项时,可以将用户 ID 改为非唯一的值。
  69.  
  70. -p, --password PASSWORD
  71. 已经加密过的密码,就像 crypt(3) 返回的那样。
  72.  
  73.  
  74. 密码将会写到本地的 /etc/passwd /etc/shadow 文件。这可能会与您的机器有所不同,这根据
  75. PAM 配置中的密码数据库配置而定。
  76.  
  77. 您应该确保密码符合系统的密码政策。
  78.  
  79. -R, --root CHROOT_DIR
  80. Apply changes in the CHROOT_DIR directory and use the configuration files from the
  81. CHROOT_DIR directory.
  82.  
  83. -s, --shell SHELL
  84. 用户的新登录 shell 的名称。将此字段设置为空会让系统选择默认的登录 shell
  85.  
  86. -u, --uid UID
  87. 用户 ID 的新数值。
  88.  
  89. 这个值必须是唯一的,除非使用了 -o 选项,必须是非负值。
  90.  
  91. 用户的邮箱,用户主目录中属于此用户的文件的属主 ID 也将自动更改。
  92.  
  93. 用户主目录之外文件所有权必须手动修复。
  94.  
  95. 不会对 /etc/login.defs 中的 UID_MIN, UID_MAX, SYS_UID_MIN SYS_UID_MAX 进行检查。
  96.  
  97. -U, --unlock
  98. 解锁用户的密码。这将移除加密的密码之前的“!”。您可以将此选项和 -p -L 配合使用。
  99.  
  100. 注意:如果您希望解锁账户(不只是使用密码访问),您也应该设置 EXPIRE_DATE (例如设置为
  101. 99999,或者 /etc/default/useradd 中的 EXPIRE 值)。
  102.  
  103. -v, --add-subuids FIRST-LAST
  104. Add a range of subordinate uids to the user's account.
  105.  
  106. This option may be specified multiple times to add multiple ranges to a users account.
  107.  
  108. No checks will be performed with regard to SUB_UID_MIN, SUB_UID_MAX, or SUB_UID_COUNT
  109. from /etc/login.defs.
  110.  
  111. -V, --del-subuids FIRST-LAST
  112. Remove a range of subordinate uids from the user's account.
  113.  
  114. This option may be specified multiple times to remove multiple ranges to a users
  115. account. When both --del-subuids and --add-subuids are specified, the removal of all
  116. subordinate uid ranges happens before any subordinate uid range is added.
  117.  
  118. No checks will be performed with regard to SUB_UID_MIN, SUB_UID_MAX, or SUB_UID_COUNT
  119. from /etc/login.defs.
  120.  
  121. -w, --add-subgids FIRST-LAST
  122. Add a range of subordinate gids to the user's account.
  123.  
  124. This option may be specified multiple times to add multiple ranges to a users account.
  125.  
  126. No checks will be performed with regard to SUB_GID_MIN, SUB_GID_MAX, or SUB_GID_COUNT
  127. from /etc/login.defs.
  128.  
  129. -W, --del-subgids FIRST-LAST
  130. Remove a range of subordinate gids from the user's account.
  131.  
  132. This option may be specified multiple times to remove multiple ranges to a users
  133. account. When both --del-subgids and --add-subgids are specified, the removal of all
  134. subordinate gid ranges happens before any subordinate gid range is added.
  135.  
  136. No checks will be performed with regard to SUB_GID_MIN, SUB_GID_MAX, or SUB_GID_COUNT
  137. from /etc/login.defs.
  138.  
  139. -Z, --selinux-user SEUSER
  140. 用户登陆的 SELinux 用户。
  141.  
  142. 空的 SEUSER 将移除用户 LOGIN SELinux 用户映射(如果有)。
  143.  
  144. CAVEATS
  145. You must make certain that the named user is not executing any processes when this command
  146. is being executed if the user's numerical user ID, the user's name, or the user's home
  147. directory is being changed. usermod checks this on Linux. On other platforms it only uses
  148. utmp to check if the user is logged in.
  149.  
  150. 您必须手动更改 crontab 文件或 at 作业的属主。
  151.  
  152. 您必须更改 NIS 服务器上的 NIS 相关内容。
  153.  

  154. 在 /etc/login.defs 中有如下配置变量,可以用来更改此工具的行为:
  155.  
  156. MAIL_DIR (string)
  157. 邮箱目录。修改或删除用户账户时需要处理邮箱,如果没有指定,将使用编译时指定的默认值。
  158.  
  159. MAIL_FILE (string)
  160. 定义用户邮箱文件的位置(相对于主目录)。
  161.  
  162. MAIL_DIR and MAIL_FILE 变量由 useradd,usermod 和 userdel 用于创建、移动或删除用户邮箱。
  163.  
  164. MAX_MEMBERS_PER_GROUP (number)
  165. 每个组条目的最大成员数。达到最大值时,在 /etc/group 开始一个新条目(行)(使用同样的名
  166. 称,同样的密码,同样的 GID)。
  167.  
  168. 默认值是 0,意味着组中的成员数没有限制。
  169.  
  170. 此功能(分割组)允许限制组文件中的行长度。这对于确保 NIS 组的行比长于 1024 字符。
  171.  
  172. 如果要强制这个限制,可以使用 25。
  173.  
  174. 注意:分割组可能不受所有工具的支持(甚至在 Shadow 工具集中)。您不应该使用这个变量,除非真
  175. 的需要。
  176.  
  177. SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT (number)
  178. If /etc/subuid exists, the commands useradd and newusers (unless the user already have
  179. subordinate group IDs) allocate SUB_GID_COUNT unused group IDs from the range
  180. SUB_GID_MIN to SUB_GID_MAX for each new user.
  181.  
  182. The default values for SUB_GID_MIN, SUB_GID_MAX, SUB_GID_COUNT are respectively 100000,
  183. 600100000 and 10000.
  184.  
  185. SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number)
  186. If /etc/subuid exists, the commands useradd and newusers (unless the user already have
  187. subordinate user IDs) allocate SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN
  188. to SUB_UID_MAX for each new user.
  189.  
  190. The default values for SUB_UID_MIN, SUB_UID_MAX, SUB_UID_COUNT are respectively 100000,
  191. 600100000 and 10000.
  192.  

  193. /etc/group
  194. 组账户信息。
  195.  
  196. /etc/gshadow
  197. 安全组账户信息。
  198.  
  199. /etc/login.defs
  200. Shadow 密码套件配置。
  201.  
  202. /etc/passwd
  203. 用户账户信息。
  204.  
  205. /etc/shadow
  206. 安全用户账户信息。
  207.  
  208. /etc/subgid
  209. Per user subordinate group IDs.
  210.  
  211. /etc/subuid
  212. Per user subordinate user IDs.
  213.  

  214. chfn(1), chsh(1), passwd(1), crypt(3), gpasswd(8), groupadd(8), groupdel(8), groupmod(8),
  215. login.defs(5), subgid(5), subuid(5), useradd(8), userdel(8).
  216.  
  217. shadow-utils 4.5 2018-01-25 USERMOD(8)

添加用户username到sudo组的更多相关文章

  1. Ubuntu新建用户并加入SUDO组

    Ubuntu新建用户并加入SUDO组 新建用户: adduser xxxx 加入用户组: usermod -aG sudo username

  2. CoreOS 添加用户并赋予sudo权限

    使用root账号登录CoreOS username 为你要添加的用户登录名 添加用户到root组 useradd -g rot username 添加 sudo 权限 visudo -f /etc/s ...

  3. RHEL7 添加用户,含sudo权限

    1.添加普通用户[root@server ~]# useradd book //添加一个名为book的用户 [root@server ~]# passwd book //修改密码 Changing p ...

  4. CentOS添加用户并加入sudo权限

    # 新增用户 useradd username # 设置密码 passwd username # 加入sudo ## 打开sudo配置文件 visudo ## 找到下面这两行,并在下面新增红色部分 # ...

  5. CentOS添加用户及赋予sudo权限

    在CentOS下添加一个用户假设用户名:username 密码:userpwd 新建用户: adduser username 修改密码: passwd username 根据提示重复输入两遍userp ...

  6. linux下添加用户到sudo组

    #查看当前用户所属组groups #查看指定用户hiuser所属组groups hiuser #添加用户hiuser到sudo组sudo usermod -G sudo hiuser

  7. 转:ubuntu添加用户adduser,并给予sudo权限

    ubuntu添加用户adduser,并给予sudo权限 如何创建ubuntu新用户? 首先打开终端,输入:sudo adduser username正在添加用户“username”... 正在添加新组 ...

  8. 添加用户到 sudo

    sudo 简介: 在 Linux 中系统管理员可以通过 sudo 实用程序让用户或组能够作为另一个用户运行命令.换句话说,可以分派命令特权,而不需要另一个用户的密码.root 用户通过在 /etc/s ...

  9. Linux 将一般的用户加入sudo组is_not_in_the_sudoers_file._This_incident_will_be_reported解决方法

      在一般用户下执行sudo命令提示xxx is not in the sudoers file. This incident will be reported.解决方法:        $where ...

随机推荐

  1. Netty权威指南之NIO通信模型

    NIO简介:与Socket和ServerSocket类相对应,NIO提供了SocketChannel和ServerSocketChannel两种不同的套接字通道实现,这两种新通道都支持阻塞和非阻塞两种 ...

  2. 使用dshow捕获摄像头图像

    #include "stdafx.h" #include <DShow.h> #include <Guiddef.h> #include <strmi ...

  3. RF根据单个/多个output文件重新生成log和report文件

    场景1:根据单个output文件重新生成log和report文件命令: rebot -d 日志和报告文件保存路径  output.xml文件 场景2:合并两个不同路径下的output文件并生成新的lo ...

  4. Selenium 管理 Cookies

    使用 Selenium ,还可以方便地对 Cookies 进行操作,例如获取.添加 .删除 Cookies 等 from selenium import webdriver browser = web ...

  5. 更新npm至最新版本

    npm install npm@latest –g 或者@ 符号后面直接添加你想更新到的版本号

  6. 【Java知识点专项练习】之 接口和抽象类的区别

    接口和抽象类的区别 接口(interface)可以说成是抽象类的一种特例,接口中的所有方法都必须是抽象的.接口中的方法定义默认为public abstract类型,接口中的成员变量类型默认为publi ...

  7. Openstack Nova network

    对于安装设置来说,Openstack就剩下网络这个地方比较复杂. 现在比较喜欢看图 整理了一下网络的资料 1:Nova 网络HA http://unchainyourbrain.com/opensta ...

  8. Linux系统启动内幕

    经过对Linux系统有了一定了解和熟悉后,想对其更深层次的东西做进一步探究.这当中就包括系统的启动流程.文件系统的组成结构.基于动态库和静态库的程序在执行时的异同.协议栈的架构和原理.驱动程序的机制等 ...

  9. 23种设计模式之备忘录模式(Memento)

    备忘录模式确保在不破坏封装的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态,这样可以在以后将对象恢复到原先保存的状态.备忘录模式提供了一种状态恢复的实现机制,使得用户可以方便地回到一个特定 ...

  10. ps软件使用的问题解决记录

    1.PS的字体颜色改变不了的解决方法,添加字体的时颜色无论怎么选都只能有[黑.白.灰]三种颜色,     问题的原因:图像的模式选择了灰度(G)     解决方法:图像-->模式-->RG ...