1 用户与群组数据库

用户清单通常保存在 /etc/passwd 文件内,把哈希编码后的密码保存在 /etc/shadow 文件内。这两个文件都是纯文本档,以简单的格式保存,可以用文本编辑器读取与修改。每个用户占一行,其字段以冒号分隔 (“:”)。

最好使用 vipw 命令编辑 /etc/passwd 文件,或使用 vigr 命令编辑 /etc/group 文件。这些命令会先锁住该文件再运行文本编辑器, (缺省使用 vi 命令,除非 EDITOR 环境变量有其他的设置)。加上 -s 选项可同时编辑对应的 shadow 文件。

1.1 用户清单:/etc/passwd

在 /etc/passwd 文件内的字段清单:

登录,例如 rhertzog;

uid:用于辨识用户的不重复数字;

gid:用户主要群组 (Debian 的默认值系为每个用户创建一个群组) 的不重复号码;

GECOS:通常保存用户全名的数据栏;

登入目录,用于保存用户的个人文件 (环境变量 $HOME 通常指向此处);

登录时运行的程序。通常是命令解译器 (shell),若指定为 /bin/false (不做任何事并立即回到控制),则用户无法登录。

1.2 隐藏与加密的密码档:/etc/shadow

/etc/shadow 文件含以下的字段:

登录;

加密的密码;

管理密码期限的字段。

安全 /etc/shadow 文件的安全

/etc/shadow,不同于它的分身,/etc/passwd,不能被一般用户读取。保存在 /etc/passwd 内的哈希编码后的密码可被任何人读取;破坏者可以用 “暴力” 法破坏它们,以常见的编码字符破解。这种攻击方式 — 称为 "字典攻击" — 对于使用 /etc/shadow 的系统是无效的。

1.3 群组清单:/etc/group

群组列在 /etc/group 文件内,类似 /etc/passwd 文件的纯文本数据库,包括以下的字段:

群组名称;

密码 (可选):只在加入群组时会用到 (使用 newgrp 或 sg 命令,见专栏 基本知识 在多个群组工作);

gid:不重复的群组识别码;

成员清单:属于此群组的用户名清单,以逗号分隔。

基本知识 在多个群组工作

用户可能加入多个群组;其中一个是 “主群组”。用户自己的主群组默认是初始化用户配置时自动产生的。默认情况下,用户添加的文件自动属于该用户,以及其主群组。这种方式并不重视可取的;例如,用户需要在自己主群组文件夹之外工作,与其他群组共享其文件。在这种情况下,用户需以命令:newgrp 变更其主要群组,启动新的 shell,或以 sg 命令,使用其他群组执行一个命令。这些命令也允许用户加入其他群组。若该群组受密码保护,则需先取得密码才能运行该等命令。

用户还可以设置文件夹的 setgid 位,让该文件夹内的文件自动属于特定群组。详情见专栏 安全 文件夹的 setgid 和 sticky bit。

id 命令显示用户的当前状态,包括个人辨识码 (uid 变量)、当前的主群组 (gid 变量)、以及其所属群组的清单 (groups 变量)。

addgroup 与 delgroup 命令可以添加或删除群组。groupmod 命令修改群组的信息 (其 gid 或辨识码)。命令 gpasswd group 可变更群组的密码,gpasswd -r group 命令可删除群组的密码。

秘诀 getent

getent (get entries) 命令使用适当的程序库函数,调用配置于 /etc/nsswitch.conf 文件的 NSS 模块,以标准方式检查系统数据库。此命令需要一个或两个参数:被检查的数据库名称、以及可能的搜索键词。因此,getent passwd rhertzog 命令将从用户 rhertzog 中给予用户数据库。

挂载点清单

有些移动式设备在链接时系统自动挂载,尤其在 GNOME、Plasma 或其他图形桌面环境。有些情况就需要用户手动挂载。同样的,也需要卸载 (从文件树移除)。标准的用户权限不允许运行挂载 mount 与卸载 umount 命令。只有管理者才能够设置 /etc/fstab 文件内的 user 选项,授权用户运行该等命令 (独立于每个挂载点)。

The /etc/fstab file gives a list of all possible mounts that happen either automatically on boot or manually for removable storage devices. Each mount point is described by a line with several space-separated fields:

  • file system: this indicates where the filesystem to be mounted can be found, it can be a local device (hard drive partition, CD-ROM) or a remote filesystem (such as NFS or even SSHFS).

    This field is frequently replaced with the unique ID of the filesystem (which you can determine with blkid device) prefixed with UUID=. This guards against a change in the name of the device in the event of addition or removal of disks, or if disks are detected in a different order. 第 8.8.1 节 “辨识磁盘” covers this topic in more detail.
  • mount point:这是把设备、远程系统或分区挂载到本地文件系统的位置。
  • type:这个字段定义挂载设备使用的文件系统。ext4、ext3、vfat、ntfs、btrfs、xfs 等。
  • options:依文件系统的不同,而有多种选项,详情见 mount 手册页面。最常用的是

rw 或 ro,表示该设备挂载后可以读/写,或只有读取的权限。

noauto 开机时关闭自动挂载。

nofail 允许在启动时处理设备,即使该设备不存在。确认启动时,该外置磁盘机可能未插入,因为 systemd 将确认所有挂载点在启动完成前必须自动挂载。可将此与 x-systemd.device-timeout=5s 并用,告诉 systemd 不必等 5 秒以上的时间,直接进入下个作业阶段 (见 systemd.mount(5))。

user 授权所有的用户均可挂载此文件系统 (若无此选项,则只有根用户才有此权限)。

  • defaults 表示缺省的选项群组为:rw、suid、dev、exec、auto、nouser 与 async,使用了 defaults 之后,还可以用 nosuid 命令、nodev 及其他类似的命令,中止 suid、dev 等作用。加入 user 选项可再启用它,因为 defaults 包括 nouser。
  • dump: this field is almost always set to 0 and kind of a relic. When it is greater then zero, it tells the dump tool that the partition contains data that is to be backed up frequently. The tool supports Ext2/3/4 filesystems only and will use the value here when run via dump -W or dump -w to determine which partitions need to be backed up. Consider the examples in /usr/share/doc/dump/examples/ if you want to use this feature. But there are better alternatives to backup a filesystem, like fsarchiver.
  • pass:最后一个字段告知系统在启动时,或其他时机,检查文件系统的完整性。若设为 0,则不检查。根文件系统的值为 1,其他固定文件系统的值为 2。

例 8.5. 范例 /etc/fstab 文件

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=7a250fb8-c16d-4a4e-9808-ec08ae92b6c6 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=13f367ae-dbaf-40ed-85c0-4072a2ebe426 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy auto rw,user,noauto 0 0
arrakis:/shared /shared nfs defaults 0 0

The last entry in the example corresponds to a network filesystem (NFS): the /shared/ directory on the arrakis server is mounted at /shared/ on the local machine.

The format of the /etc/fstab file is documented in the fstab(5) manual page.

进一步 自动挂载

systemd is able to manage automount points: those are filesystems that are mounted on-demand when a user attempts to access their target mount points. It can also unmount these filesystems when no process is accessing them any longer.

Like most concepts in systemd, automount points are managed with dedicated units, using the .automount suffix. See systemd.automount(5) for their precise syntax.

还有其他自动挂载实用程序,诸如 autof role="pkg">autofs 软件包中的 automount 或 am-utils 软件包中的amd。

Note also that GNOME, Plasma, and other graphical desktop environments work together with udisks2, and can automatically mount removable media when they are connected.

Debian11管理员手册的更多相关文章

  1. Oracle GoldenGate OGG管理员手册(较早资料)

    第一章 系统实现简述 前言 编写本手册的目的是为系统管理员以及相关操作人员提供 Oracle  Goldengat  软 件的日常维护和使用的技术参考: 3 ORACLE 第二章 OGG 日常维护操作 ...

  2. Oracle GoldenGate OGG管理员手册

    第一章 系统实现简述 前言 编写本手册的目的是为系统管理员以及相关操作人员提供 Oracle  Goldengat  软 件的日常维护和使用的技术参考: 3 ORACLE 第二章 OGG 日常维护操作 ...

  3. Ubuntu管理员手册

    hostname cat /etc/hosts apt-get install iproute2 iproute2-doc ip a ps -aux

  4. Manual | BSD手册| Linux手册 | 数据库手册 | 编程开发手册 | WEB开发手册 | 软件应用手册 | 网络技术手册 | GNU手册

    豆豆手册 □ BSD手册 □ Linux手册 □ 数据库手册 □ 编程开发手册 □ WEB开发手册 □ 软件应用手册 □ 网络技术手册 □ GNU手册 在线手册 首 页 BSD手册   ·FreeBS ...

  5. 如何成为一名出色的Oracle数据库管理员

    主要针对Oracle DBA在成长阶段的定位,学习方法等几大方面进行了经典的论述,详细内容请参考下文. 一.定位 Oracle分两大块,一块是开发,一块是管理.开发主要是写写存储过程.触发器什么的,还 ...

  6. 成为OpenStack工程师

    OpenStack Hacker 态度:开放.主动.沟通 影响力:能说.能写.能分享 四化:自动化.流程化.系统化.文档化 0级 掌握一些基本技能:python.c.linux.git.unittes ...

  7. 关于OpenStack的学习路线及相关资源汇总

    首先我们想学习openstack,那么openstack是什么?能干什么?涉及的初衷是什么?由什么来组成?刚接触openstack,说openstack不是一个软件,而是由多个组件进行组合,这是一个更 ...

  8. Symantec Backup Exec 2012 Agent for Linux 卸载

    本文介绍一下如何卸载Symantec Backup Exec 2012 Agent for Linx.首先我们来看看Symantec_Backup_Exec2012管理员手册的文档介绍: 卸载 Age ...

  9. postgreSQL使用

    1.1. 安装     自然,在你想开始使用 PostgreSQL 之前, 你必须安装它.PostgreSQL 很有可能 已经安装到你的节点上了,因为它包含在你的操作系统的发布里, 或者是系统管理员已 ...

随机推荐

  1. 高效简单的.Net数据库“访问+操作”技术

    本文技术源自外企,并已在多个世界500强大型项目开发中运用. 本文适合有初步C#.Linq.Sql知识的同学阅读. 相关技术在IDataAccess接口中提供. IDataAccess所在的命名空间是 ...

  2. Java开发学习(二十七)----SpringMVC之Rest风格解析及快速开发

    一.REST简介 REST(Representational State Transfer),表现形式状态转换,它是一种软件架构风格 当我们想表示一个网络资源的时候,可以使用两种方式: 传统风格资源描 ...

  3. 简单创建一个SpringCloud2021.0.3项目(四)

    目录 1. 项目说明 1. 版本 2. 用到组件 3. 功能 2. 上三篇教程 3. 日志处理 1. 创建日志公共模块 2. Eureka引入日志模块 4. 到此的功能代码 5. 注册中心换成naco ...

  4. openstack中Nova组件简解

    一.Nova组件概述 计算节点通过Nova Computer进行虚拟机创建,通过libvirt调用kvm创建虚拟机,nova之间通信通过rabbitMQ队列进行通信. Nova位于Openstack架 ...

  5. Node.js躬行记(22)——Node环境升级日志

    公司之前所有的 Node 项目,其环境都是 8.9.4 版本,发布于 2018 年的一个比较古老的版本. 老版本有两个比较明显的问题: Node 高版本的特性和方法都无法使用. 有些第三方新版本的包无 ...

  6. 防止一台logstash机器上接入多个端口的日志会产生混乱

    为了防止一台机器上多个接入会导致日志混乱所以地在各模块上添加type标识并作if判断! 不多比比直接上配置 [root@sf215 conf.d]# cat jddns-servers.conf in ...

  7. Gitea 与 Jenkins 的集成实践,打造你的专属 CI/CD 系统

    前言 Gitea 是一个用于代码托管的轻量级单体程序,它能与现有的经典应用集成,诸如代码分析工具 SonarQube.持续集成工具 Drone.Jenkins 以及用于工单管理的客户端插件(VSCod ...

  8. Python 代码智能感知 —— 类型标注与特殊的注释(献给所有的Python人)

    [原文地址:https://xiaokang2022.blog.csdn.net/article/details/126936985] ​ 一个不会写好的类型标注和注释的Python程序员,是让使用T ...

  9. 云原生之旅 - 2)Docker 容器化你的应用

    前言 上文中我们用Golang写了一个HTTP server,本篇文章我们讲述如何容器化这个应用,为后续部署到kubernetes 做准备. 关键词:Docker, Containerization, ...

  10. .NET 反向代理-YARP 部署Https(SSL)

    YARP 作为反向代理中间件,那就无可避免需要使用到 Https 去部署项目,那 YARP 要怎么去实现呢,本来以为 YARP 会有一套自己的实现,在翻阅了资料后发现,根本不是我想的那样,按照 YAR ...