考試信息:
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.
2.更改主機名稱爲 station.domainX.example.com(X 在這裏指您的工作站編號)
[root@localhost ~]# hostnamectl set-hostname station.domain19.example.com
[root@localhost ~]# hostname
station.domain19.example.com
3新建組,名稱爲 sysadms,指定其 GID 爲 600
[root@localhost ~]# groupadd -g 600 sysadms
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 ~]#
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.
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.
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
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
##客戶端不用關閉防火牆,服務端必須要關防火牆
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
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 ##保存退出