RHCSA复习

RHCSA复习

注:

如classroom.example.com不能访问
首先在本地主机远程172.25.254.254(172.25.0.254)
命令如下:
ssh [email protected]
echo ‘NSSENforceValidCerts off’ >> /etc/httpd/conf.d/nss.conf
systemctl restart httpd

1.破解root密码

启动界面 按e
下翻至最后2行,删除到ro 若有语言代码不用删除,按下ctrl+x键
mount -o remount,rw /sysroot
chroot /sysroot
echo "tangkai" | passwd --stdin root
touch /.autorelabel
exit
exit

2.配置IP地址

vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
IPADDR=172.25.254.10
NETMASK=255.255.255.0
GATEWAY=172.25.254.254
DNS1=172.25.254.250
保存并退出
systemctl restart network

【此时在本地主机上开一个终端远程连接】
ssh [email protected]

3.更改主机名

[root@localhost ~]# vim /etc/hostname
[root@localhost ~]# cat /etc/hostname 
station.domain12.example.com
[root@localhost ~]# bash
[root@station ~]# 

4.配置yum源

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel_dvd.repo
[root@localhost yum.repos.d]# rm -rf rhel_dvd.repo 
[root@localhost yum.repos.d]# vim zhou.repo
[root@localhost yum.repos.d]# cat zhou.repo
[zhou]
name=zhou
baseurl=http://classroom.example.com/content/rhel7.0/x86_64/dvd/
enabled=1
gpgcheck=0
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum install vsftpd -y

此时安装报错,可能是classroom.example.com访问不了,请看最下面介绍的注意

5.配置selinux

[root@station ~]# vim /etc/selinux/config
SELINUX=enforcing(将disabled修改为enforcing)

6.配置系统磁盘及打包操作

lsblk
fdisk /dev/vdb
p-n-p-回车-回车-+500M-p-w
partprobe /dev/vdb
lsblk
mkfs.xfs /dev/vdb1
mkdir /common
blkid
复制/dev/vdb1的UUID
vim /etc/fstab
UUID="2204b223-5803-4136-b09b-59903527dc77" /common xfs defaults 0 0 
保存并退出
mount -a
df -Th

mkdir /common/adm
cd /common
useradd admin
chown .admin adm
ls -l
setfacl -m g:admin:rwx adm
setfacl -m o::--- adm
ls -l

tar cjf backup_local.tar.bz2 /usr/local
ls

7.内核设置

wget http://classroom.example.com/content/rhel7.3/x86_64/dvd/Packages/kernel-3.10.0-514.el7.x86_64.rpm
rpm -ivh kernel-3.10.0-514.el7.x86_64.rpm
wget http://classroom.example.com/content/rhel7.3/x86_64/dvd/Packages/dracut-033-463.el7.x86_64.rpm
wget http://classroom.example.com/content/rhel7.3/x86_64/dvd/Packages/linux-firmware-20160830-49.git7534e19.el7.noarch.rpm
wget http://classroom.example.com/content/rhel7.3/x86_64/dvd/Packages/xfsprogs-4.5.0-8.el7.x86_64.rpm
wget http://classroom.example.com/content/rhel7.3/x86_64/dvd/Packages/kmod-20-9.el7.x86_64.rpm
rpm -Uvh kmod-20-9.el7.x86_64.rpm
rpm -Uvh linux-firmware-20160830-49.git7534e19.el7.noarch.rpm 
rpm -Uvh xfsprogs-4.5.0-8.el7.x86_64.rpm 
rpm -Uvh dracut-033-463.el7.x86_64.rpm --nodeps
rpm -ivh kernel-3.10.0-514.el7.x86_64.rpm
【此时中途会卡一会,不必惊慌,等待出来提示符】
reboot
等待2分钟再次ssh [email protected]
uname -r
3.10.0-514.el7.x86_64
【此时表示内核升级成功】

8.开启IP转发功能

vim /etc/sysctl.conf
复制 /usr/lib/sysctl.d/00-system.conf
退出
vim /usr/lib/sysctl.d/00-system.conf
加入 net.ipv4.ip_forward = 1
保存并退出
sysctl -p /usr/lib/sysctl.d/00-system.conf
【当有出现net.ipv4.ip_forward = 1表示IP转发成功】

9.计划任务

useradd natasha
crontab -u natasha -e
23 14 * * * /usr/bin/echo "I AM RHCE"
保存并退出
vim /etc/cron.allow
root
natasha
保存并退出

10.创建用户

useradd tangkai -c "BOSS" -u 9999 -G root -d /tangkai
tail -n 1 /etc/passwd

11.创建用户和组

usermod -a -G admin natasha
id natasha
useradd -G admin harry
id harry
useradd -s /sbin/nologin sarah
id sarah
echo "tangkai" | passwd --stdin natasha
echo "tangkai" | passwd --stdin harry
echo "tangkai" | passwd --stdin sarah
chage -M 30 -W 5 natasha
chage -l natasha

12.权限设置

cp /etc/fstab /var/tmp
cd /var/tmp
ls -l
setfacl -m u:natasha:rw- fstab
setfacl -m u:harry:--- fstab
setfacl -m o::r-- fstab
ls -l

13.远程登陆

1)用LDAP验证:
cd /etc/openldap/
mkdir cacerts
cd cacerts/
wget http://classroom.example.com/pub/example-ca.crt
yum install authconfig* sssd* krb5* -y
authconfig-tui
【此处勾选以下四个:】
【Use LDAP】
【Use Shadow Passwords】
【Use LDAP Authentication】
【Local authorization is sufficient】
然后下一步
 [*] Use TLS
Server: classroom.example.com
Base DN: dc=example,dc=com
然后ok
su - ldapuser12
出现bash-4.2$为正确

2)用kerbros验证
authconfig-tui
【此处勾选以下四个:】
【Use LDAP】
【Use Shadow Passwords】
【Use Kerberos】
【Local authorization is sufficient】
然后下一步
 [*] Use TLS
Server: classroom.example.com
Base DN: dc=example,dc=com
然后下一步
Realm: EXAMPLE.COM
KDC: classroom.example.com 
Admin Server: classroom.example.com 
[ ] Use DNS to resolve hosts to realms
[ ] Use DNS to locate KDCs for realms  
然后OK
su - ldapuser12
出现bash-4.2$为正确

14.NTP客户端连接

vim /etc/chrony.conf

#server 0.rhel.pool.ntp.org iburst
#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

保存并退出

systemctl restart chronyd
systemctl enable chronyd

15.LDAP客户端自动挂载

yum install autofs.x86_64 -y
cd /etc
ll auto.【此处tab两下】
vim auto.master
在/misc   /etc/auto.misc下添加
/home/guests /etc/auto.ldap
保存并退出
cp auto.misc auto.ldap
vim auto.ldap
ldapuser12  -rw  classroom.example.com:/home/guests/ldapuser12
保存并退出
systemctl restart autofs
systemctl enable autofs
su - ldapuser12
【出现完整的登陆提示符表示登陆完成】
[ldapuser12@station ~]$

16.查找文件

find / -user tangkai -exec cp -rf {} /root/findfile/ \;

cat /usr/share/dict/words | grep "atens" > /root/lines.txt

17.文件系统管理

lsblk
fdisk /dev/vdb
n-e-回车-回车-回车-n-l-回车-+500M-p-w
fdisk /dev/vdb
p-回车-82-w
partprobe /dev/vdb
mkswap /dev/vdb5
blkid
复制/dev/vdb5的UUID
vim /etc/fstab
UUID="1fdd485e-faf5-4635-a61c-d9e0aef78702" swap swap defaults 0 0
保存并退出
swapon /dev/vdb5
free -m
【swap中total出现499表示成功】

18.LVM拉大/减小

此题先存放至最后倒数第二题时候再做

df -Th  这里会有一个vo
环境中没有所以我们先创建一个vo
lsblk
fdisk /dev/vdb
p-n-l-回车-+400M-p-t-回车-8e-w
partprobe /dev/vdb
lsblk
vgcreate vg0 /dev/vdb6
lvcreate -L 200M -n vo vg0
lvdisplay
lsblk
mkfs.ext4 /dev/vg0/vo
blkid
复制/dev/loop0的UUID
vim /etc/fstab
UUID="c5e1fe56-4745-4e34-ae69-715e008b3bfe" /vo ext4 defaults 0 0
mkdir /vo
mount -a
lsblk
df -Th
【此时就有一个vo了】
【以上考试时候是已经有了,只需做以下步骤】
lvextend -L 312M /dev/vg0/vo
resize2fs /dev/vg0/vo
df -Th
【此时可以看到299M,表示成功】

19.ACL控制及权限委派

useradd admin1
useradd admin2
useradd admin3
echo "tangkai" | passwd --stdin admin1
echo "tangkai" | passwd --stdin admin2
echo "tangkai" | passwd --stdin admin3
useradd user2 -s /sbin/nologin
echo "tangkai" | passwd --stdin user2
mkdir /data
setfacl -m u:admin1:rwx /data
setfacl -m u:admin2:r-x /data
setfacl -m u:admin3:--- /data
chown .admin1 /data
chmod g+s /data
mkdir /storage
chmod 777 /storage/
chmod o+t /storage/
visudo
找到root    ALL=(ALL)       ALL 在下面一行写上:
admin1   ALL=(ALL)       /usr/sbin/useradd,/usr/sbin/userdel,/usr/sbin/usermod
保存并退出

20.日志管理

vim /etc/rsyslog.conf
找到mail.*
将后面的-/var/log/maillog替换成classroom.example.com
systemctl restart rsyslog.service 
systemctl enable rsyslog.service 
systemctl stop rsyslog.service 

21.LVM配置

此题先存放至最后一题时候再做

1)
lsblk 
fdisk /dev/vdb
p-n-l-回车-+816M-t-回车-8e-w
partprobe
lsblk
pvcreate /dev/vdb7
vgcreate -s 16M -p 50 datastore /dev/vdb7
vgdisplay

lvcreate -L 800M -n database datastore
lvs
mkdir /mnt/wshare
mkfs.vfat /dev/datastore/database
blkid
复制/dev/mapper/datastore-database的UUID
vim/etc/fstab
UUID="2E55-7C3E" /mnt/wshare vfat defaults 0 0
保存并退出
mount -a
df -Th

2)
lsblk
fdisk /dev/vdb
p-n-l-回车-+168M-p-t-回车-8e-w
partprobe
pvcreate /dev/vdb8
vgcreate -s 8M -p 20 vg1 /dev/vdb8
vgdisplay

lvcreate -L 160 -n game vg1
lvdisplay
mkfs.ext4 /dev/vg1/game
ll /storage
复制/dev/mapper/vg1-game的UUID
vim/etc/fstab
UUID="b1f45d75-53b2-4691-8198-841f14719e31" /storage ext4 defaults 0 0
保存并退出
mount -a
df -Th

3)
lsblk
fdisk /dev/vdb
p-n-l-回车-+746M-p-t-回车-8e-w
partprobe
pvcreate /dev/vdb9
vgextend vg1 /dev/vdb9
vgdisplay
lvextend -L 746M /dev/vg1/game 
resize2fs /dev/vg1/game
lvdisplay 


4)
umount /dev/vg1/game
e2fsck -f /dev/vg1/game
resize2fs /dev/vg1/game 160M
lvreduce -L 160M /dev/vg1/game
y
df -Th
e2fsck /dev/vg1/game
mount -a
df -Th

22.过滤操作

yum install vsftpd.x86_64 -y
cp /etc/vsftpd/vsftpd.conf /root
cat vsftpd.conf | grep -v ^# | grep -v ^$ | grep "YES"$ > /root/ftp.txt

23.挂载操作

cd /root
wget http://classroom.example.com/content/boot/rhci-foundation-7.3-5.r46146.iso
mv  rhci-foundation-7.3-5.r46146.iso boot.iso
vim /etc/fstab
将:
/root/boot.iso    /media/cdrom     iso9660 defaults,loop 0 0
添加至最后一行
保存并退出
mount -a

24.计划任务

crontab -e
*/10 14-17 1-5 * * /usr/bin/echo "I Love RHCE"
保存并退出
cat /etc/cron.allow
systemctl restart crond
systemctl enable crond

25.防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
iptables -nvL
iptables -F
service iptables save

注:

如classroom.example.com不能访问
首先在本地主机远程172.25.254.254(172.25.0.254)
命令如下:
ssh [email protected]
echo ‘NSSENforceValidCerts off’ >> /etc/httpd/conf.d/nss.conf
systemctl restart httpd

你可能感兴趣的:(linux,Linux)