单用户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. 第二十四章 在线会话管理——《跟我学Shiro》

    目录贴:跟我学Shiro目录贴 有时候需要显示当前在线人数.当前在线用户,有时候可能需要强制某个用户下线等:此时就需要获取相应的在线用户并进行一些操作. 本章基于<第十六章 综合实例>代码 ...

  2. git rev-parse介绍;获取commit id

    git rev-parse master^{commit} 是什么意思 显示master提交的SHA1值 if you want to make sure that the output actual ...

  3. 使用JavaScript实现量化策略并发执行

    本文代码和文章发在FMZ发明者比特币量化交易平台上: 使用JavaScript实现量化策略并发执行--封装Go函数 - 发明者量化 https://www.fmz.com/digest-topic/3 ...

  4. sql语句-按照汉字拼音首字母排序

    在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NLS_SORT值 SCHINESE_RADICAL_M 按照部首(第一顺序).笔划(第二顺序)排序SCHINESE_STROKE_M 按照 ...

  5. 高阶函数 filter map reduce

    const app=new Vue({ el:'#app', data:{ books:[{ id:1, name:"算法导论", data: '2006-1', price:39 ...

  6. java模拟from表单提交,上传图片

    /** * java上传表单,有图片 * @param urlStr 上传地址 * @param textMap 表单参数 * @param fileMap 文件参数 key:文件名称 value:文 ...

  7. js实现放烟花效果——点击处会从下向上升起烟花

    一个box中,点击其中的任意位置,会有烟花从正下方升起到点击处,并燃放出一圈圆形的烟花.代码如下: 首先是布局以及样式: <style> .box{ width: 1100px; heig ...

  8. SAS学习笔记5 字符截取语句(index、compress、substr、scan函数)

    index:返回一个字符串中,某个特定字符或字符串的位置,找不到时返回0 compress:从一个字符串移除特定的字符 substr函数 字符替换与提取字符 substr(s, p, n)从变量s的第 ...

  9. 将物理机系统转为虚拟机系统 p2v

    ref : https://blog.csdn.net/gsls200808/article/details/77932713 背景: 在公司有台机子主要负责某产品的升级与维护,出于各种原因,该产品需 ...

  10. NIPS 2018 | 程序翻译新突破:UC伯克利提出树到树的程序翻译神经网络

    NIPS 2018 | 程序翻译新突破:UC伯克利提出树到树的程序翻译神经网络 机器之心 ​ 已认证的官方帐号 49 人赞同了该文章 选自arXiv,作者:Xinyun Chen.Chang Liu. ...