user
User system is managed by a file, the default root user id is 0,
Description shadow file
encryption algorithm category
numbers behind the $ 6 specifies the encryption algorithm used is sixth, sha512 encryption
Increase user, modified to the same password to view the / etc / shadow file, you can see that although the two strings are the same password, but to see two encrypted strings are not the same in the shadow file, this is because with a plaintext string when generating the encrypted text using an encryption algorithm salt,
/ etc / passwd user database file format Description
Username centos
password new user password is not specified, then after the placeholder placeholder x, x a change password instead of the ciphertext encrypted password
uid user id values 1001
Main group id 1001
Notes information, can be set to an empty
home directory / home directory under the home
default shell
Useradd to add users
Some systems are adduser, view file properties can be found in fact useradd link
`` is the role of the output which adduser as the arguments to the command file
Default add users, it will automatically generate a user group with the same name. And the default with the same uid gid, if other occupants appear, then add 1 based on the original
Uid designated
Specifies the group name
After -g shall be followed by the name of an existing group or group id, or can not create
-G is back with a list, indicating that the user belongs to so many groups
Add User description information
Assign shell procedure when creating a user
View the system currently supported shell
CAT / etc / shalls
[root@yy ~]# cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
Specify the home directory path
Before specifying a path, you need to confirm the destination path is empty, or can not create, and does not replicate user profiles from the environment into the skel
查看当前useradd的默认参数配置
create_mall_spool 默认会在 /var/spool/mail/下创建一个和用户名同名的文件夹,用来接收邮件信息
修改默认配置项,以后使用useradd的时候不指定参数就按照默认参数进行创建
修改的结果保存在 /etc/default/useradd文件中
默认用户配置文件 /etc/login.defs
MAIL_DIR /var/spool/mail #用户的默认邮件目录
PASS_MAX_DAYS 99999 #密码的最大有效期
PASS_MIN_DAYS 0 # 密码的最小天数
PASS_MIN_LEN 5 # 密码最小长度
PASS_WARN_AGE 7 # 密码告警等级
UID_MIN 1000 # 用户id起始值 1000,才centos6中是500
UID_MAX 60000 # 用户id最大值 60000, 起始可以有65535,2的16次方
SYS_UID_MIN 201 # 系统用户最小id值
SYS_UID_MAX 999 # 最大值
GID_MIN 1000 # 组id最小值
GID_MAX 60000 # 组id最大值
SYS_GID_MIN 201
SYS_GID_MAX 999
CREATE_HOME yes # 是否创建家目录
UMASK 077 # 用户掩码
USERGROUPS_ENAB yes # 创建用户的时候自动创建组
ENCRYPT_METHOD SHA512 # 使用的密码加密方式。sha512是第6中
在创建用户的时候,回为其自动创建组,一般用户id和组id是相同的,如果在其他地方被占用,就在原来的基础上进行加1.以后创建的用户,如果不指定id,那么就在前一个用户的基础上对uid和gid进行递增
用户家目录的产生:
在使用useradd添加用户后,在/homt/下会自动生成一个同名的文件夹,进入文件夹是空的,但是有几个隐藏的用户环境配置文件.bash_logout .bash_profile .bashrc
,
该文件夹的产生的默认配置中,有一个配置项SKEL=/etc/skel
,查看该路径,发现在其目录下。默认的就有这三个隐藏文件.bash_logout .bash_profile .bashrc
,所以,使用useradd创建用户家目录的时候,使用默认的skel(骨骼)文件夹,将内部的文件拷贝到/home下,这才有了用户的家目录。
usermod
修改系统已经存在的用户属性
userdel
删除用户
参数r的作用
passwd
使用标准输入来修改密码
id
su 和newgrp
charge
更改用户密码过期时间
组
用户组也是可以加密的
加密算法
用户/组 管理文件
添加用户组 groupadd
创建一个系统组
更改组模式
删除组
gpasswd
总结
三个关键文件的总结
用户及组的概念,就是将多用户的文件进行权限划分,使得不混乱。