8月3日課堂練習及課后作業

課堂練習

1、創建用戶gentoo,附加組為bin和root,默認shell為/bin/csh,注釋信息為“Gentoo Distribution”

useradd -G bin,root -s /bin/csh -c "Gentoo Distribution" gentoo 8月3日課堂練習及課后作業

2、創建下面的用戶、組和組成員關系,名字為admins的組,用戶natasha,使用admins作為附屬組。用戶harry,也使用admins作為附屬組。用戶sarah,不可交互登錄系統,且不是admins的成員,natasha,harry,sarah密碼都是centos

注意:新建用戶,讓他不可交互登錄系統,useradd –s /sbin/nologin 用戶名 修改的時候,usermod –s /sbin/nologin 用戶名 修改密碼:passwd 用戶名

8月3日課堂練習及課后作業

3、當用戶xiaoming對/testdir目錄無執行權限時,意味著無法做哪些操作?當用戶小強對/testdir目錄無讀權限時,意味著無法做哪些操作?對用戶wangcai對/testdir目錄無寫權限時,該目錄下的只讀文件file1是否可修改和刪除?復制/etc/fstab文件到/var/tmp下,設置文件所有者為wangcai讀寫權限,所屬組為sysadmins組有讀寫權限,其他人無權限。誤刪除了用戶wangcai的家目錄,請重建并恢復該用戶家目錄及相應的權限屬性

無執行權限時,無法進入目錄和無法查看目錄

無讀權限時,能進入目錄但無法查看里面的內容

無寫權限時,不能對目錄下的文件修改和刪除

有寫權限時,可以對目錄下的文件修改和刪除

8月3日課堂練習及課后作業

8月3日課堂練習及課后作業

課后作業

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

[user1@localhost k]$ cd
[user1@localhost ~]$ echo $(umask -p 066) >> .bashrc
[user1@localhost ~]$ cat .bashre
cat: .bashre: No such file or directory
[user1@localhost ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
u=rwx,g=x,o=x
[user1@localhost ~]$ 
[user1@localhost ~]$ 
[user1@localhost ~]$ 
[user1@localhost ~]$ . .bashrc 
[user1@localhost ~]$ touch l
[user1@localhost ~]$ ll
total 0
-rw------- 1 user1 user1  0 Aug  3 21:54 f1
-rw------- 1 user1 user1  0 Aug  3 21:54 f2
drwx--x--x 2 user1 user1 14 Aug  3 21:54 k
-rw------- 1 user1 user1  0 Aug  3 21:57 l
[user1@localhost ~]$ history

2、設置/testdir/f1的權限,使user1用戶不可以讀寫執行,g1組可以讀寫/testdir/dir的權限,使新建文件自動具有acl權限:user1:rw,g1:—備份/testdir目錄中所有文件的ACL,清除/testdir的所有ACL權限,并利用備份還原。

-rw-r--rw- 1 root root  0 Aug  3 22:04 dir
drwxr-xr-x 4 root root 22 Jul 28 14:51 dir2x
drwxr-xr-x 2 root root  6 Jul 28 14:51 dir2y
-rw-r--r-- 1 root root  0 Aug  3 22:03 f1
-rw-r--r-- 1 root root  0 Aug  3 20:38 file1
[root@localhost testdir]# setfacl -m u:user1:0 f1
[root@localhost testdir]# getfacl f1
  # file: f1
  # owner: root
  # group: root
user::rw-
user:user1:---
group::r--
mask::r--
other::r--

[root@localhost testdir]# su - user1
Last login: Wed Aug  3 21:53:23 CST 2016 on pts/0
[user1@localhost ~]$ cd /testdir/
[user1@localhost testdir]$ ls
dir  dir2x  dir2y  f1  file1
[user1@localhost testdir]$ cat f1
cat: f1: Permission denied
[user1@localhost testdir]$ 

  cd /testdir/
  105  ll f1
  106  chmod 644 f1
  107  ll
  108  setfacl -m u:user1:0 f1
  109  getfacl f1
  110  su - user1
  111  chmod 640 /dir
  112  chmod 640 dir
  113  ll
  114  chmod 644 dir
  115  ll
  116  setfacl -m g:g1:rw dir
  117  getfacl dir
  118  ls
  119  rm dir
  120  mkdir dir
  121  setfacl -m g:g1:rw dir
  122  detfacl -m d:u:user1:rw dir 
  123  setfacl -m d:u:user1:rw dir 
  124  setfacl -m d:g:g1:0 dir 
  125  touch3
  126  touch 3
  127  ll
  128  getfacl dir
  129  ll -d
  130  ll -d  /testdir/
  131  su - user1
  132  chmod 777 dir
  133  su - user1
  134  getfacl -R /testdir/dir > /tmp/beifen
  135  cat /tmp/beifen 
  136  cd ..
  137  setfacl -b -R testdir/
  138  getfacl -R testdir/
  139  setfacl -R --set-file=beifen /testdir/dir
  140  setfacl -R --set-file=beifen /testdir
  141  setfacl -R --set-file=/tmp/beifen /testdir/
  142  getfacl dir
  143  getfacl -R /testdir/
  144  cd
  145  history

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

(0)
1515218807015152188070
上一篇 2016-08-04
下一篇 2016-08-04

相關推薦

  • bash特性

    2018-03-11

    2018-03-11
  • 部署LAMP之WordPress, PMA(https), Discuz

    一、環境介紹     系統:CentOS 6.7     軟件:httpd-2.2, mysql-5.3, wordpress-4.3, pma4.0     網絡:       …

    Linux干貨 2016-03-24
  • N25第六周博客作業

    第六周博客作業   請詳細總結vim編輯器的使用并完成以下練習題 1、 復制/etc/rc.d/rc.sysinit文件至/tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#; :%s@^\([[:space:]]\+\)@#\1@ig    2、 復制/boot/grub/grub.con…

    Linux干貨 2017-01-10
  • LAMP實戰

    說明:本實驗在單主機搭建。下面的步驟只需要你復制粘貼,即可完成實驗。 1、安裝httpd mkdir /tools cd /tools #獲取軟件包 wget -c http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.16.tar.gz wget http://m…

    Linux干貨 2015-10-08
  • 數據的游戲:冰與火

    我對數據挖掘和機器學習是新手,從去年7月份在Amazon才開始接觸,而且還是因為工作需要被動接觸的,以前都沒有接觸過,做的是需求預測機器學習相關的。后來,到了淘寶后,自己憑興趣主動地做了幾個月的和用戶地址相關數據挖掘上的工作,有一些淺薄的心得。下面這篇文章主要是我做為一個新人僅從事數據方面技術不到10個月的一些心得,也許對你有用,也許很傻,不管怎么樣,歡迎指…

    Linux干貨 2016-08-15
  • linux命令查找locate find要點

           在文件系統上查找符合的文件        locate, find locate:          依賴于事先構建好的索引庫:             &…

    Linux干貨 2016-11-07
欧美性久久久久