单用户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. Java如何获取ResultSet结果中的每一列的数据类型

    示例代码片段: ResultSet resultSet = statement.executeQuery(sql); ResultSetMetaData metaData = resultSet.ge ...

  2. 【ARTS】01_31_左耳听风-201900610~201900616

    ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algo ...

  3. Spring 本地事务

    主要原理: 事务的顶层接口: PlatformTransactionManager提供了3个方法,在申明式事务中这3个方法都是通过aop 调用的: 1.getTransaction: 进入相关需要被拦 ...

  4. 【C/C++开发】ffplay中的FrameQueue的自我理解

    最近在研究ffplay,以下是本人今天在研究FrameQueue的时候整理的笔记,如有错误还请有心人指出来~ //这个队列是一个循环队列,windex是指其中的首元素,rindex是指其中的尾部元素. ...

  5. 导航current背景

    ========================================简单一点的 var locationUrl = location.href.toLowerCase(); //导航cur ...

  6. Chocolate Eating【二分】

    题目链接:https://ac.nowcoder.com/acm/contest/1577/K 题目大意: 给出n块巧克力,m天吃完.每块巧克力有a[i]快乐值,每天可以选择吃任意块或者不吃巧克力(按 ...

  7. JavaSE基础(一)--初识Java

    Java 简介 Java是由Sun Microsystems公司于1995年5月推出的Java面向对象程序设计语言和Java平台的总称.由James Gosling和同事们共同研发,并在1995年正式 ...

  8. JRE和JDK的作用和区别

    JVM(Java  Virtual Machine)是一个虚拟的用于执行bytecode字节码的“虚拟计算机”JRE(Java   Runtime  Environment):Java 虚拟机.库函数 ...

  9. QComboBox的currentIndexChanged信号死循环问题

    connect(m_pComboBoxDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(sltComboBoxDeviceCurrentText ...

  10. python中的 __inti__ 和 __new__ 方法的区别

    这个要从Python的面向对象实例化的过程说起 类名() 之后,开辟一块内存空间,然后调用__init__把空间的内存地址作为self的参数传递到函数的内部,所有和self有关的参数,属性都会和sel ...