xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Linux group & user & password All In One

Linux group & user & password All In One

  • groupadd

  • groupmod

  • groupdel

  • useradd

  • usermod

  • userdel

文件

/etc/passwd 用户账户信息

/etc/shadow 安全用户账户信息

/etc/group 账户信息

/etc/gshadow 安全组账户信息

用户组

groupadd

eric@rpi4b:~ $ groupadd -h
用法:groupadd [选项] 组

选项:
  -f, --force                   如果组已经存在则成功退出
                                并且如果 GID 已被使用则取消 -g
  -g, --gid GID                 为新组使用 GID
  -h, --help                    显示此帮助信息并退出
  -K, --key KEY=VALUE           不使用 /etc/login.defs 中的默认值
  -o, --non-unique              允许创建有重复 GID 的组
  -p, --password PASSWORD       为新组使用此加密过的密码
  -r, --system                  创建一个系统账户
  -R, --root CHROOT_DIR         chroot 到的目录
  -P, --prefix PREFIX_DIR       directory prefix

groupdel

groupmod

用户

useradd

eric@rpi4b:~ $ useradd -h
用法:useradd [选项] 登录名
      useradd -D
      useradd -D [选项]

选项:
      --badnames                do not check for bad names
  -b, --base-dir BASE_DIR       新账户的主目录的基目录
      --btrfs-subvolume-home    use BTRFS subvolume for home directory
  -c, --comment COMMENT         新账户的 GECOS 字段
  -d, --home-dir HOME_DIR       新账户的主目录
  -D, --defaults                显示或更改默认的 useradd 配置
  -e, --expiredate EXPIRE_DATE  新账户的过期日期
  -f, --inactive INACTIVE       新账户的密码不活动期
  -g, --gid GROUP               新账户主组的名称或 ID
  -G, --groups GROUPS           新账户的附加组列表
  -h, --help                    显示此帮助信息并退出
  -k, --skel SKEL_DIR           使用此目录作为骨架目录
  -K, --key KEY=VALUE           不使用 /etc/login.defs 中的默认值
  -l, --no-log-init             不要将此用户添加到最近登录和登录失败数据库
  -m, --create-home             创建用户的主目录
  -M, --no-create-home          不创建用户的主目录
  -N, --no-user-group           不创建同名的组
  -o, --non-unique              允许使用重复的 UID 创建用户
  -p, --password PASSWORD       加密后的新账户密码
  -r, --system                  创建一个系统账户
  -R, --root CHROOT_DIR         chroot 到的目录
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL             新账户的登录 shell
  -u, --uid UID                 新账户的用户 ID
  -U, --user-group              创建与用户同名的组
  -Z, --selinux-user SEUSER     为 SELinux 用户映射使用指定 SEUSER

passwd

eric@rpi4b:~ $ passwd -h
用法:passwd [选项] [登录名]

选项:
  -a, --all                     报告所有帐户的密码状态
  -d, --delete                  删除指定帐户的密码
  -e, --expire                  强制使指定帐户的密码过期
  -h, --help                    显示此帮助信息并退出
  -k, --keep-tokens             仅在过期后修改密码
  -i, --inactive INACTIVE       密码过期后设置密码不活动为 INACTIVE
  -l, --lock                    锁定指定的帐户
  -n, --mindays MIN_DAYS        设置到下次修改密码所须等待的最短天数
                                为 MIN_DAYS
  -q, --quiet                   安静模式
  -r, --repository REPOSITORY   在 REPOSITORY 库中改变密码
  -R, --root CHROOT_DIR         chroot 到的目录
  -S, --status                  报告指定帐户密码的状态
  -u, --unlock                  解锁被指定帐户
  -w, --warndays WARN_DAYS      设置过期警告天数为 WARN_DAYS
  -x, --maxdays MAX_DAYS        设置到下次修改密码所须等待的最多天数
                                为 MAX_DAYS

gpasswd

eric@rpi4b:~/Desktop $ gpasswd -h
用法:gpasswd [选项] 组

选项:
  -a, --add USER                向组 GROUP 中添加用户 USER
  -d, --delete USER             从组 GROUP 中添加或删除用户
  -h, --help                    显示此帮助信息并退出
  -Q, --root CHROOT_DIR         要 chroot 进的目录
  -r, --remove-password         移除组 GROUP 的密码
  -R, --restrict                向其成员限制访问组 GROUP
  -M, --members USER,...        设置组 GROUP 的成员列表
  -A, --administrators ADMIN,...
                                设置组的管理员列表
除非使用 -A 或 -M 选项,不能结合使用这些选项。

newgrp

eric@rpi4b:~/Desktop $ newgrp -h
用法:newgrp [-] [组]

$ man newgrp

NEWGRP(1)                              用户命令                             NEWGRP(1)

名称
       newgrp - 登录到一个新组

大纲
       newgrp [-] [group]

描述
       The newgrp command is used to change the current group ID during a login
       session. If the optional - flag is given, the user's environment will be
       reinitialized as though the user had logged in, otherwise the current
       environment, including current working directory, remains unchanged.

       newgrp changes the current real group ID to the named group, or to the default
       group listed in /etc/passwd if no group name is given.  newgrp also tries to
       add the group to the user groupset. If not root, the user will be prompted for
       a password if she does not have a password (in /etc/shadow if this user has an
       entry in the shadowed password file, or in /etc/passwd otherwise) and the
       group does, or if the user is not listed as a member and the group has a
       password. The user will be denied access if the group password is empty and
       the user is not listed as a member.

       If there is an entry for this group in /etc/gshadow, then the list of members
       and the password of this group will be taken from this file, otherwise, the
       entry in /etc/group is considered.

配置文件
       The following configuration variables in /etc/login.defs change the behavior
       of this tool:

       SYSLOG_SG_ENAB (boolean)
           Enable "syslog" logging of sg activity.

文件
       /etc/passwd
           用户账户信息。

       /etc/shadow
           安全用户账户信息。

       /etc/group
           组账户信息。

       /etc/gshadow
           安全组账户信息。

参见
       id(1), login(1), su(1), sg(1), gpasswd(1), group(5), gshadow(5).

shadow-utils 4.8.1                    2020-02-07                            NEWGRP(1)

shadow


demos

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-07-30 23:33  xgqfrms  阅读(10)  评论(3编辑  收藏  举报