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 14:39
下一篇 2016-08-04 14:40

相關推薦

  • Linux運維之進程管理

    一、      進程概念 進程是內核的一個功能,在Linux中,運行一個程序或命令可以出發一個事件而驅動一個PID,在linux系統中,系統只識別二進制程序文件,我們可以通過執行系統上的二進制程序來運行程序,進而產生進程。在linux系統中第一個進程是init程序,它是系統開機第一個加載的程序,用來支撐系統的…

    Linux干貨 2016-09-13
  • PHP進階知識總結

    周末梳理了下這段時間看書的一些知識點,進步的過程不僅要實踐,還要安排多看書、思考、總結。 只針對知識點進行了羅列和簡單說明,很多細節還未整理好,待后面再專門詳細寫。   基礎易忽略概念   PHP是一個支持面向對象開發的語言,而不是一個純面向對象的語言 PHP5中保留了對var的支持,但會將var自動轉換為public 類型檢查函數: i…

    Linux干貨 2015-03-10
  • CentOS7的啟動及Systemd的管理?

    CentOS7的啟動流程     POST–>Boot Sequence–>Bootloader–>kernel+initramfs(initrd)–>rootfs–>/sbin/init    &n…

    Linux干貨 2016-09-21
  • 第11天:網絡基礎,屬性配置

    http://note.youdao.com/noteshare?id=bf6e776e7271953bffe1bdf949df4e8f

    Linux干貨 2016-09-06
  • Linux文件查找

    什么是文件查找     在文件系統中查找符合條件的文件; 文件查找分為:     實時查找:遍歷所有文件進行條件匹配(find)     非實時查找:根據索引查找(locate) locate ? 查詢系統上預建的文件索引數據庫 …

    Linux干貨 2016-08-15
  • 網絡管理之網絡配置

    一:博客 1 centos6網卡別名 在Linux系統中,我們可以在一塊物理網卡上配置多個IP地址,以此來實現類似子接口的功能,我們稱之為網卡別名。 設置網卡別名,先在/etc/sysconfig/network-scripts目錄下將eth0文件復制名為eth0:1的文件,復制文件中的1可隨意設置,但為方便管理建議按順序排列 注意要修改ifcfg-eth0…

    Linux干貨 2016-09-05
欧美性久久久久