M20-1權限作業

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

[root@centos7 testdir]# ls -ld /testdir/
drwxr-xrw-. 3 root root 27 Aug  5 08:38 /testdir/
[root@centos7 testdir]# su xiaoming
[xiaoming@centos7 testdir]$ ls
ls: cannot open directory .: Permission denied
[xiaoming@centos7 testdir]$ cd dir
bash: cd: dir: Permission denied
[xiaoming@centos7 testdir]$ ll /testdir
ls: cannot access /testdir/file: Permission denied
ls: cannot access /testdir/dir: Permission denied
total 0
?????????? ? ? ? ?            ? dir
?????????? ? ? ? ?            ? file
[xiaoming@centos7 testdir]$ rm -rf dir
rm: cannot remove ‘dir’: Permission denied
[xiaoming@centos7 testdir]$ rm -f file
rm: cannot remove ‘file’: Permission denied
[xiaoming@centos7 testdir]$

從上訴實驗可知,不能ls查看此目錄和目錄元數據,不能cd切換到此目錄中,也不能刪除目錄中的文件文件夾
2、當用戶xiaoming對/testdir 目錄無讀權限時,意味著無法做哪些操作?

[root@centos7 testdir]# chmod o=wx /testdir/
[root@centos7 testdir]# ls -ld /testdir/
drwxr-x-wx. 3 root root 27 Aug  5 08:38 /testdir/
[root@centos7 testdir]# su xiaoming
[xiaoming@centos7 testdir]$ ls
ls: cannot open directory .: Permission denied
[xiaoming@centos7 testdir]$ rm -rf file
[xiaoming@centos7 testdir]$ rm -rf dir
rm: cannot remove ‘dir/f1’: Permission denied
rm: cannot remove ‘dir/f2’: Permission denied
[xiaoming@centos7 testdir]$

從上訴實驗可知,不能ls查看,但可以刪除目錄中文件,不能刪除目錄中的目錄及文件

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

[root@centos7 testdir]# ls -ld /testdir/
drwxr-xr-x. 2 root root 17 Aug  5 13:05 /testdir/
[root@centos7 testdir]# su wang
[wang@centos7 testdir]$ ls
file
[wang@centos7 testdir]$ rm -f file
rm: cannot remove ‘file’: Permission denied
[wang@centos7 testdir]$ echo aaaaa>>file
bash: file: Permission denied
[wang@centos7 testdir]$

從上訴實驗可知,不能刪除和修改此文件

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

[root@centos7 ~]# groupadd sysadmins
[root@centos7 ~]# getent group sysadmins
sysadmins:x:10012:
[root@centos7 ~]# cp /etc/fstab  /var/tmp/
[root@centos7 ~]# chown wang.sysadmins /var/tmp/fstab
[root@centos7 ~]# ll /var/tmp/fstab
-rw-r--r--. 1 wang sysadmins 507 Aug  5 13:11 /var/tmp/fstab
[root@centos7 ~]#

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

[root@centos7 ~]# cp /etc/skel/. /home/wang/ -r
[root@centos7 ~]# cd /home/wang
[root@centos7 wang]# ls -a
.  ..  .bash_logout  .bash_profile  .bashrc  .mozilla
[root@centos7 wang]# cd ../
[root@centos7 home]# ls -ld ./wang
drwxr-xr-x. 3 root root 74 Aug  5 13:13 ./wang
[root@centos7 home]# chown -R  wang.wang ./wang
[root@centos7 home]# chmod 700 ./wang/
[root@centos7 home]# ll
total 12
drwx------. 6 gentoo   gentoo   4096 Aug  4 13:36 gentoo
drwx------. 5 hadoop   hadoop   4096 Aug  3 22:17 hadoop
drwx------. 3 wang     wang       74 Aug  5 13:13 wang
drwx------. 5 xiaoming xiaoming 4096 Aug  5 09:54 xiaoming

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

[root@centos7 ~]# useradd user1
[root@centos7 ~]#
[root@centos7 ~]# su user1
[user1@centos7 root]$ cd
[user1@centos7 ~]$
[user1@centos7 ~]$ vi ~/.bashrc
[user1@centos7 ~]$ umask
0002
[user1@centos7 ~]$ . ~/.bashrc
[user1@centos7 ~]$ umask
0066
[user1@centos7 ~]$ touch file.txt
[user1@centos7 ~]$ ll file.txt
-rw-------. 1 user1 user1 0 Aug  5 13:27 file.txt

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

[root@centos7 testdir]# touch f1
[root@centos7 testdir]# ll
total 0
-rw-r--r--. 1 root root 0 Aug  5 13:34 f1
-rw-r--r--. 1 root root 0 Aug  5 13:05 file
[root@centos7 testdir]# setfacl -m u:user1:0,g:g1:rw /testdir/f1
[root@centos7 testdir]# getfactl /testdir/f1
bash: getfactl: command not found...
[root@centos7 testdir]# getfacl /testdir/f1
getfacl: Removing leading '/' from absolute path names
# file: testdir/f1
# owner: root
# group: root
user::rw-
user:user1:---
group::r--
group:g1:rw-
mask::rw-
other::r--

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

[root@centos7 testdir]# mkdir dir
[root@centos7 testdir]# ll
total 4
drwxr-xr-x. 2 root root 6 Aug  5 13:39 dir
-rw-rw-r--+ 1 root root 0 Aug  5 13:34 f1
-rw-r--r--. 1 root root 0 Aug  5 13:05 file
[root@centos7 testdir]# setfacl -m d:u:user1:rw ./dir/
[root@centos7 testdir]# setfacl -m d:g:g1:0 ./dir/
[root@centos7 testdir]# getfacl ./dir/
# file: dir/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:user1:rw-
default:group::r-x
default:group:g1:---
default:mask::rwx
default:other::r-x

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

[root@centos7 testdir]# rm -rf /data/testdir/
[root@centos7 testdir]#
[root@centos7 testdir]# mkdir -p /data/testdir/
[root@centos7 testdir]# ll /data/testdir/
total 0
[root@centos7 testdir]# ls -ld /data/testdir/
drwxr-xr-x. 2 root root 6 Aug  5 13:44 /data/testdir/
[root@centos7 testdir]# useradd alice
[root@centos7 testdir]# useradd tom
[root@centos7 testdir]# chmod g+s /data/testdir/
[root@centos7 testdir]# ls -ld /data/testdir/
drwxr-sr-x. 2 root root 6 Aug  5 13:44 /data/testdir/
[root@centos7 testdir]# chown .g1 /data/testdir/
[root@centos7 testdir]# ls -ld /data/testdir/
drwxr-sr-x. 2 root g1 6 Aug  5 13:44 /data/testdir/
[root@centos7 testdir]# gpasswd -g g2 -a alice
Adding user alice to group g2
[root@centos7 testdir]# gpasswd -g g3 -a tom
Adding user tom to group g3
[root@centos7 testdir]# setfacl -m d:g:g2:rw /data/testdir/
[root@centos7 testdir]# setfacl -m d:g:g3:r /data/testdir/
[root@centos7 testdir]# getfacl /data/testdir/
getfacl: Removing leading '/' from absolute path names
# file: data/testdir/
# owner: root
# group: g1
# flags: -s-
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::r-x
default:group:g2:rw-
default:group:g3:r--
default:mask::rwx
default:other::r-

每天總結博客地址:http://purify.blog.51cto.com/

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

(0)
alrenalren
上一篇 2016-08-05
下一篇 2016-08-05

相關推薦

  • 很認真的第十三周作業哦

    1、建立samba共享,共享目錄為/data,要求:(描述完整的過程) mkdir /data #建立共享目錄 1)共享名為shared,工作組為magedu vim /etc/samba/smb.conf 修改 workgroup = MYGROUP 為 workgroup = magedu 修改 passdb backend = tdbsam 為 pas…

    Linux干貨 2017-03-27
  • 初識 vi/vim文本編輯器

    我們操作文件,終究離不開編輯文件,對文件內容的編輯,Linux系統下,我們通常使用VI/VIM來編輯文件。VI是每個Linux都會自帶的文本編輯器,VIM是VI的增強版,現在的最新版都已自帶,但是可能有些發行版本沒有自帶,可以使用sudo apt-get install vim命令安裝vim。 可以使用vi或者vim命令直接進入新的文本文件,或者vim 文件…

    Linux干貨 2017-07-29
  • 第一次作業

    第一次作業 作業1 博客 作業2 echo -e "\033[49;31;4;5m*******\033[0m \n\033[49;32;4;5m ***** \033[0m \n\033[49;33;4;5m  ***  \033[0m \n\033[49;34;4;5m   *   \033[0m&quo…

    Linux干貨 2016-08-03
  • 遷移home到獨立分區

    1,fdisk ?/dev/sda ?創建10G的分區 Lsblk?查看下新創建分區是否同步 partx ?-a ?/dev/sda 同步 2,mkfs.ext4 ?/dev/sda6? -L? /home 創建文件系統跟卷標 3,mkdir ?/mnt/home ?創建一個掛載點 mount ?/dev/sda6??/mnt/home 掛載 4,cp? -…

    2017-12-14
  • N_28包管理器(rpm)及前端管理工具(yum)

    1、簡述rpm與yum命令的常見選項,并舉例 rpm–>RPM package manager 是一種用于redhat發行版的打包及安裝管理工具,現在成為linux領域包管理器的行業標準,包名以.rpm為后綴。 用法: rpm [options] PACKAGE_FILE 常用選項: -i:安裝rmp包 -v:顯示安裝過程 -vv:更加詳細…

    Linux干貨 2018-01-01
  • Btrfs文件系統

    btrfs文件系統特性: 1、多物理卷支持 Btrfs可由多個底層物理卷組成:支持raid,以聯機添加,移除,修改 2、寫時復制機制(cow) ????復制,更新及替換指針,而非就地更新。在文件進行修改的時候,首先將文件復制一份出來,在復制的文件中進行修改,修改完成后,將指向原有文件的指針指向到修改完成的文件上,若修改完成的文件出現錯誤,則我們可以通過源文件…

    2016-04-10
欧美性久久久久