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.178linux.com/28758

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

相关推荐

  • Nagios

    一、Nagios简介   Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。 Nagios原名为NetSaint,由Ethan Galstad开发并维护至今…

    2017-12-20
  • Linux文件管理及常用方法

    Linux文件管理及常用方法 一切皆文件,管理系统即用正确的方法管理相应的文件。 Linux系统中文件管理所涉及到的问题 ls -l boot.log   -rw-r–r–. 1 root   root     13…

    Linux干货 2016-11-06
  • CentOS 7 yum安装LAMP,LNMP并搭建WordPress个人博客网站

    本次实验要进行的是在CentOS7.2,内核版本3.10.0-327.el7.x86_64的环境下搭建LAMP和LNMP,并在此之上做一个WordPress博客网站。 [root@Shining ~]# uname -a Linux Shining.ACG 3.10.0-327.el7.x86_64&nbsp…

    Linux干货 2016-11-24
  • 马哥教育网络班21期+第10周课程练习

    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)     1)开机后会进行POST(开机加电自检),加载BIOS,之后会根据BIOS上的boot  sequence(引导加载次序)找到第一个有引导程序的设备,找到MBR,bootloader(引导加载器)就安装在MBR内。M…

    Linux干货 2016-09-19
  • Linux终端类型

    Linux中各种终端的解释 设备终端   键盘鼠标显示器 物理终端( /dev/console ) )   在Linux 系统中,计算机显示器通常被称为控制台终端(Console)。 虚拟终端(tty :teletypewriters, /dev/tty# # 为[1-6])   tty 可有n 个,Ctrl+Alt+…

    Linux干货 2016-10-13
  • 文本处理课后小练习

    1、找出ifconfig命令结果中本机的所有IPv4地址 [root@wzc date]# ifconfig |grep -E -o  '(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]…

    Linux干货 2016-08-08