1、创建用户gentoo,附加组为bin和root,默认shell为/bin/csh,注释信息为
"Gentoo Distribution"
```
[root@han ~]# useradd -G bin,root -c "Gentoo Distribution" -s /bin/csh gentoo
```
2、创建下面的用户、组和组成员关系
名字为webs 的组
用户nginx 使用webs 作为附属组
用户varnish,也使用webs 作为附属组
用户mysql,不可交互登录系统,且不是webs 的成员, nginx, varnish,
mysql密码都是han
```
[root@han ~]# groupadd webs
[root@han ~]# useradd -G webs nginx
[root@han ~]# useradd -G webs varnish
[root@han ~]# useradd -s /sbin/nologin mysql
[root@han ~]# echo "han"|passwd --stdin nginx
[root@han ~]# echo "han"|passwd --stdin varnish
[root@han ~]# echo "han"|passwd --stdin mysql
```
3、当用户docker对/testdir 目录无执行权限时,意味着无法做哪些操作?
```
无法cd进入该目录。
```
4、当用户mongodb对/testdir 目录无读权限时,意味着无法做哪些操作?
```
不能查看该目录下的内容,即不能使用ls查看。
```
5、当用户redis 对/testdir 目录无写权限时,该目录下的只读文件file1是否可
修改和删除?
```
不能在该目录下删除和创建文件。
```
6、当用户zabbix对/testdir 目录有写和执行权限时,该目录下的只读文件file1
是否可修改和删除?
```
可修改、可删除。
```
7、复制/etc/fstab文件到/var/tmp下,设置文件所有者为tomcat读写权限,所
属组为apps组有读写权限,其他人无权限
```
[root@han ~]# cp /etc/fstab /var/tmp
[root@han ~]# chown tomcat.apps /var/tmp/fstab
[root@han ~]# chmod 660 /var/tmp/fstab
```
8、误删除了用户git的家目录,请重建并恢复该用户家目录及相应的权限属性
```
[root@han ~]# mkdir /home/git
[root@han ~]# cp -a /etc/skel/. /home/git
[root@han ~]# chown -R git:git /home/git
[root@han ~]# chmod 700 /home/git
```
9、在/testdir/dir里创建的新文件自动属于webs组,组apps的成员如:
tomcat能对这些新文件有读写权限,组dbs的成员如: mysql只能对新文
件有读权限,其它用户(不属于webs,apps,dbs)不能访问这个文件夹
```
[root@han ~]# mkdir -p /testdir/dir
[root@han ~]# groupadd webs
[root@han ~]# chgrp webs /testdir/dir
[root@han ~]# chmod g+s /testdir/dir
[root@han ~]# groupadd apps;groupadd dbs
[root@han ~]# useradd -G apps tomcat;useradd -G dbs mysql
[root@han ~]# setfacl -d -m g:apps:rw /testdir/dir
[root@han ~]# setfacl -d -m g:dbs:r /testdir/dir
[root@han ~]# chmod o= /testdir/dir
```
10、备份/testdir/dir里所有文件的ACL权限到/root/acl.txt中,清除
/testdir/dir中所有ACL权限,最后还原ACL权限
```
[root@han ~]# getfacl -R /testdir/dir/ > acl.txt
[root@han ~]# setfacl -R -b /testdir/dir
[root@han ~]# getfacl /testdir/dir
[root@han ~]# setfacl --set-file=acl.txt /testdir/dir
```