Chinaunix首页 | 论坛 | 博客
  • 博客访问: 234159
  • 博文数量: 80
  • 博客积分: 1597
  • 博客等级: 上尉
  • 技术积分: 597
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-30 13:49
文章分类

全部博文(80)

文章存档

2017年(1)

2015年(1)

2014年(1)

2013年(10)

2012年(10)

2011年(27)

2010年(30)

分类:

2011-10-04 09:49:03

原文地址:linux 用户添加配置 作者:lemon_suifeng

添加用户命令 adduser ,往/etc/passwd 添加用户信息
lemon : x : 500 : 500 : : /home/lemon : /bin/bash
用户名 :密码(用x表示,具体密码在/etc/shadow中,只能由root查看修改): 用户id :用户组id ; 用户描述信息  :家目录:用户使用的shell环境
/etc/shadow
lemon : !$1$OCOlZeym$u9CsvC77Anqyv44LWnY5l0 : 15249 : 0 : 99999 : 7 :  :  :
用户名 : md5加密后的密码(!表示此用户锁定) : 上次修改密码天shu(从1970-1-1起算): 最近两次密码修改间隔天书:
: 密码间隔最大天数(99999表无限期 ) : 密码将失效天数 :  几天未登录,帐号失效  : 帐号有效天数

修改用户信息 :
useradd lemon  -d 家目录  -s shell路径
usermod -L/-U lemon  锁定/解锁
usermod -f n(数值)  lemon  几天未登录,帐号失效
usermod -e 2011-12-30 lemon   帐号有效期时间
usermod -c " this is my user "  lemon  修改用户信息
usermod -u  511 lemon  修改用户id号
usermod -g  newgroup lemon  更改用户自身所属组, lemon原本组还存在,但已经没用户
usermod-G  newgroup lemon 将用户加到newgroup,将lemon再加到newgroup组中

/etc/group     /etc/gshadow
添加删除用户组使用 groupadd groupdel
修改组信息使用 gpasswd
gpasswd lemon 为lemon组添加密码
gpasswd -A user lemon  设置user为lemon组管理员
gpasswd -M user1,user2,user3 lemon  将user1,user2,user3 多个成员添加到lemon组
gpasswd -a user1 lemon   单个用户添加进组

gpasswd -d user1 lemon 删除组用户

gpasswd -r lemon 删除密码
newgrp newgroup 进入newgroup组


//系统用户的一些参数
[root@localhost etc]# cat login.defs
# *REQUIRED*
#   Directory where mailboxes reside, _or_ name of file, relative to the
#   home directory.  If you _do_ define both, MAIL_DIR takes precedence.
#   QMAIL_DIR is for Qmail
#
#QMAIL_DIR      Maildir
#为用户建立邮件
MAIL_DIR        /var/spool/mail  
#MAIL_FILE      .mail

# Password aging controls:
#
#       PASS_MAX_DAYS   Maximum number of days a password may be used.
#       PASS_MIN_DAYS   Minimum number of days allowed between password changes.
#       PASS_MIN_LEN    Minimum acceptable password length.
#       PASS_WARN_AGE   Number of days warning given before a password expires.

# 密码信息
PASS_MAX_DAYS   99999 
PASS_MIN_DAYS   0
PASS_MIN_LEN    5
PASS_WARN_AGE   7

#
# Min/max values for automatic uid selection in useradd
#
UID_MIN                   500
UID_MAX                 60000

#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN                   500
GID_MAX                 60000

#
# If defined, this command is run when removing a user.
# It should remove any at/cron/print jobs etc. owned by
# the user to be removed (passed as the first argument).
#
# 删除用户将用户相关所有信息一并删除,注释表否
#USERDEL_CMD    /usr/sbin/userdel_local

#
# If useradd should create home directories for users by default
# On RH systems, we do. This option is overridden with the -m flag on
# useradd command line.
#
# 默认给新添用户创建家目录
CREATE_HOME     yes

# The permission mask is initialized to this value. If not specified,
# the permission mask will be initialized to 022.
UMASK           077

# This enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes

# Use MD5 or DES to encrypt password? Red Hat use MD5 by default.
MD5_CRYPT_ENAB yes

添加用户默认参数设置文件 /etc/default/useradd
[root@localhost default]# cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel //用户所需配置文件,当建立新用户时,从/etc/skel复制文件到家目录下
CREATE_MAIL_SPOOL=yes  // 添加邮件服务




阅读(394) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~