useradd常用命令

ll /usr/sbin
过滤下
[root@iZbp1cr1sgiqi6r6qlygx9Z tmp]# ll /usr/sbin | grep user
lrwxrwxrwx. 1 root root 7 Sep 14 2020 adduser -> useradd
-rwxr-xr-x 1 root root 33112 Aug 9 2019 fuser
-rwxr-xr-x. 1 root root 15832 Apr 13 2018 lnewusers
-rwxr-xr-x. 1 root root 15752 Apr 13 2018 luseradd
-rwxr-xr-x. 1 root root 11576 Apr 13 2018 luserdel
-rwxr-xr-x. 1 root root 19896 Apr 13 2018 lusermod
-rwxr-xr-x. 1 root root 95688 Aug 9 2019 newusers
-rwxr-xr-x. 1 root root 32984 Apr 1 2020 runuser
-rwxr-xr-x. 1 root root 19720 Apr 11 2018 sasldblistusers2
-rwxr-xr-x. 1 root root 137616 Aug 9 2019 useradd
-rwxr-xr-x. 1 root root 95744 Aug 9 2019 userdel
-rwxr-xr-x. 1 root root 133456 Aug 9 2019 usermod
-rwsr-xr-x. 1 root root 11296 Apr 1 2020 usernetctl

1.
useradd text1
cat /etc/passwd
text1:x:1002:1002::/home/text1:/bin/bash
登入超级系统,设置密码
passwd text1
Aa123456
[root@iZbp1cr1sgiqi6r6qlygx9Z tmp]# openssl passwd -1 “Aa123456” 1(MD5)
$1$b2mulfX5$SfpWwNNArXa4DuQoSIoju0(MD5加密算法字符串)

useradd -p ‘$1$b2mulfX5$SfpWwNNArXa4DuQoSIoju0’ text2
cat /etc/passwd
text2:x:1003:1003::/home/text2:/bin/bash

2.

/home/text1
home为基础目录
修改基础目录
useradd -b(base directory)
useradd -b /tmp text3
text3:x:1004:1004::/tmp/text3:/bin/bash
[root@iZbp1cr1sgiqi6r6qlygx9Z text1]# cat /etc/passwd | grep text3
text3:x:1004:1004::/tmp/text3:/bin/bash

-d参数home directory 
useradd -d /tmp/hello text5
text5:x:1006:1006::/tmp/hello:/bin/bash
-c参数,备注
[root@iZbp1cr1sgiqi6r6qlygx9Z text1]# useradd -c “ceshi” text6
[root@iZbp1cr1sgiqi6r6qlygx9Z text1]# cat /etc/passwd | grep text6
text6:x:1007:1007:ceshi:/home/text6:/bin/bash
-g主组
-G附属组
useradd -G root,多组用,隔开
useradd -G root.其他组 text7
cat /etc/group

mysql:x:27:
haier:x:1000:
uuui:x:1001:
text1:x:1002:
text2:x:1003:
text3:x:1004:
text4:x:1005:
text5:x:1006:
text6:x:1007:

cat /etc/group | grep -e root-e 其他组

useradd -s /bin/sh text8
text8:x:1008:1008::/home/text8:/bin/sh

-D参数(default)
[root@iZbp1cr1sgiqi6r6qlygx9Z text1]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

[root@iZbp1cr1sgiqi6r6qlygx9Z text1]# useradd -D -b /tmp(之后创建的所有用户只要不指定,家目录都会建在/tmp下)
[root@iZbp1cr1sgiqi6r6qlygx9Z text1]# useradd -D
GROUP=100
HOME=/tmp
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

-r参数
创建系统用户
useradd -r text9
-m自动创建用户登入目录
-M 创建没有主目录的用户目录

图片[1]-useradd常用命令-晴天生活分享日志
------本页内容已结束,喜欢请分享------

感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容