0803作業

課上練習

1.當用戶xiaoming 對/testdir  目錄無執行權限時,意味著無法做哪些操作?

 drwxr-xr–. 14 root root 4096 Aug  3 13:35 /testdir

[xiaoming@localhost ~]$ touch /testdir/f1
touch: cannot touch ‘/testdir/f1’: Permission denied                      不能創建
[xiaoming@localhost ~]$ ll /testdir/aa
ls: cannot access /testdir/aa: Permission denied                          不能訪問
[xiaoming@localhost ~]$ cd /testdir
-bash: cd: /testdir: Permission denied                                    不能進入
[xiaoming@localhost ~]$ rm /testdir/aa
rm: cannot remove ‘/testdir/aa’: Permission denied                        不能刪除

2.當用戶xiaoqiang 對/testdir  目錄無讀權限時,意味著無法做哪些操作?

 drwxr-x-wx. 14 root root 4096 Aug  3 18:24 /testdir

[xiaoqiang@localhost ~]$ cd /testdir
[xiaoqiang@localhost testdir]$ ls
ls: cannot open directory .: Permission denied                        不能看里面文件名
[xiaoqiang@localhost ~]$ echo word > /testdir/x1
[xiaoqiang@localhost ~]$ echo word2 >> /testdir/x1
[xiaoqiang@localhost ~]$ cat /testdir/x1
word
word2
[xiaoqiang@localhost ~]$ rm /testdir/x1
[xiaoqiang@localhost ~]$ rm /testdir/file1
rm: remove write-protected regular file ‘/testdir/file1’? y       
//目錄權限w:可以創建或刪除目錄中文件,配合x(無視文件的權限,因為文件是目錄中的內容,一個名字)

3.當用戶wangcai  對/testdir  目錄無寫權限時,該目錄下的只讀文件file1 是否能修改和刪除?

 drwxr-xr–. 14 root root 4096 Aug  3 18:24 /testdir

 -r–r–r–. 1 root root 0 Aug  3 18:24 file1

[wangcai@localhost ~]$ echo hello > /testdir/file1
-bash: /testdir/file1: Permission denied
[wangcai@localhost ~]$ echo hello >> /testdir/file1           不能修改
-bash: /testdir/file1: Permission denied
[wangcai@localhost ~]$ rm /testdir/file1
rm: cannot remove ‘/testdir/file1’: Permission denied         不能刪除

4.復制/etc/fstab 文件到/var/tmp 下,設置文件所有者為wangcai 讀寫權限,所屬組為sysadmins 組有讀寫權限,其他人無權限

[root@localhost ~]# cp /etc/fstab /var/tmp/
[root@localhost ~]# chown wangcai.sysadmins /var/tmp/fstab 
[root@localhost ~]# chmod ug=rw,o= /var/tmp/fstab
[root@localhost ~]# ll /var/tmp/fstab       
-rw-rw----. 1 wangcai sysadmins 465 Aug  3 18:13 /var/tmp/fstab


5.誤刪除了用戶wangcai 的家目錄,請重建并恢復該用戶家目錄及相應的權限屬性

 mkdir /home/wangcai
 cp -r /etc/skel/.[^.]* /home/wangcai
 chmod 700 /home/wangcai/

作業

在/data/testdir 里創建的新文件自動屬于g1 組,組g2 的成員如:alice 能對這些新文件有讀寫權限,組g3 的成員如:

tom 只能對新文件有讀權限,其它用戶(不屬于g1,g2,g3)不能訪問這個文件夾

[root@localhost ~]# mkdir -p /data/testdir 
[root@localhost ~]# groupadd g1
[root@localhost ~]# groupadd g2
[root@localhost ~]# groupadd g3
[root@localhost ~]# cd /data
[root@localhost data]# chgrp g1 testdir/
[root@localhost data]# chmod 2770 testdir/
[root@localhost data]# ll -d testdir/     
drwxrws---. 2 root g1 6 Aug  3 19:15 testdir/
[root@localhost data]# setfacl -m g:g2:rwx testdir/    //g2組用戶能進到testdir目錄
[root@localhost data]# setfacl -m g:g3:rwx testdir/    //g3組用戶能進到testdir目錄
[root@localhost data]# setfacl -m d:g:g2:rw testdir/
[root@localhost data]# setfacl -m d:g:g3:r testdir/
[root@localhost data]# gpasswd -a alice g2
Adding user alice to group g2
[root@localhost data]# gpasswd -a tom g3
Adding user tom to group g3
[root@localhost data]# su alice
[alice@localhost data]$ cd testdir/
[alice@localhost testdir]$ touch f
[alice@localhost testdir]$ getfacl f
# file: f
# owner: alice
# group: g1
user::rw-
group::rwx                      #effective:rw-
group:g2:rw-
group:g3:r--
mask::rw-
other::---

設置/testdir/f1的權限,使user1用戶不可以讀寫執行,g1組可以讀寫

/testdir/dir的權限,使新建文件自動具有acl權限:user1:rw,g1:— 

備份/testdir目錄中所有文件的ACL,清除/testdir的所有ACL權限,并利用備份還原

cd /testdir
touch f1
setfacl -m u:user1:0 f1
mkdir dir
setfacl -m g:g1:rw dir
setfacl -m d:u:user1:rw dir
setfacl -m d:g:g1:0 dir 
touch dir/{aa,bb,cc}
getfacl -R dir/ > /bak/bak.acl   
setfacl -R -b *
setfacl -R --set-file=/bak/bak.acl /testdir/dir/

設置user1,使之新建文件權限為rw——-

[user1@localhost ~]$ umask 0066


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

(0)
victorycommandervictorycommander
上一篇 2016-08-04 08:25
下一篇 2016-08-04 11:48

相關推薦

  • bash代碼注入的安全漏洞

           很多人或許對上半年發生的安全問題“心臟流血”(Heartbleed Bug)事件記憶頗深,這兩天,又出現了另外一個“毀滅級”的漏洞——Bash軟件安全漏洞。這個漏洞由法國GNU/Linux愛好者Stéphane Chazelas所發現。隨后,美國電腦緊急應變中心(US-CERT)、紅帽以及多家從事安全的公…

    Linux干貨 2015-03-30
  • 簡述動靜分離

        今天來簡述一下如何實現wordpress的動靜分離以及讀寫分離      首先來放出大圖。   1.來看圖說話     首先來介紹一下這張圖    最前端的兩臺機器是  負責調度后端主機請求動…

    2017-05-18
  • OpenSSL 的使用

    OpenSSL 是一個開源項目,其組成主要包括一下三個組件:     openssl:多用途的命令行工具     libcrypto:加密算法庫     libssl:加密模塊應用庫,實現了ssl及tls openssl可以實現:秘鑰證書管…

    Linux干貨 2017-06-07
  • 進程管理工具

    進程管理工具 kill man 7 signal 1) SIGHUP: 無須關閉進程而讓其重讀配置文件 kill -1 進程編號 2) SIGINT: 中止正在運行的進程;相當于Ctrl+c 9) SIGKILL: 殺死正在運行的進程 再生進程 kill -9 殺不掉 15) SIGTERM:終止正在運行的進程 kill -15/或不寫(默認) +進程編號?!?/p>

    Linux干貨 2016-09-11
  • N25第一周作業

    一.計算機基礎知識     1.計算機是什么?         計算機是一種能夠按照指令對各種信息進行自動加工和處理的電子設備     2.計算機的組成?       &…

    Linux干貨 2016-12-06
  • 關于生命中出現的那個男人

    絕對真男人     一個人的一生,會遇到很多很多的男人,哦,也會遇到很多很多的女人,但是我們今天就談談男人吧.在這蕓蕓眾生中對于我們這些志向于在linux求發展謀生存的人來說,有個男人會是所有linux愛好者的良師益友.這個男人就是man,這個男人是絕對的男人,因為他是在linux這個系統中無所不知的那個男人. &nb…

    Linux干貨 2016-10-27

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-08-04 10:36

    每一步都寫的很詳細,但是能把操作結果總結成一句話就更好的。

欧美性久久久久