06 Users,Groups,and Permissions

1.The Linux security model
使用user和group管理访问权限

2.Users
/etc/passwd
例:     user1:x:500:500:user1:/home/user1/bin/bash
          栏一 用户名     栏二 X为要求密码登录,删掉密码为空
          栏三 uid     栏四 gid     栏五 用户说明  
/etc/shadow
系统中用户密码的database
例:  user1:$1$vo89pI5Y$v7tagz/t1e1:
         栏二 md5密码,开头为$1$表示该用户已设密码。开头为! !空表示密码无

  • 每个用户都被分配一个 唯一的uid (a unique user id number)
  • Users' names and uids are stored in /etc/passwd
  • Users are assigned to a home directory and a program that is run when they log in (shell)
  • Users cannot read,write or execute each others' files without permission.

3.Groups
/etc/group
例:user1:x:500:
栏1  group name     栏2 password     栏3 gid    栏4 group中的成员
/etc/gshadow

  • 每用户至少隶属于一个group,每group有一个gid
  • gids are stored in /etc/group
  • 系统给每一个用户同名的group,用户可以加入其它group以取得更多权限
  • group中的组成员可共享资源

4.The root user
should not log in as root without a very good reason

5.Linux file security

Permissions are set for:

  • the owner of the file
  • the group members
  • all others

6.Permission Types

  • -r
  • -w
  • -x   permission to execute a program or change into a directory and do a long listing of the directory.
  • -   no permission

7.Interpreting permission
例:d     rwx (u)     rwx(g)    rwx(o  others)

ls -ld  查看指定目录详细信息
ls -l     查看指定文件详细信息

8.Processing Linux security
判断过程:root? --->  uid:file's uid  --->  gid:files' gid  ---> o

9.Changing Permissions -symbolic Method(符号表示法)

chmod [-R] mode file  其中-R表示为整个目录设置权限。
例: ]# chmod -R ugo-wx doc   为doc目录去除文件所有者、用户组及其它用户的可写与可执行权限。
mode包含
who?                u    g    o    a
operator         +    -    = (将权限设定为指定状态)
permission    r    w    x

10.Changing permissions -Numeric Method(数字表示法)
使用一组三位数的模式 来设定权限,还是以ugo排序。各位以4、2、1、0相加总和而来表示。 例如5表示可读可执行权限。
用法举例改目录权限:  chmod -R 754 doc

  • 4 (read)
  • 2 (write)
  • 1 (execute)
  • 0 (no permission)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值