8月2日作業

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

[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# mkdir -p /date/testdir
[root@localhost testdir]# chmod 770 /date/testdir
[root@localhost testdir]# chown :g1 /date/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# setfacl -Rm g:g2:rwx /date/testdir/
[root@localhost testdir]# setfacl -Rm g:g3:rx /date/testdir/
[root@localhost testdir]# getfacl /date/testdir/
getfacl: Removing leading '/' from absolute path names
# file: date/testdir/
# owner: root
# group: g1
user::rwx
group::rwx
group:g2:rwx     //題目要求讀寫,沒有x權限也不行
group:g3:r-x     //題目要求讀權限,如果沒有x權限是不能讀的
mask::rwx
other::---

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 ~]# gpasswd sales
Changing the password for group sales
New Password: 
Re-enter new password: 
[root@localhost ~]# useradd -G sales user1
[root@localhost ~]# useradd -G sales user2
[root@localhost ~]# useradd -G sales user3
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# su - user1
[user1@localhost ~]$ touch user1.txt
[user1@localhost ~]$ ls -l user1.txt 
-rw-r--r-- 1 user1 sales 0 Jul 25 12:28 user1.txt   //查看user1創建文件默認屬組為sales
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su user2
[user2@localhost root]$ 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

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

(0)
LiiLii
上一篇 2016-08-05 16:20
下一篇 2016-08-05 21:42

相關推薦

  • 初學Linux之文本處理sed

    Sed介紹;Sed用法;Sed高級用法

    2018-01-21
  • N22-第七周作業

    1、創建一個10G分區,并格式為ext4文件系統;   (1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;   (2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳; 在擴展分區/dev/sda4下新建一個10G的分…

    Linux干貨 2016-10-25
  • 用戶和組的管理

    在Linux系統上,用戶管理是基于用戶名和密碼的方式進行資源的分配的,Linux上的用戶分為以下的類別: 管理員 : root  ,UID為0 (這個用戶有極大的權限,可以直接無視很多的限制,包括讀寫執行的權限。所以這個用戶的使用要小心,因為他的權限太大。) 普通用戶的UID:1-65535 普通用戶又可分為: 系統用戶(已經存…

    2017-04-08
  • 數據結構-線性表

    1. 線性表:n個數據元素的有序集合。 線性表是一種常用的數據結構。在實際應用中,線性表都是以棧、隊列、字符串、數組等特殊線性表的形式來使用的。由于這些特殊線性表都具有各自的特性,因此,掌握這些特殊線性表的特性,對于數據運算的可靠性和提高操作效率都是至關重要的?! 【€性表是一個線性結構,它是一個含有n≥0個結點的有限序列,對于其中的結點,有且僅有一個開始結點…

    Linux干貨 2015-04-07
  • 網絡N22期-第三周作業

    1、列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可。 [root@localhost ~]# who | cut -d" " -f1 | uniq root 2、取出最后登錄到當前系統的用戶的相關信息。 [roo…

    Linux干貨 2016-08-29
  • linux 3.26 第一課

    setup app

    2018-03-26
欧美性久久久久