
1、創建/www目錄,在/www目錄下新建name和https目錄,在name和https目錄下分別創建一個index.html文件,name下面的index.html文件中包含當前主機的主機名,https目錄下的index.html文件中包含當前主機的ip地址。
#創建/www目錄,在/www目錄下新建name和https目錄
[root@rhcsa0306 ~]# mkdir -pv /www/{name,https}#?在name和https目錄下分別創建一個index.html文件,name下面的index.html文件中包含當前主機的主機名,https目錄下的index.html文件中包含當前主機的ip地址。
[root@rhcsa0306 ~]# echo rhcsa0306 > /www/name/index.html
[root@rhcsa0306 ~]# echo 192.168.15.129 > /www/https/index.html#查看index.html文件內容
[root@rhcsa0306 ~]# cat /www/name/index.html
rhcsa0306
[root@rhcsa0306 ~]# cat /www/https/index.html
192.168.15.129
?
2、將/www目錄和name,https目錄的所屬者修改為web用戶,并且web用戶擁有所有的權限。
#新建用戶web
[root@rhcsa0306 ~]# useradd web#遞歸修改/www及其里面的目錄文件的所屬者為web
[root@rhcsa0306 ~]# chown -R web /www#查看
[root@rhcsa0306 ~]# ll /www
總用量 0
drwxr-xr-x. 2 web root 24 3月 23 14:46 https
drwxr-xr-x. 2 web root 24 3月 23 14:45 name
3、tom和jerry可以在name和https目錄下新建和刪除文件,其他用戶沒有任何權限。
#添加用戶tom和jerry
[root@rhcsa0306 ~]# useradd tom
[root@rhcsa0306 ~]# useradd jerry#設置其他用戶沒有任何權限
[root@rhcsa0306 ~]# chmod o-r /www/{https,name}
[root@rhcsa0306 ~]# chmod o-x /www/{https,name}#查看
[root@rhcsa0306 ~]# ll /www
總用量 0
drwxr-x---. 2 web root 24 3月 23 14:46 https
drwxr-x---. 2 web root 24 3月 23 14:45 name
#通過acl設置tom和jerry在name、https目錄下的權限為rwx
[root@rhcsa0306 ~]# setfacl -m u:tom:rwx /www/name
[root@rhcsa0306 ~]# setfacl -m u:tom:rwx /www/https
[root@rhcsa0306 ~]# setfacl -m u:jerry:rwx /www/https
[root@rhcsa0306 ~]# setfacl -m u:jerry:rwx /www/name
?查看ACL權限
?
4、復制/var/log/messages和/var/log/cron文件到/log目錄,admin賬號可以查看但不能修改該日志文件的內容。
#新建用戶admin
[root@rhcsa0306 ~]# useradd admin#創建/log,目錄
[root@rhcsa0306 ~]# mkdir /log
#將/var/log/messages /var/log/cron 復制到 /log
[root@rhcsa0306 ~]# cp /var/log/messages /var/log/cron /log#查看/log的權限
[root@rhcsa0306 ~]# ll /log
總用量 488
-rw-------. 1 root root 3252 3月 23 15:32 cron
-rw-------. 1 root root 495380 3月 23 15:32 messages#修改others對于/log及其子文件的權限
[root@rhcsa0306 ~]# chmod -R o=rx /log#查看
[root@rhcsa0306 ~]# ll /log
總用量 488
-rw----r-x. 1 root root 3252 3月 23 15:32 cron
-rw----r-x. 1 root root 495380 3月 23 15:32 messages
5、復制/etc/ssh/sshd_config文件到/ssh目錄,admin賬號可以查看并修改該文件內容。
#創建一個新目錄/ssh
[root@rhcsa0306 ~]# mkdir /ssh#將/etc/ssh/sshd_config 復制到 /ssh
[root@rhcsa0306 ~]# cp /etc/ssh/sshd_config /ssh#查看是否復制成功
[root@rhcsa0306 ~]# ll /ssh
總用量 4
-rw-------. 1 root root 3667 3月 23 15:48 sshd_config#修改用戶admin對于該文件的權限
[root@rhcsa0306 ~]# setfacl -m u:admin:rwx /ssh/sshd_config
??查看ACL權限
?
6、將復制過來的/ssh目錄下的sshd_config文件中的非空行寫入到/ssh/sshd文件中,將sshd_config文件中的非空行和非#號開頭的行寫入config文件中,并且admin可以查看sshd文件和config文件的內容。
#將復制過來的/ssh目錄下的sshd_config文件中的非空行寫入到/ssh/sshd文件中
[root@rhcsa0306 ~]# grep -v ^$ /ssh/sshd_config > /ssh/sshd
#將sshd_config文件中的非空行和非#號開頭的行寫入config文件中
[root@rhcsa0306 ~]# grep -v ^# /ssh/sshd > /config
?登錄admin賬號,查看sshd以及config文件內容,檢查是否有r權限