RedHat Exercises
RedHat Exercises
IP Address Setup . . . . . . . . . . . . . . . . . . . . . . . . . 5
Configure NTP . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Configure autofs . . . . . . . . . . . . . . . . . . . . . . . . . 20
Search files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Search a String . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Create a backup . . . . . . . . . . . . . . . . . . . . . . . . . 26
1 rd.break enforcing=0
Connect to your server at the console (don’t reboot now!) with the
root user and the new password:
Then type:
1 restorecon /etc/shadow
2 reboot
1 setenforce enforcing
For the RHCSA exam, you need to intensely practice this procedure.
Note: When dealing with boot problems, the following options
can be added to the kernel command line, bringing additional
information:
1 IP: 192.168.4.13
2 Netmask: 255.255.255.0
3 Gateway: 192.168.4.2
4 DNS: 192.168.4.12
Solutions
Login to the server1 and modify the host name:
Update networks:
1 e2fsck -f /dev/vg0/vo
2 umount /home
3 resize2fs /dev/vg0/vo // the final required partition cap\
4 acity is 100M
5 lvreduce -l 100M /dev/vg0/vo
6 mount /dev/vg0/vo /home
7 df -hT
Notes:
This diagram gives a overview of the main elements in an LVM
system:
Example scenario
Lets suppose we have a volume group called VG1, this volume
group has a physical extent size of 4MB. Into this volume group
we introduce 2 hard disk partitions, /dev/hda1 and /dev/hdb1.
These partitions will become physical volumes PV1 and PV2 (more
meaningful names can be given at the administrators discretion).
The PV’s are divided up into 4MB chunks, since this is the extent
size for the volume group. The disks are different sizes and we get 99
extents in PV1 and 248 extents in PV2. We now can create ourselves
a logical volume, this can be any size between 1 and 347 (248 + 99)
extents.
Create User Account
Create the following user, group and group membership: Admi-
nuser group User natasha, using adminuser as a sub group User
Harry, also using adminuser as a sub group User sarah, can not
access the SHELL which is interactive in the system, and is not a
member of adminuser, natasha�harry�sarah password is redhat.
Solutions:
1 groupadd adminuser
2 useradd natasha -G adminuser
3 useradd haryy -G adminuser
4 useradd sarah -s /sbin/nologin
5
6 Passwd user name // to modify password or echo redhat | p\
7 asswd --stdin user name id natasha //
8 to view user group.
Configure /var/tmp/fstab
Permission
Copy the file /etc/fstab to /var/tmp/fstab. Configure var/tmp/fstab
permissions as the following: Owner of the file /var/tmp/fstab is
Root, belongs to group root File /var/tmp/fstab cannot be executed
by any user User natasha can read and write /var/tmp/fstab User
harry cannot read and write /var/tmp/fstab All other users (present
and future) can read var/tmp/fstab.
Solutions:
1 cp /etc/fstab /var/tmp/
2 ll /var/tmp/fstab view the owner
3 setfacl -m u:natasha:rw- /var/tmp/fstab
4 setfacl -m u:haryy:--- /var/tmp/fstab
1 crontab -e -u natasha
2 23 14 * * * /bin/echo hiya
3 crontab -l -u natasha // View
4 Systemctl enable crond
5 Systemcdl restart crond
Create a Shared
Directory
Create a shared directory /home/admins, make it has the following
characteristics: /home/admins belongs to group adminuser This
directory can be read and written by members of group adminuser
Any files created in /home/ admin, group automatically set as
adminuser.
Solutions:
1 mkdir /home/admins
2 chgrp -R adminuser /home/admins
3 chmod g+w /home/admins
4 chmod g+s /home/admins
Install the Kernel
Upgrade
Istall suitable kernel updation from: http://server.domain11.example.com/pub/update
Following requirements must be met: Updated kernel used as the
default kernel of system start-up. The original kernel is still valid
and can be guided when system starts up.
Soultion:
Using the browser open the URL in the question, download kernel
file to root or home directory.
¹http://server.domain11.example.com/pub/updates.
²http://content.example.com/rhel7.0/x86-64/errata
Install the Kernel Upgrade 17
Modify
grub2-set-default “kernel full name”
Add:
server classroom.example.com iburst
Start:
systemctl enable chronyd systemctl restart chronyd
Validate:
timedatectl status
Configure autofs
Configure the autofs automatically mount to the home directory of
LDAP, as required: server.domain11.example.com use NFS to share
the home to your system. This file system contains a pre configured
home directory of user ldapuserX. Home directory of ldapuserX is:
server.domain11.example.com /home/guests/ldapuser Home di-
rectory of ldapuserX should automatically mount to the ldapuserX
of the local /home/guests Home directory’s write permissions must
be availabe for users ldapuser1’s password is password
Solutions:
1 cp /etc/auto.misc /etc/auto.ldap
2 vi /etc/auto.ldap
3 ldapuserX -fstype=nfs,rw
4 server.domain11.example.com:/home/guests/
1 mkdir /root/findfiles
2 find / - user jack -exec cp -a {} /root/findfiles/ \;
3 ls /root/findresults
Search a String
Find out all the columns that contains the string seismic within
/usr/share/dict/words, then copy all these columns to /root/lines.tx
in original order, there is no blank line, all columns must be the
accurtae copy of the original columns.
Solutions:
1 cd /usr/local
2 tar -jcvf /root/backup.tar.bz2 *
3 mkdir /test
4 tar -jxvf /root/backup.tar.bz2 -C /test/ // Decompression\
5 to check the content is
6 the same as the /usr/loca after