Linux常用命令二(用户与组)

Linux常用命令(二)
一、Useradd
用法:useradd [选项] 用户名
作用:添加用户
参数:-b 新用户主目录的父目录
-c 注释信息
-d 新用户的主目录
-D 显示和改变用户配置
-e 用户账号的失效日期
-f 密码失效后,账号的查封期限
-g 组标志号
-G 用户所属各组
-h 帮助文档
-m 创建Home
-M 不创建Home
-N 不创建组
-o 创建多个用户同一个UID
-p 设置密码
-r 创建系统用户
-R 改变root目录
-u 设置UID
-U 创建一个和用户同名的组
useradd帮助文档
Usage: useradd [options] LOGIN
useradd -Dgid GROUP
useradd -D [options]

Options:
-b, –base-dir BASE_DIR base directory for the home directory of the
new account
-c, –comment COMMENT GECOS field of the new account
-d, –home-dir HOME_DIR home directory of the new account
-D, –defaults print or change default useradd configuration
-e, –expiredate EXPIRE_DATE expiration date of the new account
-f, –inactive INACTIVE password inactivity period of the new account
-g, –gid GROUP name or ID of the primary group of the new
account
-G, –groups GROUPS list of supplementary groups of the new
account
-h, –help display this help message and exit
-k, –skel SKEL_DIR use this alternative skeleton directory
-K, –key KEY=VALUE override /etc/login.defs defaults
-l, –no-log-init do not add the user to the lastlog and
faillog databases
-m, –create-home create the user’s home directory
-M, –no-create-home do not create the user’s home directory
-N, –no-user-group do not create a group with the same name as
the user
-o, –non-unique allow to create users with duplicate
(non-unique) UID
-p, –password PASSWORD encrypted password of the new account
-r, –system create a system account
-R, –root CHROOT_DIR directory to chroot into
-s, –shell SHELL login shell of the new account
-u, –uid UID user ID of the new account
-U, –user-group create a group with the same name as the user
-Z, –selinux-user SEUSER use a specific SEUSER for the SELinux user mapping

二、userdel
用法:userdel [选项] 用户名
作用:删除用户
参数:-f 强制移除文件,即使不被用户拥有
-h 显示帮助文档
-r 移除主目录
-R 改变root目录
userdel帮助文档
Usage: userdel [options] LOGIN

Options:
-f, –force force removal of files,
even if not owned by user
-h, –help display this help message and exit
-r, –remove remove home directory and mail spool
-R, –root CHROOT_DIR directory to chroot into
-Z, –selinux-user remove any SELinux user mapping for the user
三、usermod
用法:usermod [选项] 用户名
作用:修改用户
参数:-c 修改注释信息
-d 修改home目录
-e 修改用户失效日期
-f 修改用户失效后的查封期限
-g 修改所属组
-G 修改多组
-a 将用户添加到组中
-h 显示帮助文档
-l 修改用户名
-L 锁定用户密码
-m 修改家目录
-o 允许使用多个UID
-R 修改Root目录
-s 修改shell
-u 修改UID
-U 解锁用户密码
usermod帮助文档
Usage: usermod [options] LOGIN

Options:
-c, –comment COMMENT new value of the GECOS field
-d, –home HOME_DIR new home directory for the user account
-e, –expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, –inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, –gid GROUP force use GROUP as new primary group
-G, –groups GROUPS new list of supplementary GROUPS
-a, –append append the user to the supplemental GROUPS
mentioned by the -G option without removing
him/her from other groups
-h, –help display this help message and exit
-l, –login NEW_LOGIN new value of the login name
-L, –lock lock the user account
-m, –move-home move contents of the home directory to the
new location (use only with -d)
-o, –non-unique allow using duplicate (non-unique) UID
-p, –password PASSWORD use encrypted password for the new password
-R, –root CHROOT_DIR directory to chroot into
-s, –shell SHELL new login shell for the user account
-u, –uid UID new UID for the user account
-U, –unlock unlock the user account
-v, –add-subuids FIRST-LAST add range of subordinate uids
-V, –del-subuids FIRST-LAST remvoe range of subordinate uids
-w, –add-subgids FIRST-LAST add range of subordinate gids
-W, –del-subgids FIRST-LAST remvoe range of subordinate gids
-Z, –selinux-user SEUSER new SELinux user mapping for the user account

四、groupadd
用法:groupadd [选项] 组名
作用:创建组
参数:-f 组存在时安全退出
-g 设置GID
-h 显示帮助文档
-o 不同用户相同组名
-p 密码
-r 创建系统用户
-R 改变root目录
groupadd帮助文档
Usage: groupadd [options] GROUP

Options:
-f, –force exit successfully if the group already exists,
and cancel -g if the GID is already used
-g, –gid GID use GID for the new group
-h, –help display this help message and exit
-K, –key KEY=VALUE override /etc/login.defs defaults
-o, –non-unique allow to create groups with duplicate
(non-unique) GID
-p, –password PASSWORD use this encrypted password for the new group
-r, –system create a system account
-R, –root CHROOT_DIR directory to chroot into

五、groupdel
用法:groupdel [选项] 组名
作用:删除组
参数:-h 显示帮助文档
-R 改变root目录
groupdel帮助文档
Usage: groupdel [options] GROUP

Options:
-h, –help display this help message and exit
-R, –root CHROOT_DIR directory to chroot into

六、groupmod
用法:groupmod [选项] 组名
作用:修改组
参数:-g 改变GID
-h 显示帮助文档
-n 更改组名
-o 允许使用不同ID
-p 修改密码
-R 改变Root目录
groupmod帮助文档
Usage: groupmod [options] GROUP

Options:
-g, –gid GID change the group ID to GID
-h, –help display this help message and exit
-n, –new-name NEW_GROUP change the name to NEW_GROUP
-o, –non-unique allow to use a duplicate (non-unique) GID
-p, –password PASSWORD change the password to this (encrypted)
PASSWORD
-R, –root CHROOT_DIR directory to chroot into

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值