用戶權限以及組權限作業

1、在/data/testdir里創建的新文件自動屬于g1組,組g2的成員如:alice能對這些新文件有讀寫權限,組g3的成員如:tom只能對新文件有讀權限,其它用戶(不屬于g1,g2,g3)不能訪問這個文件夾。

[root@localhost testdir]# mkdir -p /data/testdir
[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# chgrp g1 /data/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# chmod g+s /data/testdir
[root@localhost testdir]# setfacl -Rm d:g:g2:rwx /data/testdir
[root@localhost testdir]# setfacl -Rm d:g:g3:r /data/testdir
[root@localhost testdir]# getfacl /data/testdir

2、創建組sales,gid 3000,passwd:centos,sales admins:user2

將用戶user1,user2,user3加入到sales輔助組

希望user1 創建新文件 默認的所屬組為sales

user2將用戶user3從sales組移除

刪除sales,user1,user2

[root@localhost ~]# groupadd -g 3000 sales
[root@localhost ~]# echo centos > gpasswd --stdin sales
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# gpasswd -a user1 sales
[root@localhost ~]# gpasswd -a user2 sales
[root@localhost ~]# gpasswd -a user3 sales
[root@localhost ~]# su - user1
Last login: Sat Aug  6 15:28:56 CST 2016 on pts/0
[user1@localhost ~]$ touch a.txt
[user1@localhost ~]$ ll !$
ll a.txt
-rw-r--r--. 1 user1 sales 0 Aug  6 15:38 a.txt
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su - user2
Last login: Fri Aug  5 21:37:49 CST 2016 on pts/0
[user2@localhost ~]$ gpasswd -d user3 sales
Removing user user3 from group sales
[user2@localhost ~]$ exit
logout
[root@localhost ~]# userdel -r user1
userdel: group user1 not removed because it is not the primary group of user user1.
[root@localhost ~]# userdel -r user2
[root@localhost ~]# groupdel sales
[root@localhost ~]# tail -3 /etc/passwd 
wangcai:x:1006:1006::/home/wangcai:/bin/bash
gentoo:x:1007:1007:Gentoo Distribution:/home/gentoo:/bin/csh
user3:x:1010:1010::/home/user3:/bin/bash
[root@localhost ~]# tail -3 /etc/group
g3:x:3003:
user1:x:1008:
user3:x:1010:

原創文章,作者:皺 多利亞,如若轉載,請注明出處:http://www.www58058.com/29861

(0)
皺 多利亞皺 多利亞
上一篇 2016-08-08
下一篇 2016-08-08

相關推薦

  • 第十四周作業

    系統的INPUT和OUTPUT默認策略為DROP; 1、限制本地主機的web服務器在周一不允許訪問;新請求的速率不能超過100個每秒;web服務器包含了admin字符串的頁面不允許訪問;web服務器僅允許響應報文離開本機; ]# iptables -P INPUT DROP #INPUT默認策略為DROP ]# iptables -P OUTPUT DROP…

    Linux干貨 2017-04-12
  • linux第一天,不正經的感想

    課是正經課,人正不正經就不知道了

    2018-03-26
  • 初識 vi/vim文本編輯器

    我們操作文件,終究離不開編輯文件,對文件內容的編輯,Linux系統下,我們通常使用VI/VIM來編輯文件。VI是每個Linux都會自帶的文本編輯器,VIM是VI的增強版,現在的最新版都已自帶,但是可能有些發行版本沒有自帶,可以使用sudo apt-get install vim命令安裝vim。 可以使用vi或者vim命令直接進入新的文本文件,或者vim 文件…

    Linux干貨 2017-07-29
  • LVS 之 初識LVS

    LVS 之 初識LVS LVS 之 初識LVS 0x00 概述 0x01 LVS拓撲結構圖: lvs集群類型中的術語 : 0x02 lvs-type lvs-nat lvs-dr lvs-tun lvs-fullnat : 0x03 調度算法(scheduler) 0x00 概述 LVS : Linux Virtual Server lvs 工作在 IOS …

    2017-05-11
  • LVM

    LVM是 Logical Volume Manager(邏輯卷管理)的簡寫,它是Linux環境下對磁盤分區進行管理的一種機制,它由Heinz Mauelshagen在Linux 2.4內核上實現,目前最新版本為:穩定版1.0.5,開發版 1.1.0-rc2,以及LVM2開發版。Linux用戶安裝Linux操作系統時遇到的一個常見的難以決定的問題就是如何正確地…

    Linux干貨 2016-12-17
  • iptables 入門

    iptables簡單介紹    其實就是大家所熟知的基于命令行的防火墻工具,它使用規則鏈來允許或是阻止收發報文。當一條網絡連接試圖在你的系統中建立連接時,iptablels會查找其對應的匹配規則。如果找不到,iptables將對其采取默認的規則。  iptables基本的用法和常用代碼 # iptables -vnL …

    Linux干貨 2017-03-15
欧美性久久久久