8.2日作業

8.2作業

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

  先將文件目錄的屬組變更為g1 ,chmod  g+s /data/testdir/     setfacl -m -g:g2 -u:alice 666 /data/testdir/    setfacl -d -g:g3 -u:tom 444 /data/testdir/    chmod o-r /data/testdir  

  

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

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

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

user2將用戶user3從sales組移除

刪除sales,user1,user2

groupadd  sales -g 3000 

echo centos | gpasswd –stdin

gpasswd -A user2 sales

3、三種權限,三種特殊,acl,chattr 總結

 三種普通文件權限因為只影響對應的用戶,所以不在此一一贅述。

 不過普通表達式在這里列出

  chmod u= 或 chomod +/_

  chmod g= 或 chmod  +/-

  chmod o= 或 chmod  +/- 

 三種特殊權限相對就復雜了。

 SUID :僅影響文件,作用在目錄上將失效 ,僅影響該文件的屬主以外的人的權限,一般若是普通用戶具有了SUID權限將會非常危險。

 SGID:影響目錄或者文件的屬主以外的人的權限,對此目錄或文件有寫權限的用戶創建的新文件的屬組將自動變更為原文件或目錄的屬組。

 STicky: 是粘貼模式,僅影響其他用戶的權限,其他除屬主及root之外的用戶將無法刪除文件,僅用于文件,用于目錄將失效。

 表達式不予列出

 acl權限是影響除其他用戶和文件屬主、屬組的用戶權限的一種進程管理列表。

 生效順序:所有者,自定義用戶,自定義組,其他人

 

為多用戶或者組的文件和目錄賦予訪問權限rwx

mount -o acl /directory

getfacl file |directory

setfacl -m u:wang:rwx file|directory

setfacl -Rm g:sales:rwX directory

setfacl -M file.acl file|directory

setfacl -m g:salesgroup:rw file| directory

setfacl -m d:u:wang:rx directory

setfacl -x u:wang file |directory

setfacl -X file.acl directory

ACL文件上的group權限是mask 值(自定義用戶,自定義組

,擁有組的最大權限),而非傳統的組權限

getfacl 可看到特殊權限:flags

v 默認ACL權限給了x,文件也不會繼承x權限。

base ACL 不能刪除

setfacl k dir 刪除默認ACL權限

vsetfacl b file1清除所有ACL權限

getfacl file1 | setfacl setfile=- file2 復制file1

acl權限給file2


 

 

 

v mask只影響除所有者和other的之外的人和組的最大權限

Mask需要與用戶的權限進行邏輯與運算后,才能變成有限的權限

(Effective Permission)

用戶或組的設置必須存在于mask權限設定范圍內才會生效。

setfacl -m mask::rx file

v –set選項會把原有的ACL項都刪除,用新的替代,需要注意的 是一定要包含UGO的設置,不能象m一樣只是添加ACL就可以. 如:

setfacl –set u::rw,u:wang:rw,g::r,o:: file1

     chattr +i 不能刪除,改名,更改

chattr +a 只能增加

        lsattr 顯示特定屬性

附加練習:新建系統組mariadb,新建系統用戶user1,屬于maridb,要求其沒有家目錄,且shell為/sbin/nologin:嘗試root切換至用戶,查看其命令提示符

      groupadd mariadb   useradd user1 

      usermod -aG mariadb user1 

      usermod -s user1 /sbin/nologin 

      su – user1 

      cat /etc/passwd

      

     2.新建GID為5000的組mageedu,新建用戶為gentoo,要求其家目錄為/users/gentoo,密碼同用戶名

      groupadd -g 5000 mageedu

      useradd gentoo

      usermod -d /users/gentoo

       echo "gentoo "|passwd –stdin gentoo

      3.新建用戶fedora,其家目錄為/users/fedora,密碼痛用戶名

       useradd -d /users/fedora fedora 

       echo "fedora" | passwd –stdin fedora 

      4.新建用戶www,其家目錄為/ users/www;刪除www用戶,但保留其家目錄

       useradd -d /users/www www

       userdel www

      5.為用戶gentoo和fedora新增附加組mageedu;

       usermod -aG mageedu gentoo , fedora 

      6.復制目錄/var/log至/tmp/目錄,修改/tmp/log及其內部所有文件的屬組為mageedu,并讓屬組對目錄本身擁有寫權限。

              cp  /var/log /tmp/

        chgrp mageedu /tmp/log   chmod g+w /tmp/log 

              

             

原創文章,作者:sjfbjs,如若轉載,請注明出處:http://www.www58058.com/30604

(1)
sjfbjssjfbjs
上一篇 2016-08-08 16:14
下一篇 2016-08-08 16:14

相關推薦

  • hadoop分布式集群

    分布式集群的實現 環境: 192.168.36.129 ? node1:NN,SNN,RM ?192.168.36.130 ?node2:DN,NM 192.168.36.132 ? node3:DN,NM 192.168.36.133 ? node4:DN,NM 配置java環境,每個節點時間同步,基于主機名互相通信,定義/etc/hosts 文件 &nb…

    2017-12-09
  • ?N22-℡浮生.若夢 ╮第五周作業

    1、顯示當前系統上root、fedora或user1用戶的默認shell; ~]# grep -E "^(root|user1|fedora)" /etc/passwd |cut -d: -f1,7 root:/bin/bash user1:/bin/bash fedo…

    Linux干貨 2016-10-09
  • CentOS計劃任務詳解

    一、計劃任務應用場景:        需要每天對服務器上的數據進行備份,但是白天服務器的訪問量較大,服務器承受著較大的壓力,備份任務只能在夜晚服務器較空閑時才能進行。或者需要臨時在某時間點執行一個任務等,都需要用到計劃任務的功能。 二、計劃任務分類:    &…

    Linux干貨 2016-09-09
  • find命令用法詳解

    find

    2017-10-29
  • Lvm的創建

    一、LVM相關基礎: ????PE:類似與磁盤的block,這個的大小也會影響VG的大小 ????PV:是磁盤分區或邏輯上與磁盤分區具有相同功能的設備(RAID),是LVM的基本存儲模塊,但與基本的物理存儲模塊相比,卻包含有lvm相關的參數 ????VG:類似于非lvm系統中的物理磁盤,包含多個pv ????LV:類似于非lvm系統中的磁盤分區 ? PV相關…

    2016-04-10
  • 壓縮與解壓

        compress 命令使用“Lempress-Ziv”編碼壓縮數據文件。compress是個歷史悠久的壓縮程序,文件經它壓縮后,其名稱后面會多出”.Z”的擴展名。當要解壓縮時,可執         &nbsp…

    2017-08-14
欧美性久久久久