考试时间2.5小时
请首先按以下要求配置考试系统:
HostName server0.example.com
ip add :172.25.0.11
netmask:/24
gateway:172.25.254.254
Name server 172.25.254.254
所有配置要求系统重启后仍然生效
[[email protected] Desktop]# hostnamectl set-hostname server0.example.com
[[email protected] Desktop]# hostnamectl
Static hostname: server0.example.com
Icon name: computer
Chassis: n/a
Machine ID: 946cb0e817ea4adb916183df8c4fc817
Boot ID: cae3a5020190436f9d04a9429790e6c9
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64
[[email protected] Desktop]#
[[email protected] Desktop]# nmcli connection show 查看网卡信息
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
[[email protected] Desktop]# nmcli connection show eth0 查看网卡详细信息
[[email protected] Desktop]# nm-connection-editor 可以用图形
这里用这个命令方式 实现 :
[[email protected] Desktop]# nmcli connection add con-name "static" ifname eth0 autoconnect yes type ethernet ip4 "172.25.0.11/24" gw4 172.25.254.254
Connection ‘static‘ (274ff7cb-f44d-4fb8-9b96-9abb92348f33) successfully added.
[[email protected] Desktop]#
[[email protected] Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-static 可看刚才的配置
TYPE=Ethernet
BOOTPROTO=none
IPADDR0=172.25.0.11
PREFIX0=24
GATEWAY0=172.25.254.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=static
UUID=274ff7cb-f44d-4fb8-9b96-9abb92348f33
DEVICE=eth0
ONBOOT=yes
DNS1=172.25.254.254
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
~
生效配置 :
[[email protected] Desktop]# nmcli connection show
NAME UUID TYPE DEVICE
static 274ff7cb-f44d-4fb8-9b96-9abb92348f33 802-3-ethernet --
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
[[email protected] Desktop]# nmcli connection up static
nConnection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
[[email protected] Desktop]# nmcli connection show
NAME UUID TYPE DEVICE
static 274ff7cb-f44d-4fb8-9b96-9abb92348f33 802-3-ethernet eth0
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet --
[[email protected] Desktop]#
[[email protected] Desktop]# nmcli connection delete "eth0" 删除多余配置
[[email protected] Desktop]# nmcli connection show
NAME UUID TYPE DEVICE
static 274ff7cb-f44d-4fb8-9b96-9abb92348f33 802-3-ethernet eth0
[[email protected] Desktop]#
第三题:设定YUM软件仓库
配置你的本地默认YUM软件仓库,仓库地址为:http://classromm.example.com/content/rhel7.0/x86_64/dvd
解法:
[[email protected] Desktop]# yum-config-manager --add-repo="http://classromm.example.com/content/rhel7.0/x86_64/dvd"
Loaded plugins: langpacks
adding repo from: http://classromm.example.com/content/rhel7.0/x86_64/dvd
[classromm.example.com_content_rhel7.0_x86_64_dvd]
name=added from: http://classromm.example.com/content/rhel7.0/x86_64/dvd
baseurl=http://classromm.example.com/content/rhel7.0/x86_64/dvd
enabled=1
用命令加可以生成配置文件:
[[email protected] Desktop]# vim /etc/yum.repos.d/classromm.example.com_content_rhel7.0_x86_64_dvd.repo
[classromm.example.com_content_rhel7.0_x86_64_dvd]
name=added from: http://classromm.example.com/content/rhel7.0/x86_64/dvd
baseurl=http://classromm.example.com/content/rhel7.0/x86_64/dvd
enabled=1
~
~
~
~
验证:[[email protected] Desktop]# yum list
可以看到很多包
第五题:按要求创建用户
按以下要求创建用户和用户组:
新建一个名为adminuser的组,组id是40000
新建一 个名为natasha的用户,并将adminuser作为其附属组
新建一个名为harry的用户,并将adminuser作为其附属组
新建一个名为sarah的用户,其不属于adminuser组,并将其shell设置为不可登陆的shell
natasha harry sarah 三个用户的密码均设置为glegunge
解法:
[[email protected] Desktop]# groupadd -g 40000 adminuser
[[email protected] Desktop]# useradd -G adminuser natasha
[[email protected] Desktop]# useradd -G adminuser harry
[[email protected] Desktop]# useradd -s /sbin/nologin sarah
[[email protected] Desktop]# echo "glegunge" | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[[email protected] Desktop]# echo "glegunge" | passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[[email protected] Desktop]# echo "glegunge" | passwd --stdin sara
passwd: Unknown user name ‘sara‘.
第八题:文件特殊权限的设定
在/home目录下创建名为admins的子目录,并按以下要求设置权限
1、/home/admins的所有组为adminuser
[[email protected] Desktop]# mkdir /home/admins
[[email protected] Desktop]# chgrp adminuser /home/admins
2、该目录对adminuser组的成员可读,可执行可写,但对其他用户没有任何权限,但root不受限
[[email protected] Desktop]# chmod g+w /home/admins
[[email protected] Desktop]# chmod o=- /home/admins
[[email protected] Desktop]# ll -d /home/admins
drwxrwx---. 2 root adminuser 6 Jun 11 20:11 /home/admins
[[email protected] Desktop]#
3、在/home/admins目录下所创建的文件的所属组自动被设置为adminuser
[[email protected] Desktop]# chmod g+s /home/admins //s在x之 上
[[email protected] Desktop]# ll -d /home/admins
drwxrws---. 2 root adminuser 6 Jun 11 20:11 /home/admins
[[email protected] Desktop]#
第九题:升级内核
新内核的RPM包位于http://content.example.com/content/rhel7.0/x86_64/errata/Packages/kernel.3.10.0-123.1.2.el7.x86_64.rpm
系统重启后,默认以新的内核启动系统,原始的内核将继续可用
[[email protected] Desktop]# uname -r
3.10.0-123.el7.x86_64
[[email protected] Desktop]# rpm -ivh http://content.example.com/rhel7.0/x86_64/errata/Packages/kernel-3.10.0-123.1.2.el7.x86_64.rpm
Retrieving http://content.example.com/rhel7.0/x86_64/errata/Packages/kernel-3.10.0-123.1.2.el7.x86_64.rpm
warning: /var/tmp/rpm-tmp.tNnpMS: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:kernel-3.10.0-123.1.2.el7 ################################# [100%]
^Cmkinitrd failed
warning: %posttrans(kernel-3.10.0-123.1.2.el7.x86_64) scriptlet failed, exit status 1
[[email protected] Desktop]#
第十二题:同步时间
配置您 的系统时间与服务器classroom.example.com同步,要求系统重启后仍然有效
[[email protected] Desktop]# timedatectl
Local time: Sun 2017-06-11 20:36:52 CST
Universal time: Sun 2017-06-11 12:36:52 UTC
RTC time: Sun 2017-06-11 20:36:53
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[[email protected] Desktop]# timedatectl set-ntp true
[[email protected] 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
#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
:wq
[[email protected] Desktop]# systemctl enable chronyd 开机启动
s[[email protected] Desktop]# systemctl start chronyd 当前也要启动
[[email protected] Desktop]#
[[email protected] Desktop]# timedatectl
Local time: Sun 2017-06-11 20:49:43 CST
Universal time: Sun 2017-06-11 12:49:43 UTC
RTC time: Sun 2017-06-11 20:49:43
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[[email protected] Desktop]#
[[email protected] Desktop]# systemctl restart chronyd
如果没有同步起来,可以重启
手工触发:马上同步
[[email protected] Desktop]# chronyc 命令1
chrony version 1.29.1
Copyright (C) 1997-2003, 2007, 2009-2013 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 命令2
try: 1, refid: 172.25.254.254, correction: 0.000000000, skew: 1000000.000
chronyc> quit 命令3
[[email protected] Desktop]# timedatectl 再次验证
Local time: Sun 2017-06-11 20:51:42 CST
Universal time: Sun 2017-06-11 12:51:42 UTC
RTC time: Sun 2017-06-11 12:51:42
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
[[email protected] Desktop]#
第十三题:打包
请对/etc/sysconfig目录打包并且bzip2压缩,生成的文件保存为/root/sysconfig.tar.bz2
[[email protected] Desktop]# man tar 可以查是哪个参数
[[email protected] Desktop]# tar cjf /root/sysconfig.tar.bz2 /etc/sysconfig/
tar: Removing leading `/‘ from member names
[[email protected] Desktop]# ls -lh /root/sysconfig.tar.bz2 /验证
-rw-r--r--. 1 root root 42K Jun 11 20:59 /root/sysconfig.tar.bz2
[[email protected] Desktop]#
第十四题:添加用户
创建一个名为alex的用户,并满足以下要求:
用户id为3456
密码为glegunge
[[email protected] Desktop]# useradd -u 3456 alex
[[email protected] Desktop]# echo "glegunge" | passwd --stdin alex
Changing password for user alex.
passwd: all authentication tokens updated successfully.
[[email protected] Desktop]#
第十六题:查找文件
把系统上拥有者为ira1用户的所有文件,并将其拷贝到 /root/findiles1
先看有没有这个目录:
[[email protected] Desktop]# ll /root/findfiles1
ls: cannot access /root/findfiles: No such file or directory
[[email protected] Desktop]# mkdir /root/findfiles1
[[email protected] Desktop]# find / -user ira1 -exec cp {} /root/findfiles1 \;
[[email protected] Desktop]# find / -user ira -exec cp -a {} /root/findfiles \;保留文件的原有属性
[[email protected] Desktop]# find / -user ira1 -exec cp {} /root/findfiles1 \;(说明,最初找不到,然后用ira1登陆到该设备后创建文件后才找到)
find: ‘/proc/36921/task/36921/fd/6’: No such file or directory
find: ‘/proc/36921/task/36921/fdinfo/6’: No such file or directory
find: ‘/proc/36921/fd/6’: No such file or directory
find: ‘/proc/36921/fdinfo/6’: No such file or directory
cp: omitting directory ‘/home/ira1’
cp: omitting directory ‘/home/ira1/.mozilla’
cp: omitting directory ‘/home/ira1/.mozilla/extensions’
cp: omitting directory ‘/home/ira1/.mozilla/plugins’
cp: omitting directory ‘/home/ira1/.config’
cp: omitting directory ‘/home/ira1/.config/abrt’
cp: omitting directory ‘/home/ira1/.cache’
cp: omitting directory ‘/home/ira1/.cache/abrt’
cp: omitting directory ‘/home/ira1/123’
cp: omitting directory ‘/home/ira1/123.txt’
[[email protected] Desktop]# ll /root/findfiles1
total 12
-rw-r--r--. 1 root root 4 Jun 11 21:19 gnome-initial-setup-done
-rw-r-----. 1 root root 0 Jun 11 21:18 ira1 因为在找到没有加-a参数,所以显示是root的用户和组
-rw-------. 1 root root 11 Jun 11 21:19 lastnotification
-rw-r--r--. 1 root root 1443 Jun 11 21:19 monitors.xml
[[email protected] Desktop]#
如下,加-a的操作
[[email protected] Desktop]# find / -user ira1 -exec cp -a {} /root/findfiles1 \;
find: ‘/proc/37033/task/37033/fd/6’: No such file or directory
find: ‘/proc/37033/task/37033/fdinfo/6’: No such file or directory
find: ‘/proc/37033/fd/6’: No such file or directory
find: ‘/proc/37033/fdinfo/6’: No such file or directory
cp: cannot overwrite non-directory ‘/root/findfiles1/ira1’ with directory ‘/home/ira1’
[[email protected] Desktop]# ll /root/findfiles1
total 12
drwxrwxr-x. 2 ira1 ira1 6 Jun 11 21:17 123
drwxrwxr-x. 2 ira1 ira1 6 Jun 11 21:17 123.txt
drwxrwxr-x. 2 ira1 ira1 29 Jun 11 21:16 abrt
drwxr-xr-x. 2 ira1 ira1 6 Jan 27 2014 extensions
-rw-r--r--. 1 ira1 ira1 4 Jul 11 2014 gnome-initial-setup-done
-rw-rw----. 1 ira1 mail 0 Jun 11 21:14 ira1
-rw-------. 1 ira1 ira1 11 Jun 11 21:16 lastnotification
-rw-r--r--. 1 ira1 ira1 1443 Jul 11 2014 monitors.xml
drwxr-xr-x. 2 ira1 ira1 6 Jan 27 2014 plugins
[[email protected] Desktop]#
第十七题:过滤文件
把 /usr/share/dict/words文件中所有包含seismic字符串的行找到,并将这些行按照原始文件中的顺序存入/root/wordlist中、/root/list文件不能包含空行。
[[email protected] Desktop]# grep "seismic" /usr/share/dict/words > /root/list
[[email protected] Desktop]# grep "seismic" /usr/share/dict/words > /root/list 注:没有这个路径或文件会自动创建
[[email protected] Desktop]# cat /root/list