码迷,mamicode.com
首页 > 其他好文 > 详细

RH124 考试真题讲解(小部分、不全)

时间:2017-06-11 23:29:27      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:linux

考试时间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


所有配置要求系统重启后仍然生效


[root@server0 Desktop]# hostnamectl set-hostname server0.example.com

[root@server0 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

[root@server0 Desktop]# 


[root@server0 Desktop]# nmcli connection  show   查看网卡信息

NAME  UUID                                  TYPE            DEVICE 

eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0   

[root@server0 Desktop]# nmcli connection  show eth0  查看网卡详细信息


[root@server0 Desktop]# nm-connection-editor 可以用图形

这里用这个命令方式 实现 :

[root@server0 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.

[root@server0 Desktop]# 


[root@server0 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

~    


生效配置 :

[root@server0 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   

[root@server0 Desktop]# nmcli connection  up static 

nConnection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

[root@server0 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  --     

[root@server0 Desktop]# 

                 


[root@server0 Desktop]# nmcli connection  delete "eth0"    删除多余配置

[root@server0 Desktop]# nmcli connection  show

NAME    UUID                                  TYPE            DEVICE 

static  274ff7cb-f44d-4fb8-9b96-9abb92348f33  802-3-ethernet  eth0   

[root@server0 Desktop]# 


第三题:设定YUM软件仓库

配置你的本地默认YUM软件仓库,仓库地址为:http://classromm.example.com/content/rhel7.0/x86_64/dvd


解法:

[root@server0 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

用命令加可以生成配置文件:

[root@server0 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


~                                                                               

~                                                                               

~                                                                               

~                    


验证:[root@server0 Desktop]# yum list

可以看到很多包



第五题:按要求创建用户

按以下要求创建用户和用户组:

新建一个名为adminuser的组,组id是40000

新建一 个名为natasha的用户,并将adminuser作为其附属组

新建一个名为harry的用户,并将adminuser作为其附属组

新建一个名为sarah的用户,其不属于adminuser组,并将其shell设置为不可登陆的shell

natasha harry sarah 三个用户的密码均设置为glegunge


解法:

[root@server0 Desktop]# groupadd -g 40000 adminuser

[root@server0 Desktop]# useradd -G adminuser natasha

[root@server0 Desktop]# useradd -G adminuser harry

[root@server0 Desktop]# useradd -s /sbin/nologin sarah



[root@server0 Desktop]# echo "glegunge" | passwd --stdin natasha

Changing password for user natasha.

passwd: all authentication tokens updated successfully.

[root@server0 Desktop]# echo "glegunge" | passwd --stdin harry

Changing password for user harry.

passwd: all authentication tokens updated successfully.

[root@server0 Desktop]# echo "glegunge" | passwd --stdin sara

passwd: Unknown user name ‘sara‘.





第八题:文件特殊权限的设定

在/home目录下创建名为admins的子目录,并按以下要求设置权限

1、/home/admins的所有组为adminuser

[root@server0 Desktop]# mkdir /home/admins

[root@server0 Desktop]# chgrp adminuser /home/admins


2、该目录对adminuser组的成员可读,可执行可写,但对其他用户没有任何权限,但root不受限

[root@server0 Desktop]# chmod g+w /home/admins

[root@server0 Desktop]# chmod o=- /home/admins

[root@server0 Desktop]# ll -d /home/admins

drwxrwx---. 2 root adminuser 6 Jun 11 20:11 /home/admins

[root@server0 Desktop]# 



3、在/home/admins目录下所创建的文件的所属组自动被设置为adminuser

[root@server0 Desktop]# chmod g+s /home/admins     //s在x之 上

[root@server0 Desktop]# ll -d /home/admins

drwxrws---. 2 root adminuser 6 Jun 11 20:11 /home/admins

[root@server0 Desktop]# 





第九题:升级内核


新内核的RPM包位于http://content.example.com/content/rhel7.0/x86_64/errata/Packages/kernel.3.10.0-123.1.2.el7.x86_64.rpm


系统重启后,默认以新的内核启动系统,原始的内核将继续可用

[root@server0 Desktop]# uname -r

3.10.0-123.el7.x86_64


[root@server0 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

[root@server0 Desktop]# 



第十二题:同步时间

配置您 的系统时间与服务器classroom.example.com同步,要求系统重启后仍然有效


[root@server0 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

[root@server0 Desktop]# timedatectl set-ntp true 

[root@server0 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

[root@server0 Desktop]# systemctl enable  chronyd  开机启动

s[root@server0 Desktop]# systemctl start chronyd  当前也要启动

[root@server0 Desktop]# 



[root@server0 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

[root@server0 Desktop]# 

[root@server0 Desktop]# systemctl restart chronyd

如果没有同步起来,可以重启



手工触发:马上同步

[root@server0 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

[root@server0 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

[root@server0 Desktop]# 



第十三题:打包

请对/etc/sysconfig目录打包并且bzip2压缩,生成的文件保存为/root/sysconfig.tar.bz2

[root@server0 Desktop]# man tar  可以查是哪个参数

[root@server0 Desktop]# tar cjf /root/sysconfig.tar.bz2 /etc/sysconfig/

tar: Removing leading `/‘ from member names

[root@server0 Desktop]# ls -lh /root/sysconfig.tar.bz2  /验证

-rw-r--r--. 1 root root 42K Jun 11 20:59 /root/sysconfig.tar.bz2

[root@server0 Desktop]# 



第十四题:添加用户


创建一个名为alex的用户,并满足以下要求:

用户id为3456

密码为glegunge


[root@server0 Desktop]# useradd -u 3456 alex


[root@server0 Desktop]# echo "glegunge" | passwd --stdin alex

Changing password for user alex.

passwd: all authentication tokens updated successfully.

[root@server0 Desktop]# 


第十六题:查找文件 

 把系统上拥有者为ira1用户的所有文件,并将其拷贝到 /root/findiles1

先看有没有这个目录:

[root@server0 Desktop]# ll /root/findfiles1

ls: cannot access /root/findfiles: No such file or directory

[root@server0 Desktop]# mkdir /root/findfiles1


[root@server0 Desktop]# find / -user ira1 -exec cp {} /root/findfiles1 \;



[root@server0 Desktop]# find / -user ira -exec cp -a {} /root/findfiles \;保留文件的原有属性



[root@server0 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’

[root@server0 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

[root@server0 Desktop]# 




如下,加-a的操作

[root@server0 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’

[root@server0 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

[root@server0 Desktop]# 



第十七题:过滤文件 


把 /usr/share/dict/words文件中所有包含seismic字符串的行找到,并将这些行按照原始文件中的顺序存入/root/wordlist中、/root/list文件不能包含空行。



[root@server0 Desktop]# grep "seismic" /usr/share/dict/words > /root/list


[root@server0 Desktop]# grep "seismic" /usr/share/dict/words > /root/list  注:没有这个路径或文件会自动创建

[root@server0 Desktop]# cat /root/list  





























本文出自 “HCIE_38xx” 博客,谢绝转载!

RH124 考试真题讲解(小部分、不全)

标签:linux

原文地址:http://hciewd.blog.51cto.com/3272922/1934312

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!