=========================================
RHCSA考試大致要求(自整理)
- 操作都在虛擬上哥谷,物理(考試機(jī))可用做測試
- 禁止連接到其他考生主機(jī)榕吼;一經(jīng)發(fā)現(xiàn)成績?yōu)?
- 禁止修改密碼(除考試要求)泡徙,考試會提供的密碼
- 可能需要自己安裝圖形化界面
- 嚴(yán)格按照題目要求突梦,理解題目意思
- 滿分300分霎苗,210分為及格
- 本RHCSA模擬題庫分為server及desktop
- RHCSA實驗只需操作desktop
- 以下例題為RHEL7的題庫循狰,沒有任何變化
========================================
配置信息
- 主機(jī)名:desktop.group8.example.com
- IP地址:172.24.8.10
- 子網(wǎng)掩碼:255.255.255.0
- 網(wǎng)關(guān):172.24.8.254
- 名稱服務(wù):172.24.8.254
第一題 重置系統(tǒng)密碼并完成網(wǎng)絡(luò)配置
請先完成以下步驟才能繼續(xù)開始其他題目
重置系統(tǒng)密碼:
- 請修改系統(tǒng)的root賬號密碼為rrhh9708,確保能夠使用root賬戶登錄系統(tǒng)逞盆。
根據(jù)以下信息完成虛擬機(jī)desktop網(wǎng)絡(luò)的修改:
- 主機(jī)名:desktop.group8.example.com
- IP地址:172.24.8.10
- 子網(wǎng)掩碼:255.255.255.0
- 網(wǎng)關(guān):172.24.8.254
- 名稱服務(wù):172.24.8.254
參考答案
1-1. 重啟系統(tǒng)檀蹋,在已開機(jī)的desktop虛擬機(jī)上,同時按下Ctrl+Alt+Del
三鍵
1-2. 在Grub Boot Loader
倒計時讀秒技術(shù)前云芦,按下任意鍵
1-3. 選中默認(rèn)的的第一個啟動條目俯逾,并按下鍵盤字母e
鍵,以便編輯
1-4. 進(jìn)入啟動條目編輯界面后舅逸,通過鍵盤方向鍵(↓)
桌肴,找到第一個以linux16
開頭的行,并通過按下Ctrl+e
快速把光標(biāo)定位到該行的行末琉历,輸入<空格鍵> rd.break
1-5. 確定沒錯之后坠七,按下Ctrl+x
,以修改后的配置引導(dǎo)系統(tǒng)旗笔,系統(tǒng)將啟動到臨時內(nèi)核shell界面,輸入以下指令即可修改密碼
switch_root :/# mount -o remount,rw / /sysroot
sh-4.2# chroot /sysroot
sh-4.2# echo rrhh9708 | passwd --stdin root
sh-4.2#
sh-4.2# touch /.autorelabel
sh-4.2#
sh-4.2# exit
sh-4.2# exit
注意: 修改密碼后彪置,首次重啟的時間將會比較長,因為系統(tǒng)將對所有文件進(jìn)行Selinux 打標(biāo)蝇恶,請耐心等待,整個過程并非死機(jī)拳魁,請勿在打標(biāo)過程中手動強(qiáng)制再次重啟,否則系統(tǒng)將會永久性損壞導(dǎo)致無法開機(jī)
1-6. 成功啟動系統(tǒng)后撮弧,輸入賬號root
潘懊,密碼為題目要求修改的密碼
后,完成網(wǎng)絡(luò)配置
- 1-6-1 使用
nmcli
命令管理網(wǎng)絡(luò)
[root@localhost ~]# nmcli device //查看本機(jī)網(wǎng)卡設(shè)備
[root@localhost ~]# nmcli connection //查看本機(jī)連接
[root@localhost ~]# nmcli connection modify eth0 ipv4.addresses 172.24.8.10/24 ipv4.gateway 172.24.8.254 ipv4.dns 172.24.8.254 ipv4.dns-search group8.example.com ipv4.method manual connection.autoconnect yes connection.interface-name eth0
[root@localhost ~]# nmcli connection reload //重新加載連接配置信息
[root@localhost ~]# nmcli connection down eth0 //關(guān)閉網(wǎng)卡
[root@localhost ~]# nmcli connection up eth0 //重啟網(wǎng)卡
[root@localhost ~]# ping -c5 server //測試網(wǎng)絡(luò)連通性
PING server.group8.example.com (172.24.8.254) 56(84) bytes of data.
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=1 ttl=64 time=0.260 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=2 ttl=64 time=0.588 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=3 ttl=64 time=1.18 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=4 ttl=64 time=0.631 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=5 ttl=64 time=0.562 ms
--- server.group8.example.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 0.260/0.644/1.180/0.298 ms
- 1-6-2 修改網(wǎng)卡配置管理網(wǎng)絡(luò)
? ? ??redhat系統(tǒng)中贿衍,網(wǎng)卡配置文件位于/etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none //將dhcp修改為none或者static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=4dc8c88c-69b0-4203-a0a6-3671ceb0cd7e
ONBOOT=yes //將no改為yes確保重啟可用
DEVICE=eth0
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPADDR=172.24.8.10 //添加ipaddress信息
PREFIX=24 //添加子網(wǎng)掩碼信息授舟,PREFIX或者NETMASK均可
GATEWAY=172.24.8.254 //添加網(wǎng)關(guān)信息
DNS1=172.24.8.254 //添加DNS信息
[root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.24.8.254 server.group8.example.com //修改hosts確保dns服務(wù)器域名可達(dá)
[root@localhost ~]# systemctl restart network //重啟網(wǎng)卡使網(wǎng)絡(luò)生效
[root@localhost ~]# ping -c5 server //測試網(wǎng)絡(luò)連通性
PING server.group8.example.com (172.24.8.254) 56(84) bytes of data.
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=1 ttl=64 time=0.260 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=2 ttl=64 time=0.588 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=3 ttl=64 time=1.18 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=4 ttl=64 time=0.631 ms
64 bytes from server.group8.example.com (172.24.8.254): icmp_seq=5 ttl=64 time=0.562 ms
--- server.group8.example.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 0.260/0.644/1.180/0.298 ms
1-7. 設(shè)定主機(jī)名
[root@localhost ~]# hostnamectl set-hostname desktop.group8.example.com
[root@localhost ~]# bash //可以執(zhí)行bash命令,讓終端馬上看到修改后的主機(jī)名
[root@desktop ~]#
第二題 配置SeLinux
- SeLinux的工作模式為enforcing
- 要求系統(tǒng)重啟后依然生效
參考答案
[root@desktop ~]# getenforce
Permissive
[root@desktop ~]# setenforce 1 //臨時設(shè)置為enforcing模式
[root@desktop ~]# getenforce
Enforcing
[root@desktop ~]# vim /etc/sysconfig/selinux //永久設(shè)置為enforcing模式
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing //修改成enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
第三題 配置YUM倉庫
參考答案
- 3-1 使用
yum-config-manager
命令管理YUM倉庫
[root@desktop ~]# yum-config-manager --add-repo=http://server.group8.example.com/yum <--- 請直接復(fù)制題目要求中的地址舌厨,以免輸入錯誤
Loaded plugins: langpacks, product-id
adding repo from: http://server.group8.example.com/yum
[server.group8.example.com_yum]
name=added from: http://server.group8.example.com/yum
baseurl=http://server.group8.example.com/yum
enabled=1 <--- 如果地址輸入錯誤岂却,可以手工刪除配置文件/etc/yum.repos.d/*.repo忿薇,再次執(zhí)行上述添加指令
[root@desktop ~]# cat /etc/yum.repos.d/server.group8.example.com_yum.repo
[server.group8.example.com_yum]
name=added from: http://server.group8.example.com/yum
baseurl=http://server.group8.example.com/yum
enabled=1
[root@desktop ~]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
server.group8.example.com_yum | 2.9 kB 00:00:00
server.group8.example.com_yum/primary_db | 103 kB 00:00:00
repo id repo name status
server.group8.example.com_yum added from: http://server.group8.example.com/yum 119
repolist: 119
[root@desktop ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release <--- 為了避免安裝軟件包因外部源未經(jīng)校驗導(dǎo)致安裝中斷裙椭,可以通過導(dǎo)入校驗秘鑰方式防止中斷
[root@desktop ~]#
- 3-2 修改配置文件配置YUM倉庫
? ? ??配置文件位于/etc/yum.repos.d
[root@desktop ~]# cat /etc/yum.repos.d/777.repo
[7]
name=777
baseurl=http://server.group8.example.com/yum <--- 地址嚴(yán)格按照要求填寫
enabled=1
gpgcheck=0
[root@desktop ~]# yum repolist
Loaded plugins: aliases, changelog, fastestmirror, langpacks, tmprepo, verify, versionlock
Loading mirror speeds from cached hostfile
repo id repo name status
!7 777 119
repolist: 119
第四題 調(diào)整邏輯卷容量
請按照以下要求調(diào)整本地邏輯卷lv0的容量:
- 調(diào)整后的邏輯卷及文件系統(tǒng)大小為290MiB
- 調(diào)整后確保文件系統(tǒng)中己存在的內(nèi)容不能被破壞
- 調(diào)整后的容量可能出現(xiàn)誤差躏哩,只要在270MiB - 320MiB之間都是允許的
- 調(diào)整后,保證其掛載目錄不改變揉燃,文件系統(tǒng)完成
參考答案
[root@desktop ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 xfs 9.8G 3.3G 6.5G 34% /
devtmpfs devtmpfs 660M 0 660M 0% /dev
tmpfs tmpfs 674M 0 674M 0% /dev/shm
tmpfs tmpfs 674M 8.9M 666M 2% /run
tmpfs tmpfs 674M 0 674M 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 ext3 190M 1.6M 179M 1% /home <--- 當(dāng)前容量少于290MiB扫尺,需要擴(kuò)容
tmpfs tmpfs 135M 0 135M 0% /run/user/0
[root@desktop ~]# lvextend -L 290m /dev/vg0/lv0 <--- 這是邏輯卷擴(kuò)容的關(guān)鍵命令
Rounding size to boundary between physical extents: 292.00 MiB
Size of logical volume vg0/lv0 changed from 200.00 MiB (50 extents) to 292.00 MiB (73 extents).
Logical volume lv0 successfully resized.
[root@desktop ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv0 vg0 -wi-ao---- 292.00m <--- 擴(kuò)容成功,容量一般都會有少量誤差炊汤,屬于正痴ぃ現(xiàn)象
[root@desktop ~]# resize2fs /dev/vg0/lv0 <--- 刷新文件系統(tǒng)的容量信息
resize2fs 1.42.9 (28-Dec-2013) <--- 注意:如果文件系統(tǒng)是xfs,應(yīng)該使用xfs_growfs /dev/vg0/lv0
Filesystem at /dev/vg0/lv0 is mounted on /home; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/vg0/lv0 is now 299008 blocks long.
[root@desktop ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 xfs 9.8G 3.3G 6.5G 34% /
devtmpfs devtmpfs 660M 0 660M 0% /dev
tmpfs tmpfs 674M 0 674M 0% /dev/shm
tmpfs tmpfs 674M 8.9M 666M 2% /run
tmpfs tmpfs 674M 0 674M 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 ext3 279M 2.1M 263M 1% /home <--- 調(diào)整成功
tmpfs tmpfs 135M 0 135M 0% /run/user/0
題目擴(kuò)展
? ? ??如果當(dāng)前容量比題目要求調(diào)整的目標(biāo)容量要大抢腐,那么就需要給邏輯卷裁剪容量
? ? ??xfs文件系統(tǒng)不支持縮小
參考步驟
[root@desktop ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 xfs 9.8G 3.3G 6.5G 34% /
devtmpfs devtmpfs 660M 0 660M 0% /dev
tmpfs tmpfs 674M 0 674M 0% /dev/shm
tmpfs tmpfs 674M 8.9M 666M 2% /run
tmpfs tmpfs 674M 0 674M 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 ext3 279M 2.1M 263M 1% /home <--- 確認(rèn)容量為279M姑曙,現(xiàn)調(diào)整為150M
tmpfs tmpfs 135M 0 135M 0% /run/user/0
[root@desktop ~]# umount /dev/vg0/lv0 <--- 縮小容量前必須先卸載文件系統(tǒng)
[root@desktop ~]# e2fsck /dev/vg0/lv0 <--- 縮小前必須檢測文件系統(tǒng),以免把文件系統(tǒng)的錯誤擴(kuò)大
e2fsck 1.42.9 (28-Dec-2013)
/dev/vg0/lv0: clean, 11/75776 files, 15740/299008 blocks
[root@desktop ~]# resize2fs /dev/vg0/lv0 150m <--- 必須先刷新文件系統(tǒng)的容量信息迈倍,這是與擴(kuò)容相反的伤靠,順序錯了就會損壞
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/vg0/lv0' first. <--- 如果已經(jīng)檢測過,但執(zhí)行多次還是這個提示啼染,再次執(zhí)行的時候添加參數(shù)-f
[root@desktop ~]# resize2fs -f /dev/vg0/lv0 150m <--- 添加參數(shù) -f 強(qiáng)制調(diào)整
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg0/lv0 to 153600 (1k) blocks.
The filesystem on /dev/vg0/lv0 is now 153600 blocks long.
[root@desktop ~]# lvreduce -L 150m /dev/vg0/lv0 <--- 再裁剪邏輯卷設(shè)備的容量
Rounding size to boundary between physical extents: 152.00 MiB
WARNING: Reducing active logical volume to 152.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv0? [y/n]: y <--- 需要輸入y進(jìn)行確認(rèn)
Size of logical volume vg0/lv0 changed from 292.00 MiB (73 extents) to 152.00 MiB (38 extents).
Logical volume lv0 successfully resized.
[root@desktop ~]# mount /dev/vg0/lv0 /home/ <--- 如無意外宴合,就能正確掛載
[root@desktop ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 xfs 9.8G 3.3G 6.5G 34% /
devtmpfs devtmpfs 660M 0 660M 0% /dev
tmpfs tmpfs 674M 0 674M 0% /dev/shm
tmpfs tmpfs 674M 8.9M 666M 2% /run
tmpfs tmpfs 674M 0 674M 0% /sys/fs/cgroup
tmpfs tmpfs 135M 0 135M 0% /run/user/0
/dev/mapper/vg0-lv0 ext3 142M 1.6M 133M 2% /home <--- 縮小容量成功
第五題 創(chuàng)建用戶和用戶組
請按照以下要求創(chuàng)建用戶、用戶組:
- 新建一個名為adminuser的組迹鹅,組id為40000
- 新建一個名為natasha的用戶卦洽,并將adminuser作為其附屬組
- 新建一個名為harry的用戶,并將adminuser作為其附屬組
- 新建一個名為sarah的用戶斜棚,其不屬于adminuser組阀蒂,其在系統(tǒng)中沒有任何可交互的shell
- natasha、harry和sarah三個用戶的密碼均設(shè)置為redhat
參考答案
[root@desktop ~]# groupadd -g 40000 adminuser
[root@desktop ~]# useradd -G adminuser natasha
[root@desktop ~]# useradd -G adminuser harry
[root@desktop ~]# useradd -s /sbin/nologin sarah
[root@desktop ~]# echo redhat | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@desktop ~]# echo redhat | passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@desktop ~]# echo redhat | passwd --stdin sarah
Changing password for user sarah.
passwd: all authentication tokens updated successfully.
第六題 配置文件/var/tmp/fstab
的權(quán)限
復(fù)制文件/etc/fstab到/var/tmp目錄下弟蚀,并按照以下要求配置/var/tmp/fstab文件的權(quán)限:
- 該文件的所屬人為root
- 該文件的所屬組為root
- 該文件對任何人均沒有執(zhí)行權(quán)限
- 用戶natasha對該文件有讀和寫的權(quán)限
- 用戶harry對該文件既不能讀也不能寫
- 所有其他用戶(包括當(dāng)前已有用戶及未來創(chuàng)建的用戶)對該文件都有讀的權(quán)限
參考答案
[root@desktop ~]# cp /etc/fstab /var/tmp/ <--- 注意cp和mv的區(qū)別
[root@desktop ~]# chown root:root /var/tmp/fstab <--- 更改文件所有者和所有組
[root@desktop ~]# chmod a-x /var/tmp/fstab <--- 所有人不能執(zhí)行該文件
[root@desktop ~]# setfacl -m u:natasha:rw,u:harry:--- /var/tmp/fstab <--- 對兩個用戶分別設(shè)置不同的權(quán)限
[root@desktop ~]# getfacl /var/tmp/fstab <--- 檢查最后結(jié)果
getfacl: Removing leading '/' from absolute path names
# file: var/tmp/fstab
# owner: root
# group: root
user::rw-
user:natasha:rw-
user:harry:---
group::r--
mask::rw-
other::r--
第七題 建立計劃任務(wù)
對natasha用戶建立計劃任務(wù)脂新,要求在本地時間的每天14 : 23執(zhí)行以下命令:
- /bin/echo "rhcsa"
參考答案
[root@desktop ~]# crontab -e -u natasha
23 14 * * * /bin/echo "rhcsa"
解析:每一列對應(yīng)的含義
分鐘 | 小時 | 每天 | 每月 | 每星期 |
---|---|---|---|---|
23 | 14 | * | * | * |
第八題 創(chuàng)建一個共享目錄
在/home目錄下創(chuàng)建名為admins的子目錄,并按以下要求設(shè)置權(quán)限:
- /home/ admins目錄的所屬組為adminuser
- 該目錄對adminuser 組的成員可讀可執(zhí)行可寫粗梭,但對其他用戶沒有任何權(quán)限争便,但root不受限制
- 在/home/admins目錄下所創(chuàng)建的文件的所屬組自動被設(shè)置為adminuser
參考答案
[root@desktop ~]# mkdir /home/admins
[root@desktop ~]# chgrp adminuser /home/admins/ <--- 更改所屬組
[root@desktop ~]# chmod g=rw,o=--- /home/admins/ <--- 修改權(quán)限
[root@desktop ~]# chmod g+s /home/admins/ <--- 設(shè)定特權(quán)位,實現(xiàn)第三個要求
[root@desktop ~]# ls -ld /home/admins/
drwxrwS---. 2 root adminuser 1024 Mar 31 18:08 /home/admins/ <--- 查看最終屬性
第九題 升級系統(tǒng)內(nèi)核
從http://server.group8. example.com/pub/
下找到需要升級的內(nèi)核 断医,同時滿足下列要求:
- 當(dāng)系統(tǒng)重新啟動之后滞乙,升級的內(nèi)核要作為默認(rèn)的內(nèi)核
- 原來的內(nèi)核要被保留,并且仍然可以正常啟動
參考答案
[root@desktop ~]# curl --silent http://server.group8.example.com/pub/ | grep kernel <--- 通過命令快速獲取內(nèi)核包的地址信息
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="kernel-3.10.0-327.4.5.el7.x86_64.rpm">kernel-3.10.0-327.4...></a></td><td align="right">2016-12-30 16:48 </td><td align="right"> 33M</td><td> </td></tr>
[root@desktop ~]# yum install -y http://server.group8.example.com/pub/kernel-3.10.0-327.4.5.el7.x86_64.rpm <--- 使用yum命令安裝內(nèi)核
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
kernel-3.10.0-327.4.5.el7.x86_64.rpm | 33 MB 00:00:01
Examining /var/tmp/yum-root-Un01d_/kernel-3.10.0-327.4.5.el7.x86_64.rpm: kernel-3.10.0-327.4.5.el7.x86_64
Marking /var/tmp/yum-root-Un01d_/kernel-3.10.0-327.4.5.el7.x86_64.rpm as an update to kernel-3.10.0-123.el7.x86_64
Marking /var/tmp/yum-root-Un01d_/kernel-3.10.0-327.4.5.el7.x86_64.rpm as an update to kernel-3.10.0-327.el7.x86_64
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-327.4.5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================
Installing:
kernel x86_64 3.10.0-327.4.5.el7 /kernel-3.10.0-327.4.5.el7.x86_64 136 M
Transaction Summary
===================================================================================================================================================================
Install 1 Package
Total size: 136 M
Installed size: 136 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : kernel-3.10.0-327.4.5.el7.x86_64 1/1
Verifying : kernel-3.10.0-327.4.5.el7.x86_64 1/1
Installed:
kernel.x86_64 0:3.10.0-327.4.5.el7
Complete!
[root@desktop ~]# grub2-editenv list <--- 驗證
saved_entry=Red Hat Enterprise Linux Server (3.10.0-327.4.5.el7.x86_64) 7.2 (Maipo)
第十題 綁定外部驗證服務(wù)
系統(tǒng)server.group8.example.com
提供了一個LDAP驗證服務(wù)
鉴嗤,您的系統(tǒng)需要按照以下要求綁定到這個服務(wù)上:
- 驗證服務(wù)器的基本DN是: dc=group8, dc=example, dc=com
- 賬戶信息和驗證信息都是由LDAP提供連接需要使用證書加密斩启,整數(shù)可以在下面的鏈接中下載:
http://server.group8.example.com/pub/cacert.pem
當(dāng)正確完成配置后,用戶thales可以登錄系統(tǒng)醉锅,登錄密碼是redhat
參考答案
[root@desktop ~]# yum install -y sssd authconfig-gtk.x86_64 <--- 安裝ldap驗證所需的服務(wù)(sssd必須要有)
mkdir /etc/openldap/cacerts/ <--- 首次使用兔簇,必須先自己建立保存證書的目錄(或者運行authconfig-tui自動生成)
[root@desktop ~]# wget -O /etc/openldap/cacerts/ca.pem http://server.group8.example.com/pub/cacert.pem <--- 下載證書,保存的證書后綴名必須是.pem
--2020-03-31 18:43:51-- http://server.group8.example.com/pub/cacert.pem
Resolving server.group8.example.com (server.group8.example.com)... 172.24.8.254
Connecting to server.group8.example.com (server.group8.example.com)|172.24.8.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1350 (1.3K)
Saving to: ‘/etc/openldap/cacerts/ca.pem’
100%[=========================================================================================================================>] 1,350 --.-K/s in 0s
2020-03-31 18:43:51 (213 MB/s) - ‘/etc/openldap/cacerts/ca.pem’ saved [1350/1350]
[root@desktop ~]# authconfig-tui
[root@desktop ~]# getent passwd thales
thales:*:2001:2001:thales:/home/ldap/thales:/bin/bash
報錯: 如果無法獲得thales用戶的信息,或者在執(zhí)行authconfig-tui命令之后報錯
排錯: 在確保上面填寫的信息與題目提供的信息一致正確的前提下垄琐,一般sssd服務(wù)無法正確啟動導(dǎo)致的边酒,而導(dǎo)致該服務(wù)啟動失敗一般是時間沒有和服務(wù)器同步
解決: 先完成后面ntp時間同步的題目,然后重新啟動sssd服務(wù)
[root@desktop ~]# systemctl restart sssd
第十一題 配置autofs
按照下述要求配置autofs用來自動掛載LDAP用戶的主目錄:
-
server.group8.examp1e.com
通過NFS
輸出了/rhome
目錄到您的系統(tǒng)狸窘,這個文件系統(tǒng)包含了用戶thales的主目錄墩朦,并且己經(jīng)預(yù)先配置好了。 - thales用戶的主目錄是:
server.group8.example.com:/rhome/thales
- thales用戶的主目錄應(yīng)該掛載到
本地的/home/ldap/thales
- 用戶對其主目錄必須是讀寫的
- thales的登錄密碼是redhat
參考答案
[root@desktop ~]# yum install -y autofs
[root@desktop ~]# vim /etc/auto.master
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/misc /etc/auto.misc
/home/ldap /etc/auto.ldap <--- 當(dāng)系統(tǒng)訪問以/home/ldap路徑開頭的資源時翻擒,讀取/etc/*.ldap配置文件進(jìn)行自動掛載
[root@desktop ~]# vim /etc/auto.ldap
* -rw,sync,soft server.group8.eample.com:/rhome/& <--- 注意-rw前面的“-”符號氓涣,還有最后“/&”
配置含義:當(dāng)訪問/home/ldap/* (*代表任意路徑)的資源時,自動掛載到
server.group8.example.com:/rhome/對應(yīng)路徑的資源
[root@desktop ldap]# ssh thales@localhost <--- 登錄驗證
thales@localhost's password:
Last login: Tue Mar 31 19:37:33 2020 from localhost
[thales@desktop ~]$ ls
file1 file2 file3
[thales@desktop ~]$ pwd
/home/ldap/thales
[thales@desktop ~]$ logout
第十二題 配置NTP
配置您的系統(tǒng)時間與服務(wù)器server.group8.example.com
同步陋气,要求系統(tǒng)重啟后依然生效
提示: redhat 7.0 以后的版本劳吠,時間同步采用chrony服務(wù)來替代原有的ntp服務(wù),該服務(wù)默認(rèn)已安裝
參考答案
[root@desktop ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst <--- 把這里原來的4行注釋掉巩趁,考試試環(huán)境根本無法與這四臺服務(wù)器通信
server 1.rhel.pool.ntp.org iburst <--- 把它們留著這里只會影響同步的效率
server server.group8.example.com iburst <--- 把題目要求添加的時間服務(wù)器地址添加到這里
[root@desktop ~]# systemctl enable chronyd
[root@desktop ~]# systemctl restart chronyd
[root@desktop ~]# chronyc <--- 手工同步時間
chrony version 2.1.1
Copyright (C) 1997-2003, 2007, 2009-2015 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
chronyc> waitsync <--- 立刻同步時間
try: 1, refid: 172.24.8.254, correction: 0.000000053, skew: 160.854 <--- 看到類似的返回赴背,說明已經(jīng)成功同步了
chronyc> exit
第十三題 創(chuàng)建一個歸檔
創(chuàng)建一個名為/root/sysconfig.tar.bz2
的歸檔文件,其中包含/etc/sysconfig目錄
中的內(nèi)容晶渠,tar歸檔文件必須使用bzip2
進(jìn)行壓縮
參考答案
[root@desktop ~]# tar -jcf /root/sysconfig.tar.bz2 /etc/sysconfig/
參數(shù)解析:
? ? ??-c
使用bzip2壓縮歸檔
文件
? ? ??如果考試的時候凰荚,要求使用gzip壓縮
,那么參數(shù)應(yīng)該是-z
, 也就是-zcf
? ? ??如果記不住褒脯,可以#man tar
第十四題 配置一個用戶帳號
請創(chuàng)建一個名為jay
的用戶便瑟, 并滿足以下要求:
- 用戶id為3456
- 密碼為glegunge
參考答案
[root@desktop ~]# useradd -u 3456 jay
[root@desktop ~]# echo glegunge | passwd --stdin jay
Changing password for user jay.
passwd: all authentication tokens updated successfully.
第十五題 添加一個swap分區(qū)
在您的系統(tǒng)中添加一個新的swap
分區(qū),并滿足以下要求:
- swap分區(qū)容量為
512MiB
- 當(dāng)您的系統(tǒng)啟動時番川,swap分區(qū)應(yīng)該可以
自動掛載
不要移除
或者修改其他已經(jīng)存在于您的系統(tǒng)中的swap分區(qū)
參考答案
[root@desktop ~]# lsblk <--- 查看磁盤
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 9.8G 0 part /
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 500M 0 part
└─vg0-lv0 253:0 0 152M 0 lvm /home
[root@desktop ~]# fdisk /dev/sda <--- 注意:考試使用的是kvm虛擬機(jī)到涂,所以硬盤是/dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): e <--- 考試時注意磁盤分區(qū),目前環(huán)境無法再分主分區(qū)颁督,所以我們把磁盤剩余空間都首先劃分為擴(kuò)展分區(qū)
Selected partition 4
First sector (25602048-41943039, default 25602048): <--- 直接回車践啄,默認(rèn)使用剩余空間的起始柱面
Using default value 25602048
Last sector, +sectors or +size{K,M,G} (25602048-41943039, default 41943039):
Using default value 41943039
Partition 4 of type Extended and of size 7.8 GiB is set <--- 把硬盤的剩余的所有空間劃分給擴(kuò)展分區(qū)
Command (m for help): n <--- 在剛剛創(chuàng)建的擴(kuò)展分區(qū)上劃分新的邏輯分區(qū)
All primary partitions are in use
Adding logical partition 5 <--- 分區(qū)編號自動設(shè)置為5
First sector (25604096-41943039, default 25604096): <--- 直接回車,設(shè)置分區(qū)起始柱面
Using default value 25604096
Last sector, +sectors or +size{K,M,G} (25604096-41943039, default 41943039): +512M <--- 通過輸入容量沉御,設(shè)定分區(qū)的容量大杏旆怼(容量嚴(yán)格為大寫)
Partition 5 of type Linux and of size 512 MiB is set
Command (m for help): t <--- 修改分區(qū)的默認(rèn)類型標(biāo)記
Partition number (1-5, default 5): <--- 直接回車,修改剛創(chuàng)建的編號為5的分區(qū)吠裆,如果不是伐谈,可以自行填寫分區(qū)編號
Hex code (type L to list all codes): 82 <--- 82代表swap類型
Changed type of partition 'Linux' to 'Linux swap / Solaris'
Command (m for help): p <--- 查看分區(qū)結(jié)果
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bffad
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 20482047 10240000 83 Linux
/dev/sda2 20482048 24578047 2048000 82 Linux swap / Solaris
/dev/sda3 24578048 25602047 512000 83 Linux
/dev/sda4 25602048 41943039 8170496 5 Extended <--- 這是新創(chuàng)建的擴(kuò)展分區(qū)
/dev/sda5 25604096 26652671 524288 82 Linux swap / Solaris <--- 這是新創(chuàng)建的swap分區(qū)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@desktop ~]#
[root@desktop ~]# partprobe <--- 同步磁盤信息
[root@desktop ~]# ls -l /dev/sda5 <--- 如果生成設(shè)備文件失敗可以使用#partx -a /dev/sda再次生成,如果還失敗就重啟系統(tǒng)
brw-rw----. 1 root disk 8, 5 Mar 31 20:18 /dev/sda5
[root@desktop ~]# mkswap /dev/sda5 <--- 將該分區(qū)格式化為swap格式
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=88a10116-1fd6-43b9-88c4-75a0869c58d0 <--- 復(fù)制這個UUID试疙,如果想再次查看uuid可以使用# blkid /dev/sda5查看
[root@desktop ~]# swapon /dev/sda5 <--- 啟用該分區(qū)
[root@desktop ~]# swapon -s <--- 查看swap分區(qū)
Filename Type Size Used Priority
/dev/sda2 partition 2047996 0 -1
/dev/sda5 partition 524284 0 -2
[root@desktop ~]# vim /etc/fstab <--- 寫入配置文件诵棵,開機(jī)自動掛載
#
# /etc/fstab
# Created by anaconda on Mon Jul 18 19:38:41 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=3c6e20fa-3e12-42ca-8dba-b12eee74e43e / xfs defaults 1 1
UUID=ff7d2e6d-c2d7-46a0-af09-70c85898ab46 swap swap defaults 0 0
/dev/mapper/vg0-lv0 /home ext3 defaults 0 0
UUID=88a10116-1fd6-43b9-88c4-75a0869c58d0 swap swap defaults 0 0 <--- 增加新的swap分區(qū)的掛載設(shè)定
提示: 您當(dāng)然也可以把UUID替換成/dev/sda5 (考試的時候是/dev/vda5或其他),但是實際工作中祝旷,強(qiáng)烈建議使用UUID掛載
第十六題 查找文件
請把系統(tǒng)上擁有者為jay
用戶的所有文件履澳,并將其拷貝到/root/findfiles
目錄中
參考答案
[root@desktop ~]# mkdir /root/findfiles
[root@desktop ~]# find / -user jay -exec cp -a {} /root/findfiles/ \;
第十七題 查找一個字符串
把/usr/share/dict/words
文件中所有包含seismic字符串
的行找到嘶窄,并將這些行按照原始文件中的順序存放到/root/wordlist
中,/root/wordlist文件不能包含空行
參考答案
[root@desktop ~]# grep seismic /usr/share/dict/words | grep -v ^$ > /root/wordlist <--- "grep -V ^$" 是為了保證文件中不能包含空行
第十八題 創(chuàng)建一個邏輯卷
請按下列要求創(chuàng)建一個新的邏輯卷:
- 創(chuàng)建一個名為
datastore
的卷組距贷,卷組的PE
尺寸為16MiB
- 邏輯卷的名字為
database
柄冲,所屬卷組為datastore,該邏輯卷由50
個PE組成 - 將新建的邏輯卷格式化為
xfs文件系統(tǒng)
储耐,要求系統(tǒng)啟動時,該邏輯卷能被自動掛載到/mnt/database目錄
參考答案
[root@desktop ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (26654720-41943039, default 26654720): <--- 直接回車滨溉,使用默認(rèn)起始柱面
Using default value 26654720
Last sector, +sectors or +size{K,M,G} (26654720-41943039, default 41943039): <--- 直接回車,使用默認(rèn)結(jié)束柱面什湘,用完所有空間
Using default value 41943039
Partition 6 of type Linux and of size 7.3 GiB is set
Command (m for help): t <--- 修改分區(qū)類型標(biāo)記
Partition number (1-6, default 6): <--- 直接回車,修改剛剛劃分的分區(qū)
Hex code (type L to list all codes): 8e <--- 8e代表把類型修改為Linux LVM
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w <--- 保存分區(qū)設(shè)定
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@desktop ~]# partprobe
[root@desktop ~]# ls -l /dev/sda6
brw-rw----. 1 root disk 8, 6 Mar 31 20:40 /dev/sda6
[root@desktop ~]# pvcreate /dev/sda6 <--- 創(chuàng)建物理卷
Physical volume "/dev/sda6" successfully created
[root@desktop ~]# vgcreate -s 16m datastore /dev/sda6 <--- 按照題目要求將PE設(shè)置為16M
Volume group "datastore" successfully created
[root@desktop ~]# vgdisplay datastore
--- Volume group ---
VG Name datastore
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.28 GiB
PE Size 16.00 MiB <--- 確定PE與題目要求一致
Total PE 466
Alloc PE / Size 0 / 0
Free PE / Size 466 / 7.28 GiB
VG UUID YKZKQd-sTEi-PXhE-tw3d-5kzW-0htx-0f7gcm
[root@desktop ~]# lvcreate -n database -l 50 datastore<--- 參數(shù)小寫字母-l晦攒,50代表使用50個PE的容量
Logical volume "database" created.
[root@desktop ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
database datastore -wi-a----- 800.00m <--- 50x16M=800M
lv0 vg0 -wi-ao---- 152.00m
[root@desktop ~]# mkfs.xfs /dev/datastore/database <--- 根據(jù)題目要求闽撤,格式化成對應(yīng)的文件系統(tǒng)格式
meta-data=/dev/datastore/database isize=256 agcount=4, agsize=51200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=204800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@desktop ~]# mkdir /mnt/database
[root@desktop ~]# blkid /dev/datastore/database
/dev/datastore/database: UUID="2a5530be-00c6-465d-a884-9b232ac01991" TYPE="xfs"
[root@desktop ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jul 18 19:38:41 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=3c6e20fa-3e12-42ca-8dba-b12eee74e43e / xfs defaults 1 1
UUID=ff7d2e6d-c2d7-46a0-af09-70c85898ab46 swap swap defaults 0 0
/dev/mapper/vg0-lv0 /home ext3 defaults 0 0
UUID=88a10116-1fd6-43b9-88c4-75a0869c58d0 swap swap defaults 0 0
UUID=2a5530be-00c6-465d-a884-9b232ac01991 /mnt/database xfs defaults 0 0 <--- 增加掛載設(shè)定
[root@desktop ~]# mount -a
[root@desktop ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 xfs 9.8G 3.6G 6.3G 36% /
devtmpfs devtmpfs 660M 0 660M 0% /dev
tmpfs tmpfs 674M 0 674M 0% /dev/shm
tmpfs tmpfs 674M 8.9M 666M 2% /run
tmpfs tmpfs 674M 0 674M 0% /sys/fs/cgroup
tmpfs tmpfs 135M 0 135M 0% /run/user/0
/dev/mapper/vg0-lv0 ext3 142M 1.6M 133M 2% /home
/dev/mapper/datastore-database xfs 797M 33M 765M 5% /mnt/database <--- 檢查符合題目要求
至此,所有題目完成脯颜,必須重啟虛擬機(jī)
哟旗,以便檢測所有考試操作是否在系統(tǒng)重啟后仍然生效。
腳本檢測:
[root@desktop ~]# grade
Input password:
###### Grading the No.1 question ######
Checking root password... PASS*************
Checking your hostname... PASS*************
###### Grading the No.2 question ######
Check Set Selinux PASS*************
###### Grading the No.3 question ######
Check yum repo config PASS*************
Check yum repo enabled PASS*************
###### Grading the No.4 question ######
Checking size of lv0 LV... PASS*************
lv0 LV is too small
Checking size of lv0 filesystem... PASS*************
lv0 filesystem is too small
###### Grading the No.5 question ######
Check Group adminuser create PASS*************
Check User natasha create PASS*************
Check User harry create PASS*************
Check User sarah create PASS*************
Check natasha's Password PASS*************
Check harry's Password PASS*************
Check sarah's Password PASS*************
###### Grading the No.6 question ######
Check Set file or directory PASS*************
###### Grading the No.7 question ######
Check crontab service PASS*************
Check Set user crontab PASS*************
###### Grading the No.8 question ######
Check Set directory gid PASS*************
###### Grading the No.9 question ######
Check Install new Kernel PASS*************
###### Grading the No.10 question ######
Check Use LDAP and Kerberos PASS*************
###### Grading the No.11 question ######
Check AUTOFS PASS*************
###### Grading the No.12 question ######
Check Time sync server set PASS*************
###### Grading the No.13 question ######
Check sysconfig tar PASS*************
###### Grading the No.14 question ######
Check user jay create PASS*************
Check user jay password PASS*************
###### Grading the No.15 question ######
Check swap partision PASS*************
Check Swap partision id PASS*************
Check swap persitent mount in fstab PASS*************
###### Grading the No.16 question ######
Check jay file PASS*************
###### Grading the No.17 question ######
Check grep result file PASS*************
###### Grading the No.18 question ######
Check create LVM VG datastore PASS*************
Check create LVM VG size PASS*************
Check create LVM VG PE size PASS*************
Check create LVM LV database PASS*************
Check create LVM LV size PASS*************
Check mount file system PASS*************