《 rh124-exam》linux练习

考试信息:

IPADDR: 172.25.x.100(X 在这里指您的工作站编号)

NETMASK: 255.255.255.0

GATEWAY: 172.25.x.254

DNS: 172.25.254.254

yum源地址为:ftp://172.25.x.250/pub/rhel7.0



1.在进行考试之前,请先重置根用户密码为 examwestos

[root@localhost ~]# passwd

Changing password for user root.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.


wKiom1gaxNnDQUDoAAB3jRun0wc557.jpg



2.更改主机名称为 station.domainX.example.com(X 在这里指您的工作站编号)

[root@localhost ~]# hostnamectl set-hostname station.domain19.example.com

[root@localhost ~]# hostname

station.domain19.example.com

wKiom1gaxNmzpwfFAACcBVD35-Y074.jpg


3新建组,名称为 sysadms,指定其 GID 为 600

[root@localhost ~]# groupadd -g 600 sysadms

wKioL1gaxNrjGYavAABUh1n_JDE006.jpg


4新建用户 tommy,指定 UID 为 2013,配置该用户密码为 redhat

[root@localhost ~]# useradd -u 2013 tommy

[root@localhost ~]# id tommy

uid=2013(tommy) gid=2013(tommy) groups=2013(tommy)

[root@localhost ~]# passwd tommy

Changing password for user tommy.

New password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

[root@localhost ~]#

wKioL1gaxNrCGxVzAADJ4sP2JMw281.jpg


5新建用户 Jimmy,,并且禁止该用户交互式登录,配置该用户密码为 redhat

[root@localhost ~]# cat /etc/shells            ##通过该命令可以查看该系统可支持的shell类型

/bin/sh

/bin/bash

/sbin/nologin

/usr/bin/sh

/usr/bin/bash

/usr/sbin/nologin

/bin/tcsh

/bin/csh

[root@localhost ~]# useradd -s /sbin/nologin Jimmy

[root@localhost ~]# passwd Jimmy

Changing password for user Jimmy.

New password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

wKioL1gaxNmRISiUAADZ7ECBvQ0135.jpg


6新建用户 natasha,harry, 并将这两个用户加入到 sysadms 组当中,作为从属组,如果需要,则将用户密码配置为 redhat

[root@localhost ~]# useradd -g sysadms natasha

[root@localhost ~]# useradd -g sysadms harry

[root@localhost ~]# passwd natasha

Changing password for user natasha.

New password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

[root@localhost ~]# passwd harry

Changing password for user harry.

New password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

wKiom1gaxNvziq6EAAD7iUo3e40500.jpg



7在/home 目录中创建目录 materials,配置该目录的所属组为 sysadms,要求隶属于 sysadms 组当中的成员对该目录有读写权限,在

sysadms目录当中创建的文件或者文件夹,其所属组也

自动继承 sysadms 的所属组

[root@localhost ~]# mkdir /home/materials

[root@localhost ~]# chgrp sysadms /home/materials -R

[root@localhost ~]# chmod g+rw /home/materials

[root@localhost ~]# chmod g+s /home/materials

wKiom1gaxNuQDkMMAACBUA3QKkY750.jpg


8拷贝/etc/fstab 文件到/var/tmp 目录中,设置以下需求

[root@station ~]# cp /etc/fstab /var/tmp/

使 harry 用户对该文件无任何权限

[root@station ~]# setfacl -m u:harry: /var/tmp/fstab

setfacl: Option -m incomplete

使 natasha 对该文件有完全控制权限

[root@station ~]# setfacl -m u:natasha:rwx /var/tmp/fstab

配置文件所属用户为 root

[root@station ~]# chown root /var/tmp/fstab

配置文件所属组为 root

[root@station ~]# chgrp root /var/tmp/fstab

其他所有用户对文件拥有读权限

[root@station ~]# chmod o+r /var/tmp/fstab

其他所有用户对文件没有执行权限

[root@station ~]# chmod o-x /var/tmp/fstab



9设置 NTP 客户端,与172.25.x.254进行时间同步

[root@station ~]# vim /etc/chrony.conf

   3 server 172.25.19.254 iburst

[root@station ~]# systemctl restart chronyd.service

        ##客户端不用关闭防火墙,服务端必须要关防火墙

wKioL1gaxNvDBYsbAAD2v86Xi88878.jpg


10找出用户组mail 拥有的文件,并且将它们放到/root/findresults 目录中

[root@station ~]# find / -group mail -exec mv {} /root/findresults \;

find: ‘/proc/2818/task/2818/fd/6’: No such file or directory

find: ‘/proc/2818/task/2818/fdinfo/6’: No such file or directory

find: ‘/proc/2818/fd/6’: No such file or directory

find: ‘/proc/2818/fdinfo/6’: No such file or directory

mv: ‘/root/findresults/mail’ and ‘/root/findresults/mail’ are the same file

[root@station ~]# cd /root/findresults/

[root@station findresults]# ls

mail

wKioL1gcupPTkbGJAAI1C0p52Sk095.jpg

wKioL1gcuqDj5m--AABVgYMin9g375.jpgwKioL1gcupniUdyTAAIt_E8FMTQ091.jpg

wKiom1gcup_RAOXkAAI-5LNgGiM715.jpg



11在文件/usr/share/mime/packages/freedesktop.org.xml 中查找所有包含 ich 的行,将找

出的行按照先后顺序拷贝到/root/lines

文件中,/root/lines 文件不包含空格,并且其中行的内容是源文件/usr/share/mime/packages/freedesktop.org.xml 原始行的

准确副本

[root@station ~]# grep ich /usr/share/mime/packages/freedesktop.org.xml >/root/lines

[root@station ~]# vim /root/lines

:%s/^\ //g          ##清空每行最前的空格

:wq                 ##保存退出

wKiom1gcuqLy4xrRAADpo0H6Hvk065.jpg

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章