歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> RHCE6.0題庫

RHCE6.0題庫

日期:2017/2/27 16:04:30   编辑:Linux教程
RHCE模擬測試(注意配置selinux):

注意:你的IP,主機名,網關,DNS已經配置好
IP: 172.24.30.5/24
主機名:station.domain30.example.com
你是域domain30.example.com的成員主機,
另一個域是t3gg.com---172.25.0.0/16網絡

1、請將selinux狀態設置為enforcing狀態
# vim /etc/sysconfig/selinux
# setenforce 1

2、請將ip_forward功能打開,並永久生效。
# vim /etc/sysctl.comf
# sysctl -a |grep ip_forward
# sysctl -p 永久生效

3、配置ssh允許harry用戶訪問,拒絕t3gg.com域訪問
# iptables -L
# iptables -F
# iptables -Z
# iptables -X
# iptables -F -t nat
# iptables -Z -t nat
# iptables -X -t nat
# iptables -P INPUT ACCEPT 視情況而定!
# iptables -P OUTPUT ACCEPT
# iptables -P FORWARD ACCEPT
# servcice iptables save
# iptables -A INPUT -s 172.25.0.0/16 -j REJECT
# iptables -A INPUT ! -s 172.24.30.0/24 -j REJECT 二選一即可
# service iptables save 別忘了保存

4、配置ftp目錄/var/ftp/pub允許匿名下載和上傳文件,拒絕t3gg.com域訪問
# yum -y install vsftpd
# yum -y install lftp
# chkconfig vsftpd on;servcie vsftpd start
# vim /etc/vsftpd/vsftpd.conf
12 anonymous_enable=YES
27 anon_upload_enable=YES
31 anon_mkdir_write_enable=YES
# chmod o+w /var/ftp/pub
# setsebool -P allow_ftpd_full_access=1

5、將/root/cdrom.iso掛載到/opt/data下,並設置為開機自動掛載
# mkdir data
# vim /etc/fstab
/root/cdrom.iso /opt/data iso9660 default,loop,ro 0 0
# mount -a

6、配置web服務器,能被http://station.domain30.example.com訪問

7、配置web服務器,實現虛擬主機。 http://www.domain30.example.com能訪問到/www/virtual目錄下的頁面,頁面從http://ip/dir/example.html下載。並保證,http://station.domain30.example.com同樣能被訪問到之前的內容。

8、從http://ip/dir/restircted.html下載的頁面,能被本地用戶harry通過路徑http://station.domain30.example.com/訪問到, [系統用戶可以登錄],但是不可以被t3gg.com域訪問。注意:請先完全讀懂6、7、8題意!!!
# yum -y install httpd
# chkconfig httpd on;service httpd start
# vim /etc/httpd/conf/httpd.conf
990 NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName station.domain30.example.com
<Directory /var/www/html/>
authname web
authtype basic
authuserfile /etc/httpd/.Linux/1727.html' target='_blank'>htpasswd
require valid-user
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/virtual
ServerName www.domain30.example.com
</VirtualHost>
# htpasswd -cm /etc/httpd/.ptpasswd harry
# cut -d: -f1-2 /etc/shadow >>/etc/httpd/.htpasswd
# man semanage
# semanage fcontext -a -t httpd_sys_content_t ‘/www(/.*)?’
# restorecon -vRF /www/
# service httpd restart

9、配置nfs服務器,將/common目錄共享給domain30.example.com域,並允許客戶端以root用戶訪問時,也擁有root用戶權限
# mkdir /common
# chmod o+w /common
# yum -y install nfs-utils*
# chkconfig nfs on
# service nfs start
# vim /etc/exports
/common *.domain30.example.com(rw,no_root_squash,sync)
# exportfs -r
# exportfs -v

10、配置samba服務器,將/common共享,能被浏覽到。用戶harry對此共享有讀寫權限,如果需要,harry用戶密碼為harryuser。
# mkdir /common
# chcon -t samba_share_t /common
# yum -y install samba
# chkconfig smb on;service smb start
# vim /etc/samba/smb.conf
74 workgroup = RHCE
75 server string = samba server
101 security = user
[common]
path = /common
writable = yes
# smbpasswd harry [harryuser]
# chmod o+w /common
# service smb restart

11、配置一台domain30.example.com域的郵件服務器,要求可以在服務器本地或者通過harry用戶從網絡上連接到服務器收發郵件。harry用戶的郵箱是/var/spool/mail/harry。注意DNS服務器已經幫你做好MX記錄的解析。
# yum -y install postfix
# chkconfig postfix on
# service postfix start
# vim /etc/postfix/main.cf
75 myhostname = station.domian30.example.com
83 mydomain = domain30.example.com
98 myorigin = $myhostname
116 inet_interfaces = all
164 mydestination = $myhostname,$mydomain
# service postfix restart

12、連接到郵件服務器給admin發郵件,可以被harry用戶收到
# vim /etc/aliases
admin: harry,tom
# newaliases

13、配置內核參數 rhelblq=1,並要求可以通過/proc/cmdline驗證到你的內核參數
# vim /boot/grub/grub.conf
....... rhgb quiet rhelblq=1
重啟之後
# cat /proc/cmdline

14、配置cron不允許tom用戶使用
# vim /etc/cron.deny
Tom

15、寫一個腳本/root/program,要求當給腳本輸入參數kernel時,腳本返回user,給腳本輸入參數user時,腳本返回kernel。而腳本沒有參數或者參數錯誤時,從標准錯誤輸出輸出“usage:/root/program kernel|user”
[root@station ~]# vim program 這裡已經指定腳本名稱了
#!/bin/bash
case $1 in
kernel)
echo user
;;
user)
echo kernel
;;
*)
echo “usage:/root/program kernel|user”
esac
[root@station ~]# chmod u+x program
[root@station ~]# ./program user

16、請你訪問iscsi共享存儲,存儲服務器的地址是172.24.30.100,分出150M空間,格式化成ext3文件系統,掛載到/mnt/data下,並實現開機自動掛載。 為了實驗,可簡單自建個服務器
# fdisk -cu /dev/sda
# partx -a /dev/sda
# yum -y install scsi-target-utils
# vim /etc/tgt/targets.conf
<target iqn.2012-05.example.domain30:rhce>
backing-store /dev/sda5
initiator-address 172.24.30.5
</target>
# chkconfig tgtd on
# service tgtd start

客戶機
# yum -y install iscsi-initiator-utils
# chkconfig iscsi on;service iscsi restart
# chkconfig iscsid on;service iscsid restart
# man iscsiadm
# iscsiadm -m discovery -t st -p 172.24.30.100
# iscsiadm -m node -T iqn.2012-05.example.domain30:rhce -p
172.24.30.100:3260 -l
# fdisk -cul

# fdisk -cu /dev/sdaX
# partprobe /dev/sdaX
# mkfs.ext4 /dev/sdaX
# mkdir /mnt/data
# blkid /dev/sdaX
# vim /etc/fstab
UUID=..... /mnt/data ext4 defaults,_netdev 0 0
# mount -a

新增加強:!!!


1.創建計劃任務,要求root 在每月的1.3.5 日14:30 分執行/bin/echo hello 僅允許root 和
natasha 用戶能創建計劃任務
30 14 1,3,5 * * /bin/echo howdy
[root@demo ~]# vim /etc/cron.allow
natasha
root

① 這2個文件都不存在,只有root用戶可編輯計劃任務;文件
② 僅/etc/cron.deny,只拒絕寫在其中的用戶編輯計劃任;
③ 僅/etc/cron.allow,只寫在其中的用戶被允許編輯計劃任務;
④ 均存在。/etc/cron.deny文件被忽略。等於僅/etc/cron.allow。

2、使用者 natasha 須設立一個排程工作,在本地時間每天 20:45 執行 /bin/echo howdy,
拒絕harry 創建任務計劃
[root@demo ~]# crontab -e -u natasha
45 20 * * * /bin/echo howdy
[root@demo ~]# vim /etc/cron.deny
harry

3、將/home 分區增大為250Mib 在250-300Mib 之間都是正確的,並且開機能正常使用 。
[root@demo ~]# lvextend -L 250M /dev/mapper/vgsrv-home
[root@demo ~]# resize2fs /dev/mapper/vgsrv-home
[root@demo ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vgsrv-root
ext4 3.6G 2.3G 1.1G 68% /
/dev/vda1 ext4 260M 32M 216M 13% /boot
/dev/mapper/vgsrv-home
ext4 260M 11M 237M 5% /home
program
program

4、寫一個腳本/root/pprrooggrraamm,要求當給腳本輸入參數kernel 時,腳本返回user,給腳本輸入參數user 時,腳本返回 kernel。而腳本沒有參數或者參數錯誤是,從標准錯誤輸出輸出
“usage:/root/program kernel|user”
[root@station ~]# vim program 這裡已經指定腳本名稱了
#!/bin/bash
if
[ $1 = kernel ];then
echo user
elif
[ $1 = user ];then
echo kernel
else
echo “usage:/root/program kernel|user”
fi
[root@server12 ~]# chmod u+x program

6、設置網頁流覽限制,要求只有本機可以訪問wwwX.example.com
<VirtualHost *:80>
<Directory /var/www/html/www12>
order allow,deny
allow from localhost
allow from 127.0.0.1
allow from www12.example.com
allow from server12.example.com
allow from 192.168.0.12
</Directory>
DocumentRoot /var/www/html/www12
ServerName www12.example.com
</VirtualHost>

7、設置網頁權限限制,natasha 用戶可以對/var/www/html/www12 有讀寫的權限
[root@server12 ~]#setfacl -m u:natasha:rw /var/www/html/www12

apache 服務最近考試變化很多,一定要靈活
Copyright © Linux教程網 All Rights Reserved