day7-Linux system user and user group management (ob-04)-1

Linux system user and user group management-01

Summary of Management User Commands

Insert picture description here
Insert picture description here
Insert picture description here

/etc/skel directory

Insert picture description here
Insert picture description here

Insert picture description here

/etc/login.defs file

/etc/login.defs文件是用来定义创建用户时需要的一些用户的配置信息。
如创建用户时,是否需要家目录,UID和GD的范围,用户及密码的有效期限等等。
#篇幅有限就不放 cat /etc/login.defs内容出来了

/etc/default/useradd file

/etcl default/useradd文件是在使用useradd添加用户时的一个需要调用的一个默认的配置文件,-可以使用useradd -D参数,这样的命令格式来修改文件里面的内容。
cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home   #→把用户的家目录建在/home 中。
INACTIVE=-1  #→是否启用帐号过期停权,-1表示不启用。
EXPIRE=#→帐号终止日期,不设置表示不启用
SHELL=/bin/bash  #→新用户默认所用的shell类型。
SKEL=/etc/skel  #配置新用户家目录的默认文件存放路径。前文提到的/etc/skell,就是配在这里生效的,即当我们用useradd添加用户时,用户家目录下的文件,都是从这里配置的目录中复制过去的。
CREATE_MAIL_SPOOL=yes #创建mail文件
例子中更改/etc/default /useradd中 SKEL路径后测试的例子。其它参数的修改方法同,直接生效,当然也可以通过useradd -D参数的方式修改。
useradd      -D, --defaults                print or change default useradd configuration

useradd instruction

Insert picture description here
Insert picture description here

#finger查看用户信息
finger root 

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

useradd -D

It can be seen that useradd -D displays the content of /etc/default/useradd by default.
Insert picture description here
Insert picture description here
Insert picture description here
#Modify the default expiration time of a new account. After setting, new users will expire after this time
useradd -D -e 01/19/12

Linux system user and user group management-02

Add user group command groupadd

Insert picture description here

passwd command:

Insert picture description here
Insert picture description here
Insert picture description here

 chage -l root

Insert picture description here

The following requires oldboy users not to change their passwords within 7 days, and must change their passwords after 60 days. Oldboy users are notified 10 days before the expiration, and users are prohibited from logging in after 30 days after the expiration.
Insert picture description here
Insert picture description here

Linux system user and user group management-03

passwd batch add user account password script

#!bin/bash
userchars="test"
passfile="/tmp/user.log"

for num in `seq 3`
do
	useradd $userchars$num
	passwd="`echo "date $RANDOM" | md5sum | cut -c3-11`"
	echo "$oasswd" | passwd --stdin $userchars$num
	echo -e "user: $userchars$num \t passwd:$passwd" >>$passfile
done

echo ------user password info----------------
cat $passfile

Insert picture description here
Insert picture description here

END

Guess you like

Origin blog.csdn.net/Nightwish5/article/details/113737611