单用户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

  1. Username field: This field denotes the User (or User Account) Name. According to the man page of useradd command, "Usernames may only be up to 32 characters long". This username must be used at the time of logging in to the system.
  2. 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.
  3. 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.
  4. GID field: Similar to the UID field, this field specifies which group the user belongs to, the group details being present in /etc/group file.
  5. 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 user Mandar Shinde, hence this comment).
  6. 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/mandar in this case).
  7. Shell: This field denotes, the user has access to the shell mentioned in this field (user 'mandar' has been given access to /bin/bash or simply bash shell).

查看Linux系统中有哪些shell可以用

[root@51cto ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash

用户密码在/etc/shadow文件中

参考:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Introduction_To_System_Administration/s3-acctsgrps-shadow.html

[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系统管理——用户、组的更多相关文章

  1. Linux的用户(组),权限,文件精妙的三角关系,和强大的帮助系统

    在linux中一切都是文件(文件夹和硬件外设是特殊的文件),如果有可能尽量使用文本文件.文本文件是人和机器能理解的文件,也成为人和机器进行 交流的最好途径.由于所有的配置文件都是文本,所以你只需要一个 ...

  2. Linux实际用户(组)ID,有效用户(组)ID,设置用户(组)ID

    实际用户(组)ID: 标识用户是谁,这两个字段在登录时取自口令文件中的登录项. 有效用户(组)ID: 决定了对文件的访问权限,通常有效用户(组)ID等于实际用户(组)ID,谁运行有效ID就等于谁的实际 ...

  3. 第2章 细说Linux系统用户/组管理(1)

    2.1 用户和组的基本概念 用户和组是操作系统中一种身份认证资源. 每个用户都有用户名.用户的唯一编号uid(user id).所属组及其默认的shell,可能还有密码.家目录.附属组.注释信息等. ...

  4. Linux下用户-组权限配置

    cat /etc/group cat /etc/ashadow 一.用户管理 1.添加用户 #useradd 用户名 useradd php100;用cat /etc/passwd查看 分析:php1 ...

  5. Linux将用户添加到组的指令

    原文:https://blog.csdn.net/youmatterhsp/article/details/80549683:           https://www.cnblogs.com/cl ...

  6. 【转】linux 设置用户id 设置组id

    linux 设置用户id 设置组id   转自 linux 设置用户id 设置组id   最近看apue,简单记录对设置用户id理解(设置组id同理). 1. 相关的id好像很多,共有哪些? 文件2个 ...

  7. 【转载】干货再次来袭!Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载八)用命令实现批量添加用户

    Windows添加用户需要至少5个界面,而Linux一条命令就搞定了,这是不是高效人士办公第一法则呢.本文不给你一堆参数和选项,不让你见识教条主义,只给你最实用的代码. 想每天能听到小妞的语音播报,想 ...

  8. Linux系统管理技术手册——第6章 添加新用户

    6.1/etc/passwd文件 用户登录时Linux识别用户的文件/etc/passwd /etc/passwd包括7个字段: 登录名(不超过32位,使用NIS系统后不超过8位) 经过加密的口令或口 ...

  9. Linux修改用户所在组方法

    Linux修改用户所在组方法 usermod -g 用户组 用户名强行设置某个用户所在组usermod -G 用户组 用户名把某个用户改为 group(s) usermod -a -G 用户组 用户名 ...

随机推荐

  1. 禁止CSRF校验实例

    静态文件----提交表单 本例在static目录中建立了一个from.html静态页面,该页面有一个<form>标签,用于向服务端提交POST请求,然后在post.py脚本文件中添加一个路 ...

  2. Linux下通过shell进MySQL执行SQL或导入脚本

    这条命令表示通过用户名和密码执行shell然后在shell里面执行一个建表语句: USER="root" PASS="root" mysql -u $USER ...

  3. 【c# 学习笔记】c#中的语句

    1.条件语句: if语句: bool condition = true; if (condition) { } else if (condition) { } else { } switch语句: b ...

  4. Spark学习笔记0——简单了解和技术架构

    目录 Spark学习笔记0--简单了解和技术架构 什么是Spark 技术架构和软件栈 Spark Core Spark SQL Spark Streaming MLlib GraphX 集群管理器 受 ...

  5. eclipse设置html js css自动提示

    eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用eclipse自带的插件,无需另外安装插件,具体步骤如下 1.打开eclipse→Window ...

  6. [学习笔记] Blender layout 视图切换

    layout 数字键5  --- 正交视图/透视图 切换 数字键0 -- 摄像机视图 数字键7 -- 顶视图 数字键1 --- 前视图 数字键3 --- 右视图 ctrl +数字键3 --- 左视图 ...

  7. 使用使用nltk 和 spacy进行命名实体提取/识别

    1. 什么是 命名实体提取? 参考:https://towardsdatascience.com/named-entity-recognition-with-nltk-and-spacy-8c4a7d ...

  8. 26.Spark创建RDD集合

    打开eclipse创建maven项目 pom.xml文件 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...

  9. 路由器02---PandoraBox配置

    1.安装libc 什么是libc,这里贴一个gnu官方的解释 Any Unix-like operating system needs a C library: the library which d ...

  10. Laravel安装和composer安装

    下载地址:https://getcomposer.org/download/ 他会自动找到你的php目录,如果没有记得手动修改  一直点下一步,即可. 如果安装不成功,可能是之前安装过composer ...