学习linux-基础五(权限管理练习题)

一、创建组vlan,gid 4000,passwd :centos,vlan 的组管理员admin:vlan2

将用户vlan1,vlan2,vlan3加入到vlan辅助组

希望vlan1创建新文件默认的所属组为vlan

vlan2将用户vlan3从vlan组移除

[[email protected] testdir]# groupadd -g 4000 vlan     #创建一个名叫vlan的组
[[email protected] testdir]# useradd -G vlan vlan1
[[email protected] testdir]# useradd -G vlan vlan2
[[email protected] testdir]# useradd -G vlan vlan3     #创建了三个用户都加入到vlan的辅助组中
[[email protected] ~]# groupmems -l -g vlan            #查看在vlan辅助组中的账号
vlan1  vlan2  vlan3
[[email protected] ~]# gpasswd vlan
Changing the password for group vlan
New Password:
Re-enter new password:
[[email protected] ~]# gpasswd -A vlan2 vlan          #将vlan2成为vlan组中的管理员
[[email protected] ~]# getent gshadow vlan
vlan:$6$inq7L/hyB0u/$bjTdT78t2jUKNFviflwfquUlWe7IRVsxLzT21gbBqKHZEY2ArouReNBelf6TvoBIbia25qLutDmDLTatNq4mN0:vlan2:vlan1,vlan2,vlan3
[[email protected] ~]# su vlan2
[[email protected] root]$ gpasswd -d vlan3 vlan      #删除辅助组vlan中的账号vlan3
Removing user vlan3 from group vlan
[[email protected] root]$ exit
exit
[[email protected] ~]# groupmems -l -g vlan
vlan1  vlan2

  

 

二、在/testdir/data里创建的新文件自动属于g1组,组g2的成员如:alice能对这些新文件有读写权限,组g3的成员如:alice能对这些新文件有读写权限,组g3的成员如:tom只能对新文件有读权限,其它用户(不属于g1,g2,g3)不能访问这个文件夹。

[[email protected] testdir]# mkdir -p /date/testdir
[[email protected] testdir]# pwd
/testdir
[[email protected] testdir]# groupadd g1
[[email protected] testdir]# groupadd g2
[[email protected] testdir]# groupadd g3
[[email protected] testdir]# chgrp g1 /date/testdir/
[[email protected] testdir]# useradd -G g2 alice
[[email protected] testdir]# useradd -G g3 tom
[[email protected] testdir]# chmod g+s /data/testdir
chmod: cannot access `/data/testdir‘: No such file or directory
[[email protected] testdir]# chmod g+s /date/testdir
[[email protected] testdir]# setfacl -Rm d:g:g2:rwx /date/testdir/
[[email protected] testdir]# getfacl /date/testdir/

  

  

  

  

时间: 2024-12-07 20:26:27

学习linux-基础五(权限管理练习题)的相关文章

linux基础操作----权限管理

linux的拥有这强大的权限操作. 我们能够简单的对linux权限管理进行分类: 权限本身有: 读 read. 写 write. 运行 execute 权限针对目标: 文件. 文件夹文件夹 权限针对用户: 主人 user. 同组 group. 其它组 other 我们如今举个样例分别对上述进行解释: 当前用户是zhoudong 用于文件doublegun.txt zhoudong(music) rwx (主人权限:读/写/运行) doublegun.txt xueyou(music) rw- (

Linux基础之权限管理

权限管理: ls -l rwxrwxrwx: 左三位:定义user(owner)的权限 中三位:定义group的权限: 右三位:定义other的权限 进程安全上下文: 进程对文件的访问权限应用模型: 进程的属主与文件的属主是否相同:如果相同,则应用属主权限: 否则,则检查进程的属主是否属于文件的属组:如果是,则应用属组权限: 否则,就只能应用other的权限: 权限: r:readable, 读 w:writable, 写 x:excutable,执行 文件: r:可获取文件的数据: w: 可修

Linux基础之磁盘管理

 Linux基础之磁盘管理         关于Linux中磁盘管理我们应该从以下四个方面入手,去了解和学习磁盘管理的知识. 第一点 磁盘的结构--硬盘         硬盘的参数 结构:磁盘的盘片,磁头,马达(机械键盘) 类型:固态硬盘(SSB)和机械硬盘 接口:早期的IDE接口,现在的SATA,SCSI,SAS 还有容量,转速,传输速度,缓存等. 硬盘存储术语 head: 磁头 track: 磁道 cylinder: 柱面 secotr: 扇区  512bytes(字节) 第二点 磁盘的分区

linux基础知识---权限

权限 一.文件的基本权限 所谓的权限就是用户访问文件的能力,文件的基本权限包括 r(读),write(写),x(可执行). 用ls -ld file 查看文件的权限属性: drwxr-xr-x 4 root root 4096 Jul  3 21:29 file drwxr-xr-x:说明文件类型,常见的文件类型有:d 目录文件,l 链接文件,c 线性设备文件,b 块设备文件,s sorket文件,- 一般文件,p 管道文件 drwxr-xr-x:此文件(目录)属主用户权限 drwxr-xr-x

(赵小明RHCE笔记)linux基础之四 权限详解

一.special permissions for executables1.special permissions for executables:  -suid:command run with permissions of the owner of the command,not executor of   the command  -sgid:command runs with group affiliation of the group of the commandeg:file:us

linux命令之——权限管理命令

linux命令之——权限管理命令 权限管理命令:chmod 英文名称:chmod 命令英文原意:change the permissions mode of a file 命令所在路径: /bin/chmod 执行权限: 所有用户 语法: chmod[{ugoa}{+-=}{rwx}][文件或目录] [mode=421][文件或目录] -R 递归修改 功能描述: 改变文件或目录权限 范例 : 方式一:   chmod u+x Japanlovestory.list      对Japanlove

Linux基础系统权限

Linux基础系统权限 文件权限 Linux中,每个文件拥有三种权限 权限 对文件的影响 对目录的影响 r(读取) 可读取文件 可列出目录内容 w(写入) 可修改文件内容 可在目录中创建删除文件 x(执行) 可以修改文件内容 可访问目录内容 注意: 目录必须拥有x权限,否则无法察看其内容 UGO linux权限基于UGO模型进行控制 U代表User, G代表Group, O代表other 每一个文件的权限基于UGO进行设置 权限三个一组(rwx), 对应UGO分别设置 每个文件都有一个拥有者/用

[Linux学习笔记] Linux常用命令 - 权限管理命令

Linux权限管理命令 1. 改变文件或目录权限: chmod 命令名称: chmod 命令英文原意: change the permissions mode of a file 命令所在路径: /bin/chmod 执行权限: 所有用户 语法: chmod [{ugo} {+-=} {rwx}] [文件或目录]             [mode=421] [文件或目录] 功能描述: 改变文件或目录权限 代表字符 权限 对文件的含义 对目录的含义 r 读权限 可以查看文件内容 可以列出目录中的

linux用户及权限管理

[文件管理.管道.用户及组管理.用户及权限管理]\用户及组管理 用户与组管理 Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统.用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问:另一方面也可以帮助用户组织文件,并为用户提供安全性保护.每个用户账号都拥有一个惟一的用户名和各自的口令.用户在登录时键入正确的用户名和口令后,就能够进入系统和自己的主目录.实现用户账号的管理