CONTENTS
useradd:添加用户
useradd帮助文档:
root:~# useradd -h 用法:useradd [选项] 登录 useradd -D useradd -D [选项] 选项: -b, --base-dir BASE_DIR 新账户的主目录的基目录 -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 到的目录 -s, --shell SHELL 新账户的登录 shell -u, --uid UID 新账户的用户 ID -U, --user-group 创建与用户同名的组 -Z, --selinux-user SEUSER 为 SELinux 用户映射使用指定 SEUSER
useradd使用示例:
root@cstriker1407-ubuntu:~# useradd test1 root@cstriker1407-ubuntu:~# useradd test2 -p passwd2 root@cstriker1407-ubuntu:~# mkdir /home/test3 root@cstriker1407-ubuntu:~# useradd test3 -p passwd3 -d /home/test3
groupadd:添加用户组
帮助文档及示例:
root@cstriker1407-ubuntu:/home/cstriker1407# 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 创建一个系统账户 root@cstriker1407-ubuntu:/home/cstriker1407# groupadd testgroup root@cstriker1407-ubuntu:/home/cstriker1407# useradd test4 -g testgroup
查看用户
root@cstriker1407-ubuntu:/home/cstriker1407# cat /etc/passwd 。。。。。 。。。。。 test1:x:1001:1001::/home/test1:/bin/sh test2:x:1002:1002::/home/test2:/bin/sh test3:x:1003:1003::/home/test3:/bin/sh test4:x:1004:1004::/home/test4:/bin/sh
userdel:删除用户
帮助文档及示例:
root@cstriker1407-ubuntu:/home/cstriker1407# userdel -h 用法:userdel [选项] 登录 选项: -f, --force 即使不属于此用户,也强制删除文件 -h, --help 显示此帮组文件并退出 -r, --remove 删除主目录和邮箱 root@cstriker1407-ubuntu:/home/cstriker1407# userdel -fr test1 userdel:警告:无法删除 /var/mail/test1:没有那个文件或目录 userdel:未找到 test1 的主目录“/home/test1” root@cstriker1407-ubuntu:/home/cstriker1407# userdel -fr test2 userdel:警告:无法删除 /var/mail/test2:没有那个文件或目录 userdel:未找到 test2 的主目录“/home/test2”
查看用户组
root@cstriker1407-ubuntu:/home/cstriker1407# cat /etc/group 。。。。。 testgroup:x:1004:
groupdel:删除用户组
root@cstriker1407-ubuntu:/home/cstriker1407# groupdel 用法:groupdel 组 root@cstriker1407-ubuntu:/home/cstriker1407# groupdel testgroup
发表评论