grep redis /etc/passwd
-
redis[用户名]:x[密码占位符]:986[uid]:980[gid]:Redis Database Server[注释信息]:/var/lib/redis[家目录]:/sbin/nologin[不能登录]
grep 'root' /etc/shadow
-
root[用户名]:04Ru0f1ABltJQ[加密后的密码]::0:99999:7:::
groups root 「 查询用户」
-
root[用户名] : root[用户组]
gpasswd -a thomas root 「 将 thomas 加入到 root 组」
groups thomas
-
thomas : thomas root wheel[三个用户组]
gpasswd -d thomas root 「 将 thomas 从 root 组删除」
groups thomas
-
thomas : thomas wheel
gpasswd --help
-
-a, --add USER add USER to GROUP
-
-d, --delete USER remove USER from GROUP
useradd -D 「 默认值」
-
vim /etc/default/useradd 「 修改默认值」
useradd -c 'i am bob' -s /sbin/nologin -d /bob -g root -G thomas -u 10000 bob
-
-c COMMENT
-
-s SHELL
-
-d HOME_DIR
-
-g 主组
-
-G 附属组
-
-u UID
grep 'bob' /etc/passwd
bob:x:10000:0:i am bob:/bob:/sbin/nologin
groups bob
-
bob : root[主组] Thomas[附属组]
su - bob 「 /sbin/nologin 」
This account is currently not available.
usermod -s /bin/bash bob 「 改shell 」
grep bob /etc/passwd
bob:x:10000:0:i am bob:/bob:/bin/bash
su - bob
exit 「 退回root 」
usermod -c '宁国' bob
grep bob /etc/passwd
bob:x:10000:0:宁国:/bob:/bin/bash
usermod -h 「 --help & 用户属性 」
# 密码
passwd bob
passwd -S bob 「--status & 密码状态」
passwd --usage 「 使用场景 」
passwd -d bob 「 --delete & 删密码」
passwd -S bob
bob NP 2020-09-20 0 99999 7 -1 (Empty password.)
echo 123456 | passwd --stdin bob 「 --stdin 标准输入」
Changing password for user bob.
passwd: all authentication tokens updated successfully.
# 自动创建用户和密码(bob1、bob2、bob3)
for i in `seq 1 3` 「 seq 序列号」
do
useradd bob$i
echo 123456 | passwd --stdin bob$i
done
passwd -l bob 「 --lock 锁定密码 & ssh bob@10.211.55.12不能登录 」
passwd -u bob 「--unlock 解锁密码 & ssh bob@10.211.55.12正常登录」
usermod -L bob 「 --lock & 不能登录」
usermod -U bob 「 --unlock & 正常登录」
userdel -r bob3 「 -r 删除家目录 」
chage -E 2020-12-31 bob 「 过期时间 」
chage -m 10 -M 20 -W 7 bob 「 -m 最小使用时间 & -M 最大使用时间 & -W 到期提前警告时间 」
chage -l bob 「 --list 账户信息 」
id bob