用户组
当用户登录成功时,系统会自动分配令牌token给用户,token会记录权限
用户类型
管理员用户 root
普通用户
系统用户/程序用户
useradd -u 制定uid
useradd -g 基本组/附加组
useradd -G 基本组/附加组 useradd -g user1 -G user3 text 制定组是user1 附加组user3 用户是 text
useradd -s /sbin/nologin -M 123 创建没有家目录的123禁止登陆
useradd -r mysql 创建1000以内的系统用户
useradd -d 指定家目录 useradd -d /mnt/user1 user2
useradd -M 不创建家目录
修改用户信息
usermod
-u uid
-g 组名称
-G 组名称
-s shell名称
-a 继续添加
[root@localhost tmp]# gpasswd -a tom1 sb
正在将用户“tom1”加入到“sb”组中
[root@localhost tmp]# id tom1
uid=1003(tom1) gid=1003(tom1) 组=1003(tom1),1002(sb)
[root@localhost tmp]# usermod -g tom2 sb
usermod:用户“sb”不存在
[root@localhost tmp]# usermod -g sb tom2
[root@localhost tmp]# id ton2
id: ton2: no such user
[root@localhost tmp]# id tom2
uid=1004(tom2) gid=1002(sb) 组=1002(sb)
[root@localhost tmp]# usermod -aG tom2 tom2
[root@localhost tmp]# id tom2
uid=1004(tom2) gid=1002(sb) 组=1002(sb),1004(tom2)
修改组名 groupmod -n newgroup wang
删除组成员 gpasswd -d tom1 sb
[root@localhost tmp]# id tom1
uid=1003(tom1) gid=1003(tom1) 组=1003(tom1),1002(sb)
[root@localhost tmp]# gpasswd -d tom1 sb
正在将用户“tom1”从“sb”组中删除
[root@localhost tmp]# id tom1
uid=1003(tom1) gid=1003(tom1) 组=1003(tom1)
----------------------------------------------------------------------------------------------------------
账户默认信息
[root@rocky ~]# cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
######################################################################################################
[root@rocky ~]# su - tom1 -c 'touch tom1' 切用户执行命令
[root@rocky ~]# ll /home/tom1/
total 0
-rw-rw-r-- 1 tom1 tom1 0 Jul 14 05:15 tom1