Linux系统管理——用户、组
单用户OS和多用户OS?
Linux是多用户OS,Windows是单用户OS。很多人会疑惑? Windows7也可以创建多个用户啊,怎么能说是单用户OS呢?
这里的多用户指的是OS同时可以被多个人访问,单用户指的是OS一次只能被一个用户的访问。
Windows里面,win7、winxp都是单用户OS;Windows server 2008,2003等是多用户OS。
Linux环境下使用who命令可以知道当前有多少用户
[root@51cto ~]# who
root tty1 -- :
root pts/ -- : (192.168.80.1)
whoami可以知道当前登陆用户是谁
[root@51cto ~]# whoami
root
无论单用户OS还是多用户OS都可以再系统上创建多个账户。
用户类别

UID的取值范围再配置文件/etc/login.defs里面定义了
[root@51cto ~]# cat /etc/login.defs | grep -v '^#'
MAIL_DIR /var/spool/mail
PASS_MAX_DAYS
PASS_MIN_DAYS
PASS_MIN_LEN
PASS_WARN_AGE
UID_MIN
UID_MAX
GID_MIN
GID_MAX
CREATE_HOME yes
UMASK
USERGROUPS_ENAB yes
ENCRYPT_METHOD SHA512
组类别

使用组简化授权
基本组:优先使用基本组,用户只能属于一个基本组。基本组也叫默认组。
附加组:基本组不能满足授权要求时,创建附加组。用户可以属于多个附加组。
私有组:创建用户是如果没有指定所属的组 系统会自动为其创建一个同名的组
Linux环境下用户信息保存在/etc/passwd,每一行代表一个用户。
[root@51cto ~]# cat /etc/passwd
root:x:::root:/root:/bin/bash
bin:x:::bin:/bin:/sbin/nologin
daemon:x:::daemon:/sbin:/sbin/nologin
adm:x:::adm:/var/adm:/sbin/nologin
lp:x:::lp:/var/spool/lpd:/sbin/nologin
sync:x:::sync:/sbin:/bin/sync
shutdown:x:::shutdown:/sbin:/sbin/shutdown
halt:x:::halt:/sbin:/sbin/halt
mail:x:::mail:/var/spool/mail:/sbin/nologin
uucp:x:::uucp:/var/spool/uucp:/sbin/nologin
operator:x:::operator:/root:/sbin/nologin
games:x:::games:/usr/games:/sbin/nologin
gopher:x:::gopher:/var/gopher:/sbin/nologin
ftp:x:::FTP User:/var/ftp:/sbin/nologin
nobody:x:::Nobody:/:/sbin/nologin
vcsa:x:::virtual console memory owner:/dev:/sbin/nologin
saslauth:x:::"Saslauthd user":/var/empty/saslauth:/sbin/nologin
postfix:x::::/var/spool/postfix:/sbin/nologin
sshd:x:::Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
wangyan:x::::/home/wangyan:/bin/bash

- Username field: This field denotes the User (or User Account) Name. According to the man page of
useraddcommand, "Usernames may only be up to 32 characters long". This username must be used at the time of logging in to the system. - Password field: Second field is the Password field, not denoting the actual password though. A 'x' in this field denotes the password is encrypted and saved in the
/etc/shadowfile. - UID field: Whenever a new user account is created, it is assigned with a user id or UID (UID for the user '
mandar' is 500, in this case) and this field specifies the same. - GID field: Similar to the UID field, this field specifies which group the user belongs to, the group details being present in
/etc/groupfile. - Comment/Description/User Info field: This field is the short comment/description/information of the user account (For this example, user account '
mandar' belongs to the userMandar Shinde, hence this comment). - User Home Directory: Whenever a user logs in to the system, he is taken to his Home directory, where all his personal files reside. This field provides the absolute path to the user's home directory (
/home/mandarin this case). - Shell: This field denotes, the user has access to the shell mentioned in this field (user '
mandar' has been given access to/bin/bashor simplybashshell).
查看Linux系统中有哪些shell可以用
[root@51cto ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
用户密码在/etc/shadow文件中
[root@51cto ~]# cat /etc/shadow
root:$$5B2lQCfHQp5kBP8L$yA9etUiORX6Zxn663OARZcp/:::::::
bin:*:::::::
daemon:*:::::::
adm:*:::::::
lp:*:::::::
sync:*:::::::
shutdown:*:::::::
halt:*:::::::
mail:*:::::::
uucp:*:::::::
operator:*:::::::
games:*:::::::
gopher:*:::::::
ftp:*:::::::
nobody:*:::::::
vcsa:!!:::::::
saslauth:!!:::::::
postfix:!!:::::::
sshd:!!:::::::
wangyan:!!:::::::
[root@WebServer ~]# tail - /etc/shadow
wangyan:$$PDZ2U4mgN89wtWFfCYFB.:::::::
用户登录名
加密后的密码
从1970 年到最近一次更改密码时间之间过了多少天
密码最少使用几天
密码最长使用多少天
密码到期前几天提醒用户更改密码
密码过期时间
用户过期时间

chage
更改用户密码过期信息
-d 设置最近一次更改密码时间
-E 设置账户过期时间
-I 设置密码过期时间
-l --list 列出用户账户密码信息
-m 设置用户最短密码使用时间
-M 设置用户最常密码使用时间
-W 设置密码更改警告时间
Linux系统管理——用户、组的更多相关文章
- Linux的用户(组),权限,文件精妙的三角关系,和强大的帮助系统
在linux中一切都是文件(文件夹和硬件外设是特殊的文件),如果有可能尽量使用文本文件.文本文件是人和机器能理解的文件,也成为人和机器进行 交流的最好途径.由于所有的配置文件都是文本,所以你只需要一个 ...
- Linux实际用户(组)ID,有效用户(组)ID,设置用户(组)ID
实际用户(组)ID: 标识用户是谁,这两个字段在登录时取自口令文件中的登录项. 有效用户(组)ID: 决定了对文件的访问权限,通常有效用户(组)ID等于实际用户(组)ID,谁运行有效ID就等于谁的实际 ...
- 第2章 细说Linux系统用户/组管理(1)
2.1 用户和组的基本概念 用户和组是操作系统中一种身份认证资源. 每个用户都有用户名.用户的唯一编号uid(user id).所属组及其默认的shell,可能还有密码.家目录.附属组.注释信息等. ...
- Linux下用户-组权限配置
cat /etc/group cat /etc/ashadow 一.用户管理 1.添加用户 #useradd 用户名 useradd php100;用cat /etc/passwd查看 分析:php1 ...
- Linux将用户添加到组的指令
原文:https://blog.csdn.net/youmatterhsp/article/details/80549683: https://www.cnblogs.com/cl ...
- 【转】linux 设置用户id 设置组id
linux 设置用户id 设置组id 转自 linux 设置用户id 设置组id 最近看apue,简单记录对设置用户id理解(设置组id同理). 1. 相关的id好像很多,共有哪些? 文件2个 ...
- 【转载】干货再次来袭!Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载八)用命令实现批量添加用户
Windows添加用户需要至少5个界面,而Linux一条命令就搞定了,这是不是高效人士办公第一法则呢.本文不给你一堆参数和选项,不让你见识教条主义,只给你最实用的代码. 想每天能听到小妞的语音播报,想 ...
- Linux系统管理技术手册——第6章 添加新用户
6.1/etc/passwd文件 用户登录时Linux识别用户的文件/etc/passwd /etc/passwd包括7个字段: 登录名(不超过32位,使用NIS系统后不超过8位) 经过加密的口令或口 ...
- Linux修改用户所在组方法
Linux修改用户所在组方法 usermod -g 用户组 用户名强行设置某个用户所在组usermod -G 用户组 用户名把某个用户改为 group(s) usermod -a -G 用户组 用户名 ...
随机推荐
- 记一次线上由nginx upstream keepalive与http协议"协作"引起的接口报错率飙高事件
年前接到个任务,说要解决线上一些手机客户端接口报错率很高的问题.拿到了监控邮件,粗略一看,各种50%+的错误率,简直触目惊心.这种疑难杂症解决起来还是挺好玩的,于是撸起袖子action. 最终的结果虽 ...
- 高级UI-Snackbar
在与用户的交互中,最为常用的Toast和Dialog,但二者都存在其局限,Toast无法与用户进行交互,Dialog虽然可以与用户交互,但却会阻断用户操作的连贯性,介于二者之间的平衡,Snackbar ...
- PyCharm Community Edition编辑Python查看数据库
描述:利用PyCharm Community Edition社区版本的时候无法查看数据库 解决方法如下: 点击File之后选择setting 点击setting之后出现的画面上面选择Plugins,之 ...
- python线程互斥锁Lock(29)
在前一篇文章 python线程创建和传参 中我们介绍了关于python线程的一些简单函数使用和线程的参数传递,使用多线程可以同时执行多个任务,提高开发效率,但是在实际开发中往往我们会碰到线程同步问题, ...
- logstash grok nginx log
#cat logstash.conf input { file { path => "/alidata/logs/nginx/appapi.dayutang.cn.access*.lo ...
- GB2312、GBK、GB18030 这几种字符集的主要区别
1 GB2312-80 GB 2312 或 GB 2312-80 是中国国家标准简体中文字符集,全称<信息交换用汉字编码字符集·基本集>,又称 GB 0,由中国国家标准总局发布,1981 ...
- GBK字符集
GBK字库 编辑 同义词 GBK一般指GBK字库 GBK全称<汉字内码扩展规范>(GBK即“国标”.“扩展”汉语拼音的第一个字母,英文名称:Chinese Internal Code Sp ...
- S03_CH08_DMA_LWIP以太网传输
S03_CH08_DMA_LWIP以太网传输 8.1概述 本例程详细创建过程和本季课程第一课<S03_CH01_AXI_DMA_LOOP 环路测试>非常类似,因此如果读者不清楚如何创建工程 ...
- 【C#】上机实验一
1.开发一个控制台应用程序,根据提示从键盘获取一个华氏温度,请转换并输出对应的摄氏温度. using System; namespace Project { class Program { publi ...
- Tree Generator™ CodeForces - 1149C (线段树,括号序列)
大意: 给定括号序列, 每次询问交换两个括号, 求括号树的直径. 用[ZJOI2007]捉迷藏的方法维护即可. #include <iostream> #include <algor ...