用戶組和權限管理練習題

創建⽤戶gentoo,附加組爲bin和root,默認shell爲/bin/csh,註釋信息爲 "Gentoo Distribution"

[root@magedu ~]# useradd -G bin,root -c "Gentoo Distribution" -s /bin/csh gentoo

創建下⾯的⽤戶、組和組成員關係 名字爲webs 的組 ⽤戶nginx 使⽤webs 作爲附屬組 ⽤戶varnish,也使⽤webs 作爲附屬組 ⽤戶mysql,不可交互登錄系統,且不是webs 的成員, nginx, varnish, mysql密碼都是magedu

[root@magedu ~]# groupadd webs
[root@magedu ~]# useradd -G webs nginx
[root@magedu ~]# useradd -G webs varnish
[root@magedu ~]# useradd -s /sbin/nologin mysql
[root@magedu ~]# echo "magedu"|passwd --stdin nginx
[root@magedu ~]# echo "magedu"|passwd --stdin varnish
[root@magedu ~]# echo "magedu"|passwd --stdin mysql

當⽤戶docker對/testdir ⽬錄⽆執⾏權限時,意味着⽆法做哪些操作?#
1、無法進入目錄
2、可以用ls查看列表,但是無法查看文件屬性類型
3、就算對目錄中的文件有rw權限,也無法查看和寫入>>也不行
當⽤戶mongodb對/testdir ⽬錄⽆讀權限時,意味着⽆法做哪些操作?#
1、可以進入目錄,無法查看文件列表,可以查看ll file詳細信息
2、可以執行目錄內程序,cat file可以查看文件內容
3、如果對文件有w權限,還可以通過>>寫入文件
當⽤戶redis 對/testdir ⽬錄⽆寫權限時,該⽬錄下的只讀⽂件file1是否可修改和刪除?
不能在該目錄下刪除和創建文件。
當⽤戶zabbix對/testdir ⽬錄有寫和執⾏權限時,該⽬錄下的只讀⽂件file1是否可修改和刪除?#
不能改、可刪除。
複製/etc/fstab⽂件到/var/tmp下,設置⽂件所有者爲tomcat讀寫權限,所屬組爲apps組有讀寫權限,其他⼈⽆權限

[root@magedu ~]# cp /etc/fstab /var/tmp
[root@magedu ~]# chown tomcat.apps /var/tmp/fstab
[root@magedu ~]# chmod 660 /var/tmp/fstab

誤刪除了⽤戶git的家⽬錄,請重建並恢復該⽤戶家⽬錄及相應的權限屬性

[root@magedu ~]# cp -a /etc/skel/ /home/git
[root@magedu ~]# chown -R git.git /home/git
[root@magedu ~]# chmod -R 700 /home/git

在/testdir/dir⾥創建的新⽂件⾃動屬於webs組,組apps的成員如:##tomcat能對這些新⽂件有讀寫權限,組dbs的成員如: mysql只能對新⽂件有讀權限,其它⽤戶(不屬於webs,apps,dbs)不能訪問這個⽂件夾

[root@magedu ~]# mkdir -p /testdir/dir
[root@magedu ~]# groupadd webs
[root@magedu ~]# groupadd apps
[root@magedu ~]# groupadd dbs
[root@magedu ~]# useradd tomcat
[root@magedu ~]# useradd mysql
[root@magedu ~]# chgrp -R webs /testdir/dir
[root@magedu ~]# chmod -R g+s /testdir/dir
[root@magedu ~]# gpasswd -a tomcat apps
[root@magedu ~]# gpasswd -a mysql dbs
[root@magedu ~]# useradd -G apps tomcat
或者 groupmems -g apps -a tomcat
[root@magedu ~]# useradd -G dbs mysql
或者 groupmems -g dbs -a mysql
[root@magedu ~]# setfacl -R -m g:apps:rw /testdir/dir
[root@magedu ~]# setfacl -R -m g:dbs:r /testdir/dir
[root@magedu ~]# setfacl -R -m o::0 /testdir/dir

備份/testdir/dir⾥所有⽂件的ACL權限到/root/acl.txt中,清除/testdir/dir中所有ACL權限,最後還原ACL權限

[root@magedu ~]# getfacl -R /testdir/dir/ > /root/acl.txt
[root@magedu ~]# setfacl -R -b /testdir/dir
[root@magedu ~]# getfacl /testdir/dir
[root@magedu ~]# setfacl -R --set-file=/root/acl.txt /testdir/dir
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章