EX200 無料問題集「RedHat Red Hat Certified System Administrator - RHCSA」
Copy /etc/fstab to /var/tmp name admin, the user1 could read, write and modify it, while user2 without any permission.
正解:
# cp /etc/fstab /var/tmp/
# chgrp admin /var/tmp/fstab
# setfacl -m u:user1:rwx /var/tmp/fstab
# setfacl -m u:user2:--- /var/tmp/fstab
# ls -l
-rw-rw-r--+ 1 root admin 685 Nov 10 15:29 /var/tmp/fstab
# chgrp admin /var/tmp/fstab
# setfacl -m u:user1:rwx /var/tmp/fstab
# setfacl -m u:user2:--- /var/tmp/fstab
# ls -l
-rw-rw-r--+ 1 root admin 685 Nov 10 15:29 /var/tmp/fstab
Create a backup file named /root/backup.tar.bz2, which contains the contents of /usr/local, bar must use the bzip2 compression.
正解:
cd /usr/local
tar -jcvf /root/backup.tar.bz2*
mkdir /test
tar -jxvf /root/backup.tar.bz2 -C /test/
tar -jcvf /root/backup.tar.bz2*
mkdir /test
tar -jxvf /root/backup.tar.bz2 -C /test/
Create a 2G swap partition which take effect automatically at boot-start, and it should not affect the original swap partition.
正解:
# fdisk /dev/sda
p
(check Partition table)
n
(create new partition: press e to create extended partition, press p to create the main partition, and the extended partition is further divided into logical partitions) Enter
+2G t
8 I
82
W
partx -a /dev/sda
partprobe
mkswap /dev/sda8
Copy UUID
swapon -a
vim /etc/fstab
UUID=XXXXX swap swap defaults 0 0
(swapon -s)
p
(check Partition table)
n
(create new partition: press e to create extended partition, press p to create the main partition, and the extended partition is further divided into logical partitions) Enter
+2G t
8 I
82
W
partx -a /dev/sda
partprobe
mkswap /dev/sda8
Copy UUID
swapon -a
vim /etc/fstab
UUID=XXXXX swap swap defaults 0 0
(swapon -s)
Part 2 (on Node2 Server)
Task 2 [Installing and Updating Software Packages]
Configure your system to use this location as a default repository:
http://utility.domain15.example.com/BaseOS
http://utility.domain15.example.com/AppStream
Also configure your GPG key to use this location
http://utility.domain15.example.com/RPM-GPG-KEY-redhat-release
Task 2 [Installing and Updating Software Packages]
Configure your system to use this location as a default repository:
http://utility.domain15.example.com/BaseOS
http://utility.domain15.example.com/AppStream
Also configure your GPG key to use this location
http://utility.domain15.example.com/RPM-GPG-KEY-redhat-release
正解:
[root@node1 ~]# vim /etc/yum.repos.d/redhat.repo
[BaseOS]
name=BaseOS
baseurl=http://utility.domain15.example.com/BaseOS
enabled=1
gpgcheck=1
gpgkey=http://utility.domain15.example.com/RPM-GPG-KEY-redhat-release
[AppStream]
name=AppStream
baseurl=http://utility.domain15.example.com/AppStream
enabled=1
gpgcheck=1
gpgkey=http://utility.domain15.example.com/RPM-GPG-KEY-redhat-release
[root@node1 ~]# yum clean all
[root@node1 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
[root@node1 ~]# yum list all
[BaseOS]
name=BaseOS
baseurl=http://utility.domain15.example.com/BaseOS
enabled=1
gpgcheck=1
gpgkey=http://utility.domain15.example.com/RPM-GPG-KEY-redhat-release
[AppStream]
name=AppStream
baseurl=http://utility.domain15.example.com/AppStream
enabled=1
gpgcheck=1
gpgkey=http://utility.domain15.example.com/RPM-GPG-KEY-redhat-release
[root@node1 ~]# yum clean all
[root@node1 ~]# yum repolist
repo id repo name
AppStream AppStream
BaseOS BaseOS
[root@node1 ~]# yum list all
Add users: user2, user3.
The Additional group of the two users: user2, user3 is the admin group Password: redhat
The Additional group of the two users: user2, user3 is the admin group Password: redhat
正解:
# useradd -G admin user2
# useradd -G admin user3
# passwd user2
redhat
# passwd user3
redhat
# useradd -G admin user3
# passwd user2
redhat
# passwd user3
redhat
Add an additional swap partition of 754 MB to your system.
The swap partition should automatically mount when your system boots.
Do not remove or otherwise alter any existing swap partitions on your system.
The swap partition should automatically mount when your system boots.
Do not remove or otherwise alter any existing swap partitions on your system.
正解:
fdisk -l
fdisk -cu /dev/vda
p n
e or p select e
default (first): enter
default (last): enter n
default(first): enter
default(first): +754M t (1-5)
l: 82 p
w #reboot
#mkswap /dev/vda5
vim /etc/fstab
/dev/vda5 swap swap defaults 0 0
wq
mount -a
swapon -a
swapon -s
fdisk -cu /dev/vda
p n
e or p select e
default (first): enter
default (last): enter n
default(first): enter
default(first): +754M t (1-5)
l: 82 p
w #reboot
#mkswap /dev/vda5
vim /etc/fstab
/dev/vda5 swap swap defaults 0 0
wq
mount -a
swapon -a
swapon -s
Create a 2G swap partition which take effect automatically at boot-start, and it should not affect the original swap partition.
正解:
# fdisk /dev/sda
p
(check Partition table)
n
(create new partition: press e to create extended partition, press p to create the main partition, and the extended partition is further divided into logical partitions) Enter
+2G
t
l
W
partx -a /dev/sda
partprobe
mkswap /dev/sda8
Copy UUID
swapon -a
vim /etc/fstab
UUID=XXXXX swap swap defaults 0 0
(swapon -s)
p
(check Partition table)
n
(create new partition: press e to create extended partition, press p to create the main partition, and the extended partition is further divided into logical partitions) Enter
+2G
t
l
W
partx -a /dev/sda
partprobe
mkswap /dev/sda8
Copy UUID
swapon -a
vim /etc/fstab
UUID=XXXXX swap swap defaults 0 0
(swapon -s)
Configure autofs
Configure autofs to automatically mount the home directory of a remote user as described below:
- materials.example.com (172.25.254.254) exports /rhome via NFS to your system. This filesystem contains a pre-configured home directory for the user remoteuser1.
- The home directory of remoteuser1 is materials.example.com:/rhome/remoteuser1.
- The home directory of remoteuser1 should be automatically mounted locally at /rhome/remoteuser1.
- The home directory must be writable by the user.
- The password for remoteuser1 is "flectrag".
Configure autofs to automatically mount the home directory of a remote user as described below:
- materials.example.com (172.25.254.254) exports /rhome via NFS to your system. This filesystem contains a pre-configured home directory for the user remoteuser1.
- The home directory of remoteuser1 is materials.example.com:/rhome/remoteuser1.
- The home directory of remoteuser1 should be automatically mounted locally at /rhome/remoteuser1.
- The home directory must be writable by the user.
- The password for remoteuser1 is "flectrag".
正解:
# Preparations (not required for the exam)
# Go back to foundation0, remote into classroom, create the remoteuser1 user and directory.
# This step is necessary to avoid issues with autofs mounting during testing.
[kiosk@foundation0 ~]$ ssh root@classroom 'useradd -u 1010 remoteuser1 && mkdir -p /rhome/remoteuser1 && chown remoteuser1: /rhome/remoteuser1'
# Install nfs-utils and autofs
[root@node1 ~]# yum -y install nfs-utils autofs
[root@node1 ~]# vim /etc/auto.master
/rhome /etc/auto.rhome
[root@node1 ~]# vim /etc/auto.rhome
remoteuser1 -rw materials.example.com:/rhome/remoteuser1
[root@node1 ~]# systemctl enable --now autofs
# Verification
[root@node1 ~]# ll /rhome/
[root@node1 ~]# ssh remoteuser1@localhost
remoteuser1@localhost\'s password: `flectrag`
$ pwd
/rhome/remoteuser1
$ touch my.file
$ mount | grep rhome
...
materials.example.com:/rhome/remoteuser1 on /rhome/remoteuser1 type nfs4 (`rw`,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.100,local_lock=none,addr=172.25.254.254)
# Go back to foundation0, remote into classroom, create the remoteuser1 user and directory.
# This step is necessary to avoid issues with autofs mounting during testing.
[kiosk@foundation0 ~]$ ssh root@classroom 'useradd -u 1010 remoteuser1 && mkdir -p /rhome/remoteuser1 && chown remoteuser1: /rhome/remoteuser1'
# Install nfs-utils and autofs
[root@node1 ~]# yum -y install nfs-utils autofs
[root@node1 ~]# vim /etc/auto.master
/rhome /etc/auto.rhome
[root@node1 ~]# vim /etc/auto.rhome
remoteuser1 -rw materials.example.com:/rhome/remoteuser1
[root@node1 ~]# systemctl enable --now autofs
# Verification
[root@node1 ~]# ll /rhome/
[root@node1 ~]# ssh remoteuser1@localhost
remoteuser1@localhost\'s password: `flectrag`
$ pwd
/rhome/remoteuser1
$ touch my.file
$ mount | grep rhome
...
materials.example.com:/rhome/remoteuser1 on /rhome/remoteuser1 type nfs4 (`rw`,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.100,local_lock=none,addr=172.25.254.254)
Create a swap space, set the size is 600 MB, and make it be mounted automatically after rebooting the system (permanent mount).
正解:
if=/dev/zero of=/swapfile bs=1M count=600 mkswap /swapfile
/etc/fstab:
/swapfile swap swap defaults 0 0 mount -a
/etc/fstab:
/swapfile swap swap defaults 0 0 mount -a
Find the files owned by harry, and copy it to catalog: /opt/dir
正解:
# cd /opt/
# mkdir dir
# find / -user harry -exec cp -rfp {} /opt/dir/ \;
# mkdir dir
# find / -user harry -exec cp -rfp {} /opt/dir/ \;