用戶權限以及組權限作業

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 16:14
下一篇 2016-08-08 16:15

相關推薦

  • Apache、nginx 、lighttpd性能比較

    1. web服務器簡介 1. lighttpd      Lighttpd是一個德國人領導的開源軟件,其根本的目的是提供一個專門針對高性能網站,安全、快速、兼容性好并且靈活的Web server環境         Lighttpd是一個具有非常低的…

    Linux干貨 2015-04-10
  • linux學習筆記: shell腳本編程相關(上)

    前言 unix/linux操作系統下的shell,是一種殼,其目的是提供一個用戶與計算機相互交互的命令接口,通過輸入各種命令,達到操作的目的。 與此同時,shell支持控制流程,進而可以組合出各種各樣的應用實例。 shell腳本的格式  首行shebang機制:  bash腳本,首行添加#!/bin/bash&nbsp…

    Linux干貨 2017-04-18
  • N25-第十周

    1、請詳細描述CentOS系統的啟動流程(詳細到每個過程系統做了哪些事情) 一、內核空間詳細過程如下: POST –> BootSequence(BIOS) –> Bootloader(MBR) –> kernel(ramdisk) –> rootfs(只讀) –> /sbin/init(systemd) 1.POST:(pow…

    Linux干貨 2017-05-30
  • 0804練習與作業

    0804練習與作業 練習  1 、找出ifconfig 命令結果中本機的所有IPv4 地址 答: 使用cut將電腦的IP地址提取出來。   經過觀察,這些信息極為不規則,沒有明顯的分隔符。這時們需要首先提取出IP地址所在的行,然后去定義一個合適的分隔符,再利用cut進行提取即可。(思路:化繁為簡,化不規則為規則,這樣才能更好的套用我們的命…

    Linux干貨 2016-08-08
  • 測試

    3、查詢file.txt以abc結尾的行grep "abc$" file.txt4、刪除file.txt文件中的空行grep -v '^$' file.txt > file.txtsed '/^$/d' file.txt > file.txt(覆蓋重定向文件變為空該文件為空,但是追加時正常成功?!?/p>

    Linux干貨 2016-06-12
  • linux基礎學習第十一天(shell循環、軟件包管理)

    2016-08-16 授課內容: shell腳本基礎:循環,for,while,until(未講完) 軟件包管理(未講完): ?軟件運行環境 ?軟件包基礎 ?Rpm包管理 循環執行 將某代碼段重復運行多次 重復運行多少次: 循環次數事先已知 循環次數事先未知 有進入條件和退出條件 循環控制語句: break:【提結束循環,循環將不再執行】指前面的循環退出,退…

    Linux干貨 2016-08-18
欧美性久久久久