首页 > 代码库 > 练习题
练习题
IPADDR: 172.25.x.100(X 在这里指您的工作站编号)
NETMASK: 255.255.255.0
GATEWAY: 172.25.x.254
DNS: 172.25.254.254
yum源地址为:ftp://172.25.x.250/pub/rhel7.0
1.
在进行考试之前,请先重置根用户密码为 examwestos
2.
更改主机名称为 station.domainX.example.com(X 在这里指您的工作站编号)
[root@desktop Desktop]# hostnamectl set-hostname station.domain49.example.com
3
新建组,名称为 sysadms,指定其 GID 为 600
[root@station Desktop]# groupadd -g 600 sysadms
4
新建用户 tommy,指定 UID 为 2013,配置该用户密码为 redhat
[root@station Desktop]# useradd -u 2013 tommy
[root@station Desktop]# passwd tommy
Changing password for user tommy.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
5
新建用户 Jimmy,,并且禁止该用户交互式登录,配置该用户密码为 redhat
[root@station Desktop]# useradd -s /sbin/nologin Jimmy
[root@station Desktop]# passwd Jimmy
Changing password for user Jimmy.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
6
新建用户 natasha,harry, 并将这两个用户加入到 sysadms 组当中,作为从属组,如果需要,则将用户密码配置为 redhat
[root@station Desktop]# useradd -G sysadms natasha
[root@station Desktop]# useradd -G sysadms harry
[root@station Desktop]# id harry
uid=2016(harry) gid=2016(harry) groups=2016(harry),600(sysadms)
[root@station Desktop]# id natasha
uid=2015(natasha) gid=2015(natasha) groups=2015(natasha),600(sysadms)
7
在/home 目录中创建目录 materials,配置该目录的所属组为 sysadms,要求隶属于 sysadms 组当中的成员对该目录有读写权限,在sysadms目录当中创建的文件或者文件夹,其所属组也
自动继承 sysadms 的所属组
[root@station Desktop]# mkdir /home/materials/
[root@station Desktop]# chgrp sysadms /home/materials/
[root@station Desktop]# chmod g+s /home/materials/
[root@station Desktop]# ll -d /home/materials/
drwxr-sr-x. 2 root sysadms 6 Nov 2 21:59 /home/materials/
拷贝/etc/fstab 文件到/var/tmp 目录中,设置以下需求
[root@station Desktop]# cp /etc/fstab /var/tmp/
使 harry 用户对该文件无任何权限
[root@station Desktop]# setfacl -m u:harry:0 /var/tmp/
使 natasha 对该文件有完全控制权限
[root@station Desktop]# setfacl -m u:natasha:7 /var/tmp/
配置文件所属用户为 root
[root@station Desktop]# chown root /var/tmp/
配置文件所属组为 root
[root@station Desktop]# chgrp root /var/tmp/
其他所有用户对文件拥有读权限
[root@station Desktop]# chmod o+r /var/tmp/
其他所有用户对文件没有执行权限
[root@station Desktop]# chmod o-x /var/tmp/
[root@station Desktop]# getfacl /var/tmp/
getfacl: Removing leading ‘/‘ from absolute path names
# file: var/tmp/
# owner: root
# group: root
# flags: --t
user::rwx
user:natasha:rwx
user:harry:---
group::rwx
mask::rwx
other::rw-
9
设置 NTP 客户端,与172.25.x.254进行时间同步
客户端:
[root@station Desktop]# vim /etc/chrony.conf
[root@station Desktop]# systemctl stop firewalld
[root@station Desktop]# systemctl disable firewalld
[root@station Desktop]# systemctl restart chronyd.service
服务器:
[root@foundation49 ~]# vim /etc/chrony.conf
[root@foundation49 ~]# systemctl stop firewalld
[root@foundation49 ~]# systemctl disable firewalld
[root@foundation49 ~]# systemctl restart chronyd.service
测试:
[root@station Desktop]# chronyc sources -v
210 Number of sources = 1
10
找出用户组mail 拥有的文件,并且将它们放到/root/findresults 目录中
[root@station Desktop]# find / -group mail
find: ‘/proc/3257’: No such file or directory
find: ‘/proc/3275/task/3275/fd/6’: No such file or directory
find: ‘/proc/3275/task/3275/fdinfo/6’: No such file or directory
find: ‘/proc/3275/fd/6’: No such file or directory
find: ‘/proc/3275/fdinfo/6’: No such file or directory
/var/spool/mail
/var/spool/mail/rpc
/var/spool/mail/student
/var/spool/mail/shengchan
/var/spool/mail/caiwu
/var/spool/mail/jishu
/var/spool/mail/tom
/var/spool/mail/leo
/var/spool/mail/admin
/var/spool/mail/mi
/var/spool/mail/iphone
/var/spool/mail/huawei
/var/spool/mail/root
/var/spool/mail/tommy
/var/spool/mail/Jimmy
/var/spool/mail/natasha
/var/spool/mail/harry
11
[root@station Desktop]# cp -r /var/spool/mail/ /root/findresults
在文件/usr/share/mime/packages/freedesktop.org.xml 中查找所有包含 ich 的行,将找
出的行按照先后顺序拷贝到/root/lines
文件中,/root/lines 文件不包含空格,并且其中行的内容是源文件/usr/share/mime/packages/freedesktop.org.xml 原始行的准确副本
[root@station Desktop]# grep ‘ich‘ /usr/share/mime/packages/freedesktop.org.xml > /root/lines
[root@station Desktop]# vim /root/lines
本文出自 “12147236” 博客,请务必保留此出处http://12157236.blog.51cto.com/12147236/1869134
练习题