rhcetext1的总结报告.docx
《rhcetext1的总结报告.docx》由会员分享,可在线阅读,更多相关《rhcetext1的总结报告.docx(16页珍藏版)》请在冰豆网上搜索。
rhcetext1的总结报告
RHCT部分
注:
当大家看到这个文件时,你已经把前三道题做成功了,可以直接从第四题开始,另外,本实验环境有两个域:
对应的是192.168.0.0/255.255.255.0craker.org对应的是192.168.1.0/255.255.255.0
一破解密码,要求root用户登录密码为redhat,家目录是/root(不能进入recue模式)
这个要掌握技巧,可以在打开电脑的时候就做的
二设置网络IP192.168.0.X
网关为192.168.0.254
Nameserver192.168.0.254
HostnamestationX
设置本机默认启动是runlevel5
答案:
system-config-network-tui
vim/etc/sysconfig/network
vim/etc/sysconfig/network-scripts/ifcfg-eth0
hostname
Vim/etc/hosts
vim/etc/inittab更改运行级别
[root@station15~]#runlevel
N5
三配置nfsclient,要求让系统每次启动时能自动把192.168.0.254:
/var/ftp/pub挂载到/mnt/nfs目录下,进入/mnt/nfs,能看到一个rhcetest的文件
答案:
首先,先配置NIS客户端
配置域名和IP地址
vim/etc/auto.master
/mnt/etc/nfs.misc
vim/etc/nfs.misc
nfs-fstype=nfs192.168.0.254:
/var/ftp/pub/
ls/mnt/nfs
serviceautofsrestart
四安装fonts-chinese包,按照rhcetest文件的描述完成考试的剩下内容
答案:
首先配置yum库,然后用yuma安装包;或者用RPM来安装;
Yuminstallfonts-chinese
rpm–ivhfonts-chinese*
别忘了要先配置yum库哦
五为默认的网卡设置一个别名叫“网卡名:
1”,设置IP为192.168.1.X,同时设置一个路由,指定去192.168.1.0/24的网关是192.168.1.254
答案;
也可以使用图像界面添加网卡
必须先关机。
在添加网卡
cd/etc/sysconfig/network-scripts/
#cpifcfg-eth0ifcfg-eth0:
1
vimifcfg-eth0:
1
DEVICE=eth0:
1(名字一定要改的,不能忘了哦!
!
!
)
HWADDR=00:
0c:
29:
35:
bd:
58
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.1.15
GATEWAY=192.168.1.254
TYPE=Ethernet
servicenetworkrestart
#routeadd-net192.168.1.0netmask255.255.255.0gw192.168.1.254
六在192.168.0.254:
/var/ftp/pub/errata目录下有更新的kernel,
1你可以选择yum或者rpm工具完成kernel的更新
从图形界面下载kernel包到桌面,用RPM安装
rpm-ivhkernel-xen-2.6.18-92.1.6.el5.i686.rpm
2要保证系统启动默认加载更新的kernel
vim/boot/grub/grub.conf
default=0
3挑战题:
试着为grub设置密码为redhat
[root@station15~]#grub-md5-crypt
Password:
Retypepassword:
$1$cd19Q/$8s.x2Rm4Uas8uyKf9i8wP.
vim/boot/grub/grub.conf
七分两个分区做RAID0,用来挂载/rhome,大小是300M,文件系统类型是ext3
答案:
首先创建两个分去,因为RAID0需要两个分区,(别忘了该文件系统类型)
然后
partprobe
mdadm-C/dev/md0-l0-n2/dev/sda5/dev/sda6
vim/etc/fstab将其挂载在/rhome上
mkdif/rhome
mke2fs-j/dev/md0一定不能少的
mount/dev/md0/rhome
mount
八创建kevin,mandy,todd和erien用户,创建teacher,student组
答案;
[root@station15~]#groupaddteacher
[root@station15~]#groupaddstudent
[root@station15~]#forUSERinkevinmandytodderien
>douseradd$USER
>done
要求:
kevintodd属于teacher组,密码设置成password
[root@station15~]#usermod-gteacherkevin
[root@station15~]#passwdkevin
[root@station15~]#usermod-gteachertodd
[root@station15~]#passwdtodd
mandy属于student组,并且指定他的家目录是/rhome,设置密码有效期是20天,密码任意设置。
usermod-gstudent-d/rhome/mandymandy
passwd-x20mandy或者chage-M30mandy
用查看vim/etc/shadow
erien属于erien组同时隶属于teacher和student组,但指定他使用的shell为/sbin/nologin
usermod-Gteacher,student-s/sbin/nologinerien
九拷贝/etc/passwd到/student
1要求该文件拥有者是root,拥有组是student
2其它人没有执行权限3kevin能读写该文件4todd只能读
答案:
[root@station15~]#mkdir/student
[root@station15~]#cp/etc/passwd/student/
[root@station15~]#chownroot.student/student/passwd
[root@station15~]#chmod776/student/passwd
[root@station15~]#setfacl-mu:
todd:
r/student/passwd
[root@station15~]#setfacl-mu:
kevin:
rw/student/passwd
[root@station15~]#getfacl/student/passwd
getfacl:
Removingleading'/'fromabsolutepathnames
#file:
student/passwd
#owner:
root
#group:
student
user:
:
rwx
user:
kevin:
rw-
user:
todd:
r--
group:
:
rwx
mask:
:
rwx
other:
:
rw-
十创建/student/test目录,要求1student组的用户对此目录有完全权限2kevin对此目录有r-x权限
3在有此目录中创建的文件,只本人和root可以删除
4在此目录中创建的文件,拥有组一定是student
答案:
[root@station15~]#mkdir/student/test
[root@station15~]#chownroot.student/student/test/必须有的
[root@station15~]#setfacl-mg:
student:
rwx/student/test/
[root@station15~]#getfacl/student/test/
getfacl:
Removingleading'/'fromabsolutepathnames
#file:
student/test
#owner:
root
#group:
root
user:
:
rwx
group:
:
r-x
group:
student:
rwx
mask:
:
rwx
other:
:
r-x
[root@station15~]#setfacl-mu:
kevin:
r-x/student/test/
[root@station15~]#chmod1775/student/test/
[root@station15~]#chmod3776/student/test/
可以在目录中创建一个文件试试,看看去属组是不是student
十一todd用户设置一个计划任务
每周三和周五的三点钟,每两分钟统计一下内存的使用情况
crontab-utodd–e
servicecrondrestart
十二创建用户student1到student50,指定组为student组,其中为student1和student2这两个用户设置磁盘配额,要求以这两个用户登录系统后,运行ddif=/dev/zeroof=/home/studentX/filetestbs=1Mcount=10是成功的,ddif=/dev/zeroof=/home/studentX/filetestbs=1Mcount=30是失败的
答案:
[root@station15~]#foriin$(seq150);
Do
useradd-gstudentstudent$i;
done
[root@station15~]#vim/etc/fstab加入usrquota用户
[root@station15~]#mount-oremount,usrquota/home
[root@station15~]#quotacheck-cu/home
[root@station15~]#quotaon/home
[root@station15~]#edquota-ustudent1设置软限制和硬限制
Softhard
500025000
[root@station15~]#edquota-ustudent2或者用edquota-pstudent1student2
[root@station15~]#su-student1
[student1@station15~]$ddif=/dev/zeroof=/home/studentX/filetestbs=1Mcount=10正常
[student1@station15~]$ddif=/dev/zeroof=/home/student1/filetestbs=1Mcount=30超出限额
[root@station15~]#su-student2
[student2@station15~]$ddif=/dev/zeroof=/home/student2/filetestbs=1Mcount=10正常
[student2@station15~]$ddif=/dev/zeroof=/home/student2/filetestbs=1Mcount=30超出限额
注意单位的换算啊
注意:
此题要将组的限制也加上,为何呢?
?
?
vim/etc/fstab
usrquota,grpquota
十三192.168.0.254这个服务器上有用户guest200X,密码为password,nisdomainisnotexample
1要求这个用户可以通过你的机器登录
2192.168.0.254通过nfs把/home共享出来了
3guest200X的家目录是:
/home/guests/guest200X
4guest200X的家目录应该能自动挂载到/home/guests/guest200X
5guest200X的家目录必须要有可写权限
答案:
Setup设置域名和服务器名
mount-tnfs192.168.0.254/home/home出现错误
vim/etc/auto.master
/home/etc/home.misc这个/home/guests是自动挂载的目录
cp/etc/auto.misc/etc/home.misc
vim/etc/home.misc
guest2015-fstype=nfs:
/home/guest2015用户的家目录啊
serviceautofsrestart
su-guest2015测试
这一题出现了问题;一定要检测下啊;
十四把/home扩展成2G
[root@station15~]#vgdisplay查看卷组大大小,还能直接扩吗?
[root@station15~]#lvextend-L2048M/dev/vol0/home
[root@station15~]#resize2fs/dev/vol0/home2048M
[root@station15~]#df-h
把/home减小成1G
[root@station15~]#umount/home
[root@station15~]#e2fsck-f/dev/vol0/home
[root@station15~]#resize2fs/dev/vol0/home1024M
[root@station15~]#lvreduce-L1024M/dev/vol0/home
[root@station15~]#mount/home
[root@station15~]#df-h
十五设置一个别名date=”date+%F”,要求,kevin这个用户每次登录系统都要能用这个别名
答案:
[root@station15~]#su-kevin
[kevin@station15~]$vim/home/kevin/.bashrc编辑此文件
[kevin@station15~]$date测试周五
FriJan2222:
24:
53CST2010
十六搭建时钟服务客户端,指定上级服务器是192.168.0.054
答案:
首先一定要将时间NTP给重启了
[root@station15~]#chkconfigntpdon
[root@station15~]#servicentpdrestart
Shuttingdownntpd:
[OK]
ntpd:
Synchronizingwithtimeserver:
[OK]
Startingntpd:
[OK]
[root@station15~]#system-config-date
或者编辑vim/etc/ntp.conf
然后重启servicentpdrestart
最后测试[root@station15~]#ntpq-p
十七用两种方法,去打开kernel的转发功能
答案:
[root@station15~]#vim/etc/sysctl.conf
net.ipv4.ip_forward=1
[root@station15~]#sysctl-p查看
net.ipv4.ip_forward=1
或者是
echo"1">>/proc/sys/net/ipv4/ip_forward
[root@station15~]#sysctl-p
[root@station15~]#servicenetworkrestart
Shuttingdowninterfaceeth0:
[OK]
Shuttingdownloopbackinterface:
[OK]
DisablingIPv4packetforwarding:
net.ipv4.ip_forward=0
[OK]
Bringinguploopbackinterface:
[OK]
Bringingupinterfaceeth0:
[OK]
重启时显示这种情况几说明是正确的
十八设置selinux的模式为enforcing
system-config-selinux或者vim/etc/selinux/config
reboot
RHCE部分
一搭建FTP服务,要求,student1和student2登录ftp后,只能在自己的家目录下,student3不能登录ftp,不允许从192.168.0.0/24以外的其它地方登录
答案:
首先更改YUm,配置YUM库,如果还不可以,就改以下文件
vim/usr/lib/python2.4/site-packages/yum/yumRepo.py
remote="relative
将URl改为这个
yuminstallvsftpd
[root@station15~]#chkconfigvsftpdon
[root@station15~]#servicevsftpdrestart
[root@station15~]#getsebool-a|grepftp 查看布尔值
allow_ftpd_anon_write-->off
allow_ftpd_full_access-->off
allow_ftpd_use_cifs-->off
allow_ftpd_use_nfs-->off
ftp_home_dir-->off
ftpd_disable_trans-->off
ftpd_is_daemon-->on
httpd_enable_ftp_server-->off
tftpd_disable_trans-->off
[root@station15~]#setsebool-Pftp_home_diron 开启家目录
[root@station15~]#vim/etc/vsftpd/vsftpd.conf
这两句的意思是,将用户固定在自己的根目录下,而不能切到系统的其他目录下
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
[root@station15~]#vim/etc/vsftpd/chroot_list ;列出登陆的用户
[root@station15~]#vim/etc/vsftpd/ftpusers
添加student3
就是说,在ftpusers文件里的用户无法登陆ftp
别忘了给家目录一定的权限哦,呵呵
是的,就是说,那些用户登陆时,将登陆用户固定在自己的家目录下
[root@station15~]#iptables-AINPUT-s!
192.168.0.254/24-ptcp--dport21-jREJECT
[root@station15~]#iptables-AINPUT-s!
192.168.0.254/24-pudp--dport21-jREJECT
[root@station15~]#serviceiptablessave
Savingfirewallrulesto/etc/sysconfig/iptables:
[OK]
[root@station15~]#serviceiptablesrestart
[root@station15~]#su-student3 测试
[student3@station15~]$lftp192.168.0.254
二配置samba服务,共享出/home/sharefile目录,要求只有192.168.0.0/24和192.168.1.0/24和127.0.0.1可以访问,共享出的名字是[sharefile],用户不能查看到,只有student组才有写的权限,同时,要把student组里的每个用户的家目录也要共享出来,同时设置Netbiosname=GUEST200X
答案:
首先安装samba
yuminstallsamba
chkconfigsmbon
servicesmbrestart
然后设置目录的情况:
mkdir/home/sharefile
ll-d/home/sharefile/
drwxr-xr-x2rootroot1024Jan2310:
55/home/sharefile/
getsebool-a|grepsamba
setsebool-Psamba_enable_home_dirson要把student组里的每个用户的家目录也要共享出来
chcon-tsamba_share_t/home/sharefile/是更改上下文,是其能通过SELINUX
ll-Zd/home/sharefile/
drwxrwxrwxrootrootroot:
object_r:
samba_share_t/home/sharefile/
vim/etc/samba/smb.conf
netbiosname=GUEST2015
[sharefile]
hostsallow=192.168.0.192.168.1.127.设置允许的网段
path=/home/sharefile设置共享路径
browseable=no使用户不可见
writable=yes
writelist=@student使只有student组才有写的权限
servicesmbrestart
然后加入用户
smbpasswd-aerien将student组里的用户加为smb用户
最后测试;
[root@station15~]#testparm/etc/samba/smb.confstation15.example