RHCSA练习题及答案

您所在的位置:网站首页 图形密码题及答案 RHCSA练习题及答案

RHCSA练习题及答案

2024-06-14 18:43| 来源: 网络整理| 查看: 265

文章目录 环境说明开考准备1,给系统添加一个默认的软件仓库2,调整逻辑卷的大小3,创建用户账户4,配置文件/var/tmp/fstab的权限5,配置一个计划任务6,创建一个共享目录7,安装内核的升级8,绑定到外部验证服务9,autofs的配置10,配置NTP网络时间客户端11,配置一个用户账户12,添加一个swap分区13,查找文件14,查找一个字符串15,创建一个逻辑卷16,创建一个归档附录——逻辑卷划分之前练习环境的准备

环境说明

考试环境说明—— 考试服务器(会提供DNS/YUM/认证/素材) xxx.domain0.example.com,yyy.comain0.example.com 真实机(无root权限):foundation.domain0.example.com 虚拟机(有root权限):station.domain0.example.com

练习环境说明—— 考试服务器(会提供DNS/YUM/认证/素材):classroom.example.com 真实机(无root权限):room9pc13.tedu.cn 虚拟机(有root权限):server0.example.com

开考准备

将系统的root账号密码设置为redhat(假设密码已忘记,重设密码) 配置虚拟机系统使用以下的静态网络配置 Hostname:serverX.example.com(X为数字) IP address:172.25.0.X Netmask:255.255.255.0 Gateway:172.25.0.254 Name server:172.25.254.254

步骤 重启虚拟机server,出现GRUB启动菜单时按e键进入编辑状态 找到linux16所在行,末尾添加rd.break console=tty0按下Ctrl+x键进入恢复模式 以可写方式重新挂载硬盘中的根分区,并重设root密码

switoh_root:/# mount -o remount,rw /sysroot //以可读写方式重新挂载根系统 switch_root:/# chroot /sysroot/ //切换到根系统 sh-4.2# echo redhat | passwd --stdin root //设置指定的密码 sh-4.2# touch /.autorelabel //标记下一次启动重做selinux标记 switch_root:/# reboot

配置主机名、IP地址、掩码、默认网关、DNS地址

[root@server0~]# hostnamectl set-hostname serverX.example.com [root@server0~]# nmcli connection show //查看连接名 [root@server0~]# nmcli connection modify "连接名" ipv4.method manual ipv4.address "172.25.0.X/24 172.25.0.254" ipv4.dns 172.25.254.254 autoconnect yes //进行网卡配置,配置方法为手工(manual)配置地址、掩码、网关、dns地址,最后设置开机自动识别此网卡配置 [root@server0~]# nmcli connection up "连接名" //启动刚才配好的网卡连接 1,给系统添加一个默认的软件仓库

yum的软件源为http://content.example.com/rhel7.0/x86_64/dvd将此配置为系统的默认软件仓库 该yum源的地址在考试环境中是可用的,考试环境会提供

步骤

[root@server0~]# cd /etc/yum.repos.d/ //切换到yum配置文件的路径下 [root@server0 yum.repos.d]# ls //查看是否有其他.repo结尾的配置文件,若有则移动到备份,防止与自己的yum源配置冲突 [root@server0 yum.repos.d]# mkdir bak //创建备份文件夹 [root@server0 yum.repos.d]# mv *.repo bak/ //将yum.repos.d目录下的以.repo结尾的文件移到备份文件夹内 [root@server0 yum.repos.d]# vi dvd.repo //创建配置文件并编辑 [dvd] //yum的id name=dvd //yum源的名字 baseurl=http://content.example.com/rhel7.0/x86_64/dvd //配置yum源的路径 gpgcheck=0 //不检查签名 [root@server0 yum.repos.d]# yum repolist //加载 2,调整逻辑卷的大小

将逻辑卷xyz和其文件系统大小调整到300MiB要确保文件系统中的内容保持完整。注:分区大小一般很少能够完全符合要求的大小,所以分区大小在270MiB到330MiB之间的都可以 练习环境需要提前准备一下,可以参考附录

步骤 准备磁盘空间(如果xyz所在的卷组空间足够,就可直接下一步,否则应该综合所有的题目以便考虑分区的最佳方案)

[root@server0~]# fdisk /dev/vdb .. .. Command (m for help): n //新建 Partition type: p primary (3 primary, 0 extended, 1 free) e extendedSelect (default e): e //扩展分区 Selected partition 4 First sector (6555648-20971519, default 6555648): //起始位置默认 Last sector, +sectors or +size{K,M,G} .. ..): //结束位置默认 Command (m for help): n //新建 First sector (6557696-20971519, default 6557696): //起始位置默认 Last sector, +sectors or +size{K,M,G} .. ..): +500M //结束位置+500MiB(卷扩容) Partition 5 of type Linux and of size 500 MiB is set Command (m for help): n //新建 First sector (7583744-20971519, default 7583744): //起始位置默认 Last sector, +sectors or +size{K,M,G} .. ..): +2000M //结束位置+2000MiB(自定卷组) Partition 6 of type Linux and of size 2 GiB is set Command (m for help): n //新建 First sector (11681792-20971519, default 11681792): //起始位置默认 Last sector, +sectors or +size{K,M,G} .. ..): +512M //结束位置+512MiB(交换分区) Partition 7 of type Linux and of size 512 MiB is set Command (m for help): p Device Boot Start End Blocks Id System .. .. /dev/vdb4 6555648 20971519 7207936 5 Extended /dev/vdb5 6557696 7581695 512000 83Linux /dev/vdb6 7583744 11679743 2048000 83Linux /dev/vdb7 11681792 12730367 524288 83Linux Command (m for help): w //保存分区更改 [root@server0~]# partprobe /dev/vdb //刷新分区表 [root@server0~]# reboot //重启一次!!确保新分区表生效 [root@server0~]# lvscan ACTIVE '/dev/systemvg/vo' [180.00 MiB] inherit //检查原有的逻辑卷

扩展逻辑卷

[root@server0~]# vgextend systemvg /dev/vdb5 //扩展卷组 [root@server0~]# lvextend -L 300MiB /dev/systemvg/xyz //扩展逻辑卷 [root@server0~]# resize2fs /dev/systemvg/xyz //更新逻辑卷大小 3,创建用户账户

创建下列用户、组以及和组成员的关系 一个名为haha的用户,其属于sysuser,这个组是该用户的从属组 一个名为jerry的用户,其属于sysuser,这个组是该用户的从属组 一个名为shasha的用户,其在系统中没有可以交互的shell,并且不是sysuser组的成员用户 haha、jerry、和shasha的密码都要设置为flectrag

步骤

[root@server0~]# groupadd sysuser [root@server0~]# useradd -G sysuser haha [root@server0~]# useradd -G sysuser jerry [root@server0~]# useradd -s /sbin/nologin shasha [root@server0~]# echo flectrag | passwd --stdin haha [root@server0~]# echo flectrag | passwd --stdin jerry [root@server0~]# echo flectrag | passwd --stdin shasha 4,配置文件/var/tmp/fstab的权限

拷贝文件/etc/fstab到/tmp/fstab,配置文件/tmp/fstab的权限 文件/tmp/fstab的拥有者是root用户 文件/tmp/fstab属于sysuser组 文件/tmp/fstab对任何人都不可执行 用户haha能够对文件/tmp/fstab执行读和写操作

步骤

[root@server0~]# cp /etc/fstab /var/tmp/fstab [root@server0~]# chown root:sysuser /var/tmp/fstab //修改/var/tmp/fstab的所有者以及所属组 [root@server0~]# chmod u-x,g-x,o-x /var/tmp/fstab //去掉所有执行权限 [root@server0~]# setfacl -m u:haha:rw /var/tmp/fstab //单独针对haha设置权限 [root@server0~]# setfacl -m u:jerry:- /var/tmp/fstab //单独针对jerry设置权限 [root@server0~]# chmod o+r /var/tmp/fstab //添加其他用户对/var/tmp/fstab的读权限 5,配置一个计划任务

为用户haha配置一个定时任务,每天在本地时间18:43时执行以下命令 /bin/echo xixi

步骤

[root@server0~]# systemctl restart crond [root@server0~]# systemctl enable crond [root@server0~]# crontab -e -u haha 43 18 * * * /bin/echo xixi 6,创建一个共享目录

创建一个共享目录/home/adminshare /home/adminshare目录的组的所有权是sysuser sysuser组的成员对这个目录有读写执行的权限。除此之外的其他所有用户都没有任何权限(root用户能够访问系统中所有文件和目录) 在/home/adminshare目录中创建的文件,其组所有权会自动设置为属于sysuser组 注:此处所谓的共享目录并不是说的网络共享,只是某个组成员共用某个文件

步骤

[root@server0~]# mkdir /home/adminshare [root@server0~]# chown :sysuser /home/adminshare [root@server0~]# chmod ug=rwx,o-rwx /home/adminshare [root@server0~]# chmod g+s /home/adminshare //给目录设置GID权限,使子目录能自动继承父目录的所属组权限 7,安装内核的升级

新版内核可以从http://classroom/content/rhel7.0/x86_64/errata/Packages/获取 升级系统内核版本 当系统重新启动之后升级的内核要作为默认的内核 原来的内核要被保留,并且仍然可以正常启动

步骤

[root@f0~]# LANG=C firefox http://classroom/content/rhel7.0/x86_64/errata/Packages/ //从真机浏览器访问所给的地址,找到内核rpm文件下载地址 //如果Firefox右键菜单乱码,请添加LANG= 改运行环境 [root@server0~]# yum -y install http://../kernel-3.10.0-123.1.2.el7.x86_64.rpm //请耐性等待安装完成,中途不可以中断 [root@server0~]# reboot //重启以使内核生效 [root@server0~]# uname -r //确认新内核版本 3.10.0-123.1.2.el7.x86_64 8,绑定到外部验证服务

系统classroom.example.com提供了一个LDAP验证服务。需要按照下面要求绑定到这个服务上 验证服务器的基本DN是:dc=example.dc=com 账户信息和验证信息都是由LDAP提供的 连接要使用证书进行加密,证书可以在下面的链接中下载 http://classroom.example.com/pub/example-ca.crt 当正确完成配置之后,用户ldapuser0应该能够登陆到您的系统中,但是没有主目录 当您完成sutofs的题目之后,才能生成主目录 当用户ldapuser0的密码是password

步骤

[root@server0~]# yum -y install sssd [root@server0~]# authconfig-tui //使用简易配置工具

根据提示完成用户和认证方式设置—— User Information:[*] User LDAP Authentication Method:[*] User Ldap Authentication 根据提示选中[*]Use TLS,并设置下列参数—— Server: classroom.example.com Base DN: dc=example.dc=com 提示下载证书到/etc/openldap/cacerts目录时,另开一终端执行:

[root@server0~]# cd /etc/openladap/cacerts/ [root@server0~]# wget http://classroom.example.com/pub/example-ca.crt

然后回到authconfig-tui工具确认,稍等片刻即可

[root@server0~]# systemctl restart sssd [root@server0~]# systemctl enable sssd [root@server0~]# id ldapuser0 //验证LDAP用户 uid=170(ldapuser0) gid=170(ldapuser0) groups=170(ldapuser0) 9,autofs的配置

按照下述要求配置autofs用来自动挂载LDAP用户的主目录 classroom.example.com(172.25.0.250)通过NFS v3版本输出/home/guests目录到您的系统,这个文件系统包含了用户ldapuser0的主目录,并且已经预先配置好 ldapuser0用户的主目录是classroom.example.com:/home/guests/ldapuser0 ldapuser0的主目录应该挂载到本地的/home/guests/ldapuser0目录下 用户对其主目录必须是可写的 ldapuser0用户的密码是password

步骤

[root@server0~]# yum -y install autofs [root@server0~]# vim /etc/auto.master //指定监控点(家目录的父目录) /home/guests /etc/guests.rule [root@server0~]# vim /etc/guests.rule //配置挂载策略 ldapuser0 -rw.v3 classroom.example.com:/home/guests/ldapuser0 [root@server0~]# systemctl start autofs [root@server0~]# systemctl enable autofs [root@server0~]# su - ldapuser0 -c 'pwd' //验证结果 /home/guests/ldapuser0 10,配置NTP网络时间客户端

配置系统作为一个classroom.example.com的NTP客户端

步骤

[root@server0~]# vim /etc/chrony.conf #server 0.rhel.pool.ntp.org iburst //注释掉默认的server配置 #server 1.rhel.pool.ntp.org iburst #server 2.rhel.pool.ntp.org iburst #server 3.rhel.pool.ntp.org iburst server classroom.example.com iburst //添加新的配置 [root@server0~]# systemctl restart chronyd [root@server0~]# systemctl enable chronyd [root@server0~]# timedatectl //查看状态 .. .. NTP enbled: yes //检查NTP是否已经启用 11,配置一个用户账户

创建一个名为alex的用户,用户ID是1234。密码是redhat

步骤

[root@server0~]# useradd -u 1234 alex [root@server0~]# echo redhat | passwd --stdin alex 12,添加一个swap分区

在系统中添加大小为512MiB的swap分区 当系统启动时,swap分区应该可以自动挂载 不要移除或者修改其他已经存在于系统中的swap分区

步骤

[root@server0~]# mkswap /dev/vdb7 //分区准备参见第二题 [root@server0~]# vim /etc/fstab /dev/vdb7 swap swap defaults 0 0 [root@server0~]# swapon -a [root@server0~]# swapon -s //查看交换分区信息 13,查找文件

找出所有用户student拥有的文件,并且把它们拷贝到/root/find目录中

步骤

[root@server0~]# mkdir /root/find [root@server0~]# find / -user student -type f -exec cp -p {} /root/find/ \ 14,查找一个字符串

在文件/usr/share/dict/words中查找到所有包含字符串seismic的行 将找出的行按照原文的先后顺序拷贝到/root/wordlist文件中 /root/wordlist文件不要包含空行,并且其中的所有行的内容都必须是/user/share/dict/words文件中原始行的准确副本

步骤

[root@server0~]# grep 'seismic' /usr/share/dict/words > /root/wordlist 15,创建一个逻辑卷

根据下面的要求创建一个新的逻辑卷 逻辑卷命名为database,属于datastore卷组,并且逻辑卷的大小为50个物理扩展单元(physical extent) 在datastore卷组中的逻辑卷,物理扩展单元(physical extent)大小应为16MiB 使用ext3文件系统对新的逻辑卷进行格式化,此逻辑卷应该在系统启动的时候自动挂载在/mnt/database目录下

步骤

[root@server0~]# vgcreate -s 16MiB datastore /dev/vdb6 //分区准备参见第二题 [root@server0~]# lvcreate -l 50 -n database datastore [root@server0~]# mkfs.ext3 /dev/datastore/database [root@server0~]# mkdir /mnt/database [root@server0~]# vim /etc/fstab /dev/datastore/database /mnt/database ext3 defaults 0 0 [root@server0~]# mount -a 16,创建一个归档

创建一个名为/root/backup.tar.bz2的归档文件,其中包含/usr/local目录中的内容,tar归档必须使用bzip2进行压缩

步骤

[root@server0~]# tar -cjPf /root/backup.tar.bz2 /usr/local/ 附录——逻辑卷划分之前练习环境的准备

如果是操作磁盘/dev/vdb(包含linxu系统),则使用剩余空间完成分区练习题 练习时需要自行处理/dev/vdb,模拟成“已使用部分空间+剩余空间”的磁盘练习环境

[root@server0~]# fdisk /dev/vdb //新建 command (m for help): n Partitoin type: p primary (0 primary, 0 extended,4 free) e extended Select (default p): p //主分区 Partition number (1-4,default 1): 1 //主分区编号1 First sector (2048-20971519,default 2048): //起始位置默认 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +200M //结束位置+200MiB Partition 1 of type Linux and of size 200 MiB is set Command (m for help): n //新建 Select (default p): p //主分区 Partition number (2-4, default 2): 2 //分区编号2 First sector .. ..: //起始位置默认 Last sector, .. ..: +2000M //结束位置+2000MiB Partition 2 of type Linux and of size 2 GiB is set Command (m for help): n //新建Select (default p): p //主分区 Partition number (3,4, default 3): 3 //分区编号3 First sector .. ..: //起始位置默认 Last sector, .. ..: +1000M //结束位置+1000MiB Partition 3 of type Linux and of size 1000 MiB is set Command (m for help): p //确认分区结果 Device Boot Start End Blocks Id System /dev/vdb1 2048 411647 204800 83 Linux /dev/vdb2 411648 4507647 2048000 83 Linux /dev/vdb3 4507648 6555647 1024000 83 Linux Command (m for help): w //保存分区结果 [root@server0~]# partprobe /dev/vdb //刷新分区表 [root@server0~]# vgcreate systemvg /dev/vdb1 //创建卷组 Physical volume "/dev/vdb1" successfully created Volume group "systemvg" successfully created [root@server0~]# lvcreate -n vo -L 180M systemvg //创建逻辑卷 Logical volume "vo" created[root@server0~]# lvscan //确认结果 ACTIVE '/dev/systemvg/vo' [180.00 MiB] inherit [root@server0~]# mkfs.ext3 /dev/systemvg/vo //格式化


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3