添加用户username到sudo组
添加用户username到sudo组:
- sudo usermod -aG sudo username
- USERMOD(8) 系统管理命令 USERMOD(8)
- 名
- usermod - 修改一个用户账户
- 大
- usermod [选项] 登录
- 描
- usermod 修改系统账户文件和在命令行上指定的相关更改。
- 选
- usermod 可以接受的选项有:
- -a, --append
- 将用户添加到附加组。只能和 -G 选项一起使用。
- -c, --comment COMMENT
- 用户密码文件中注释字段的新值。通常使用 chfn(1) 工具对其进行修改。
- -d, --home HOME_DIR
- 用户的新登录目录。
- 如果给了 -m 选项,当前主目录的内容将会移动到新主目录中,如果不存在,则创建。
- -e, --expiredate EXPIRE_DATE
- 用户账户将被禁用的日期。日期以 YYYY-MM-DD 格式指定。
- 空 EXPIRE_DATE 参数将禁用账户过期。
- 此选项需要一个 /etc/passwd 文件。如果没有,将会创建一条 /etc/shadow 项目。
- -f, --inactive INACTIVE
- 密码过期之后,账户被彻底禁用之前的天数。
- 0 表示密码过期时,立即禁用账户;-1 表示不使用这个功能。
- 此选项需要一个 /etc/passwd 文件。如果没有,将会创建一条 /etc/shadow 项目。
- -g, --gid GROUP
- 用户的新初始登录组的组名或数字代号。此组必须存在。
- 用户主目录中,属于原来的主组的文件将转交新组所有。
- 主目录之外的文件所属的组必须手动修改。
- -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
- 用户还属于的附加组列表。组之间使用逗号分隔,没有空格。这些组需要遵守和 -g 选项中给的组同
- 样的限制。
- 如果用户当前是一个组的成员,而这个组没有列在这里,用户将被从那个组里便删除。这个行为可以
- 通过 -a 选项修改,这使用户追加到给出的附加组列表中。
- -l, --login NEW_LOGIN
- 用户的名称将会从 LOGIN 修改为 NEW_LOGIN。不会更改别的任何东西。特别是,用户的主目录名和
- 邮件池也需要手动修改以和新登录名对应。
- -L, --lock
- 锁定用户的密码。这会在用户加密的密码之前放置一个“!”,可以快速禁用密码。您可以和 -p 或 -U
- 配合使用此选项。
- 注意:如果希望锁定账户(不仅仅是通过密码访问),您也需要设置 EXPIRE_DATE 为 1。
- -m, --move-home
- 将用户的主目录移动到新位置。
- 这个选项只有和 -d (或 --home) 选项组合使用时才有效。
- usermod 会改写文件的属主并复制模式、ACL 和扩展属性,但是稍后也可能需要手动修改。
- -o, --non-unique
- 使用 -u 选项时,可以将用户 ID 改为非唯一的值。
- -p, --password PASSWORD
- 已经加密过的密码,就像 crypt(3) 返回的那样。
- 注
- 密码将会写到本地的 /etc/passwd 或 /etc/shadow 文件。这可能会与您的机器有所不同,这根据
- PAM 配置中的密码数据库配置而定。
- 您应该确保密码符合系统的密码政策。
- -R, --root CHROOT_DIR
- Apply changes in the CHROOT_DIR directory and use the configuration files from the
- CHROOT_DIR directory.
- -s, --shell SHELL
- 用户的新登录 shell 的名称。将此字段设置为空会让系统选择默认的登录 shell。
- -u, --uid UID
- 用户 ID 的新数值。
- 这个值必须是唯一的,除非使用了 -o 选项,必须是非负值。
- 用户的邮箱,用户主目录中属于此用户的文件的属主 ID 也将自动更改。
- 用户主目录之外文件所有权必须手动修复。
- 不会对 /etc/login.defs 中的 UID_MIN, UID_MAX, SYS_UID_MIN 和 SYS_UID_MAX 进行检查。
- -U, --unlock
- 解锁用户的密码。这将移除加密的密码之前的“!”。您可以将此选项和 -p 或 -L 配合使用。
- 注意:如果您希望解锁账户(不只是使用密码访问),您也应该设置 EXPIRE_DATE (例如设置为
- 99999,或者 /etc/default/useradd 中的 EXPIRE 值)。
- -v, --add-subuids FIRST-LAST
- Add a range of subordinate uids to the user's account.
- This option may be specified multiple times to add multiple ranges to a users account.
- No checks will be performed with regard to SUB_UID_MIN, SUB_UID_MAX, or SUB_UID_COUNT
- from /etc/login.defs.
- -V, --del-subuids FIRST-LAST
- Remove a range of subordinate uids from the user's account.
- This option may be specified multiple times to remove multiple ranges to a users
- account. When both --del-subuids and --add-subuids are specified, the removal of all
- subordinate uid ranges happens before any subordinate uid range is added.
- No checks will be performed with regard to SUB_UID_MIN, SUB_UID_MAX, or SUB_UID_COUNT
- from /etc/login.defs.
- -w, --add-subgids FIRST-LAST
- Add a range of subordinate gids to the user's account.
- This option may be specified multiple times to add multiple ranges to a users account.
- No checks will be performed with regard to SUB_GID_MIN, SUB_GID_MAX, or SUB_GID_COUNT
- from /etc/login.defs.
- -W, --del-subgids FIRST-LAST
- Remove a range of subordinate gids from the user's account.
- This option may be specified multiple times to remove multiple ranges to a users
- account. When both --del-subgids and --add-subgids are specified, the removal of all
- subordinate gid ranges happens before any subordinate gid range is added.
- No checks will be performed with regard to SUB_GID_MIN, SUB_GID_MAX, or SUB_GID_COUNT
- from /etc/login.defs.
- -Z, --selinux-user SEUSER
- 用户登陆的 SELinux 用户。
- 空的 SEUSER 将移除用户 LOGIN 的 SELinux 用户映射(如果有)。
- CAVEATS
- You must make certain that the named user is not executing any processes when this command
- is being executed if the user's numerical user ID, the user's name, or the user's home
- directory is being changed. usermod checks this on Linux. On other platforms it only uses
- utmp to check if the user is logged in.
- 您必须手动更改 crontab 文件或 at 作业的属主。
- 您必须更改 NIS 服务器上的 NIS 相关内容。
- 配
- 在 /etc/login.defs 中有如下配置变量,可以用来更改此工具的行为:
- MAIL_DIR (string)
- 邮箱目录。修改或删除用户账户时需要处理邮箱,如果没有指定,将使用编译时指定的默认值。
- MAIL_FILE (string)
- 定义用户邮箱文件的位置(相对于主目录)。
- MAIL_DIR and MAIL_FILE 变量由 useradd,usermod 和 userdel 用于创建、移动或删除用户邮箱。
- MAX_MEMBERS_PER_GROUP (number)
- 每个组条目的最大成员数。达到最大值时,在 /etc/group 开始一个新条目(行)(使用同样的名
- 称,同样的密码,同样的 GID)。
- 默认值是 0,意味着组中的成员数没有限制。
- 此功能(分割组)允许限制组文件中的行长度。这对于确保 NIS 组的行比长于 1024 字符。
- 如果要强制这个限制,可以使用 25。
- 注意:分割组可能不受所有工具的支持(甚至在 Shadow 工具集中)。您不应该使用这个变量,除非真
- 的需要。
- SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT (number)
- If /etc/subuid exists, the commands useradd and newusers (unless the user already have
- subordinate group IDs) allocate SUB_GID_COUNT unused group IDs from the range
- SUB_GID_MIN to SUB_GID_MAX for each new user.
- The default values for SUB_GID_MIN, SUB_GID_MAX, SUB_GID_COUNT are respectively 100000,
- 600100000 and 10000.
- SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number)
- If /etc/subuid exists, the commands useradd and newusers (unless the user already have
- subordinate user IDs) allocate SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN
- to SUB_UID_MAX for each new user.
- The default values for SUB_UID_MIN, SUB_UID_MAX, SUB_UID_COUNT are respectively 100000,
- 600100000 and 10000.
- 文
- /etc/group
- 组账户信息。
- /etc/gshadow
- 安全组账户信息。
- /etc/login.defs
- Shadow 密码套件配置。
- /etc/passwd
- 用户账户信息。
- /etc/shadow
- 安全用户账户信息。
- /etc/subgid
- Per user subordinate group IDs.
- /etc/subuid
- Per user subordinate user IDs.
- 参
- chfn(1), chsh(1), passwd(1), crypt(3), gpasswd(8), groupadd(8), groupdel(8), groupmod(8),
- login.defs(5), subgid(5), subuid(5), useradd(8), userdel(8).
- shadow-utils 4.5 2018-01-25 USERMOD(8)
添加用户username到sudo组的更多相关文章
- Ubuntu新建用户并加入SUDO组
Ubuntu新建用户并加入SUDO组 新建用户: adduser xxxx 加入用户组: usermod -aG sudo username
- CoreOS 添加用户并赋予sudo权限
使用root账号登录CoreOS username 为你要添加的用户登录名 添加用户到root组 useradd -g rot username 添加 sudo 权限 visudo -f /etc/s ...
- RHEL7 添加用户,含sudo权限
1.添加普通用户[root@server ~]# useradd book //添加一个名为book的用户 [root@server ~]# passwd book //修改密码 Changing p ...
- CentOS添加用户并加入sudo权限
# 新增用户 useradd username # 设置密码 passwd username # 加入sudo ## 打开sudo配置文件 visudo ## 找到下面这两行,并在下面新增红色部分 # ...
- CentOS添加用户及赋予sudo权限
在CentOS下添加一个用户假设用户名:username 密码:userpwd 新建用户: adduser username 修改密码: passwd username 根据提示重复输入两遍userp ...
- linux下添加用户到sudo组
#查看当前用户所属组groups #查看指定用户hiuser所属组groups hiuser #添加用户hiuser到sudo组sudo usermod -G sudo hiuser
- 转:ubuntu添加用户adduser,并给予sudo权限
ubuntu添加用户adduser,并给予sudo权限 如何创建ubuntu新用户? 首先打开终端,输入:sudo adduser username正在添加用户“username”... 正在添加新组 ...
- 添加用户到 sudo
sudo 简介: 在 Linux 中系统管理员可以通过 sudo 实用程序让用户或组能够作为另一个用户运行命令.换句话说,可以分派命令特权,而不需要另一个用户的密码.root 用户通过在 /etc/s ...
- 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 ...
随机推荐
- Netty权威指南之NIO通信模型
NIO简介:与Socket和ServerSocket类相对应,NIO提供了SocketChannel和ServerSocketChannel两种不同的套接字通道实现,这两种新通道都支持阻塞和非阻塞两种 ...
- 使用dshow捕获摄像头图像
#include "stdafx.h" #include <DShow.h> #include <Guiddef.h> #include <strmi ...
- RF根据单个/多个output文件重新生成log和report文件
场景1:根据单个output文件重新生成log和report文件命令: rebot -d 日志和报告文件保存路径 output.xml文件 场景2:合并两个不同路径下的output文件并生成新的lo ...
- Selenium 管理 Cookies
使用 Selenium ,还可以方便地对 Cookies 进行操作,例如获取.添加 .删除 Cookies 等 from selenium import webdriver browser = web ...
- 更新npm至最新版本
npm install npm@latest –g 或者@ 符号后面直接添加你想更新到的版本号
- 【Java知识点专项练习】之 接口和抽象类的区别
接口和抽象类的区别 接口(interface)可以说成是抽象类的一种特例,接口中的所有方法都必须是抽象的.接口中的方法定义默认为public abstract类型,接口中的成员变量类型默认为publi ...
- Openstack Nova network
对于安装设置来说,Openstack就剩下网络这个地方比较复杂. 现在比较喜欢看图 整理了一下网络的资料 1:Nova 网络HA http://unchainyourbrain.com/opensta ...
- Linux系统启动内幕
经过对Linux系统有了一定了解和熟悉后,想对其更深层次的东西做进一步探究.这当中就包括系统的启动流程.文件系统的组成结构.基于动态库和静态库的程序在执行时的异同.协议栈的架构和原理.驱动程序的机制等 ...
- 23种设计模式之备忘录模式(Memento)
备忘录模式确保在不破坏封装的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态,这样可以在以后将对象恢复到原先保存的状态.备忘录模式提供了一种状态恢复的实现机制,使得用户可以方便地回到一个特定 ...
- ps软件使用的问题解决记录
1.PS的字体颜色改变不了的解决方法,添加字体的时颜色无论怎么选都只能有[黑.白.灰]三种颜色, 问题的原因:图像的模式选择了灰度(G) 解决方法:图像-->模式-->RG ...