You are on page 1of 12

1-set root password as redhat@123 (consol mode)

reboot vm then during boot press esc then point to rescue kernel then press "e"

then put the pointer to word "linux" then press "end key on keyboard" then put space then right
rd.break then press "ctrl+x"

press enter to get into maintinance shell , then write the below

#mount -o remount,rw /sysroot

#chroot /sysroot

#echo redhat@123 | passwd --stdin root

#touch /.autorelabel

#ls -a (to verify the file created with the correct name)

#exit

#exit

after that it takes time to relabel then it will boot to normal kernal (os level) , login with root to verify.

----------------------------------------------------------------------------------------------------------------------------------
2-configure the below (consol mode)

hostname =statio.domain101.example.com

ip address=192.168.29.101

netmask=255.255.255.0

gateway=192.168.29.1

dns server=192.168.29.1

dns-search domain=domain26.example.com

#systemctl enable NetworkManager

#systemctl restart NetworkManager

#ip -a (to get the connection name)

#nmtui (this will run a ui interface to configure the network and hostname)

edit connection -> point on the connection name as listed above -> edit -> go to "IPv4 CONFIGURATION"
then press enter and change it to manual then go to show then press on it

enter the configuration as required then press ok then back to previous screen then point to activate ->
activate it "it will show * mark on the left side of the connection name" then go back then press on "set
system hostname"

then change it as required then ok -> ok

----------------------------------------------------------------------------------------------------------------------------------
3-configure yum repositories on both system and use the following details (from now on check on ssh
service and give permission to root to ssh directly to systems)

#vi /etc/ssh/sshd_config

uncomment the line start with "PermiRootLogin" then change the paramaeter beside from "prohibit-
password" to "yes" then save using wq!

#systemctl enable sshd.service

#systemctl restart sshd.service

#vi /etc/yum.repos.d/local.repo

[BaseOS]

name=BaseOS

baseurl="as in the question"

gpgcheck=0

enable=1

[AppStream]

name=AppStream

baseurl="as in the question"

gpgcheck=0

enable=1

then save it using wq! , you can copy it all and use on the other server to save time as you will be
required to configure on it too

#dnf clean all

#dnf repolist

#dnf info httpd (to check that repo configuration is correct)

----------------------------------------------------------------------------------------------------------------------------------
4-check your system's default tuning profile and set it as per recommended for the system

#dnf install tuned

#systemctl enable tuned

#systemctl restart tuned

#tuned-adm active

#tuned-adm recommend

it will list the recommend tune profile

#tuned-adm off

#tuned-adm profile "recommend tune profile listed above"

#tuned-adm active (to verify the active profile)

----------------------------------------------------------------------------------------------------------------------------------

5-create group named "sysadmin" with group id 10001 ,

creaate user alex belongs to sysadmin as a secondry group also create another user alice who also
belongs to sysadmin

create another user "robin" who does not have interactive shell on the system , and who is not
member of sysadmin

all users should have the password set as redhat@123

#groupadd -g 10001 sysadmin

#useradd -G sysadmin alex

#useradd -G sysadmin alice

#useradd -s /sbin/nologin robin

#echo redhat@123 | passwd --stdin alex

#echo redhat@123 | passwd --stdin alice

#echo redhat@123 | passwd --stdin robin

----------------------------------------------------------------------------------------------------------------------------------

6-create user called sarah with UID 6001 and password redhat@123

#useradd -u 6001 sarah

#echo redhat@123 | passwd --stdin sarah

----------------------------------------------------------------------------------------------------------------------------------
7-create a directory /backup . group ownership of /backup is sysadmin . the directory

should be readable,writeable and accessible to members of sysadmin , but not to any other users ,
files

create in /backup automatically have group ownership set to sysadmin group

also ensure only file owners can delete their own files /backup

#mkdir /backup

#chgrp sysadmin /backup

#chmod 770 /backup

#chmod g+s /backup

#chmod o+t /backup

----------------------------------------------------------------------------------------------------------------------------------

8-locate all files which are owned by user alex and place them into /root/found directory

#mkdire /root/found

#touch /tmp/zimpa (to verify command work or not)

#find / -user alex -exec cp -p {} /root/found \;

#ls /root/found/

----------------------------------------------------------------------------------------------------------------------------------

9-create a compressed archive file called /root/usrlocal.tgz for the directory /usr/local.

ensure file is being compressed through gzip compression utility.

#tar -czf /root/usrlocal.tgz /usr/local

#file usrlocal.tgz

----------------------------------------------------------------------------------------------------------------------------------

10-create an archive file called /root/etc.tar for the directory /etc.

compress the file using bzip2 compression utility.

#tar -cjf /root/etc.tar.bz2 /etc

#file /root/etc.tar.bz2

----------------------------------------------------------------------------------------------------------------------------------

11-search all lines from /usr/share/dict/words which are having the word "command" .

copy the lines in the file named /root/command.txt without disturbing the original order display
#grep "command" /user/share/dict/words > /root/command.txt

12-classroom.example.com

is exporting as an NFS share the /rhome directory. The expected mount point for

station.domain101.example.com

is also /rhome. User natasha should have her home directory automatically mounted as
/rhome/natasha under the local system. Configure automounter service in such a way, so that when
user natasha login to the system, her local home directory automatically gets mounted to

classroom.example.com:/rhome/natasha. You can login to the system as user natasha with password
redhat@123.

#dnf install nfs-utils autofs

#vi /etc/auto.master.d/rhome.autofs

/rhome /etc/auto.rhome

wq!

#vi /etc/auto.rhome

natasha -rw,sync classroom.example.com:/rhome/natasha

wq!

#systemctl enable autofs

#systemctl restart autofs

----------------------------------------------------------------------------------------------------------------------------------
13- your orgnization is deploying a new custom web application , the web application is running

on a nonstandard port 82/tcp , one of your junior administrator has already configured

the application on your system , you need to deploy httpd package in the local system

which must run even after reboot and ensure that the application is accessible from the

network by other hosts.

#dnf install httpd

#systemctl enable httpd

#systemctl status httpd.service

#semanage-port -a -t http_port_t -p tcp 82

#systemctl start httpd

#systemctl status httpd.service

#firewall-cmd --permanent --add-port=82/tcp

#firewall-cmd --reload

----------------------------------------------------------------------------------------------------------------------------------

14- user must configure a cron job that runs daily in between 17:00 to 18:00 localtime

for every 5 minutes and execute "echo Hello World"

#su - natasha

#crontab -e

*/5 17-18 * * * echo Hello World

wq!

#systemctl enable crond

#systemctl restart crond

----------------------------------------------------------------------------------------------------------------------------------
15- bash script myscript

to be created under /usr/local/bin

need to search file in /usr and store under /root/filefound with below condition

1. file size should be more that 30k and less that 50k

2. file should have sgid permission

3. directory will be created automatically if not present

#touch /usr/local/bin/myscript

#chmod +x /usr/local/bin/myscript

#vi /usr/local/bin/myscript

(inside the file is below)

#!/bin/bash

mkdir /root/filefound

file -type f -size +30k -size -50k -perm -2000 -exec cp -p {} /root/filefound \;

wq!

----------------------------------------------------------------------------------------------------------------------------------

16- configure your system so that it is a NTP client of 1.in.pool.ntp.org

#vi /etc/chrony.conf

just comment out the line started with pool at the top of the file and under it write the below

server 1.in.pool.ntp.org iburst

wq!

#systemctl enable chronyd

#systemctl restart chronyd

#timedatectl

----------------------------------------------------------------------------------------------------------------------------------
17- create a logical volume called database under the volume group called datastore and should have
15 extents ,

logical extent size should be 32 MiB in the logical volume , format the logical

volume using ext3 file system and mount it under /database.

you need to do this math first "(number of extent + 2) * extent size

and in our situation its : (15+2) * 32 = 544 , but the exact size we want to use is 15*32 = 480

#lsblk (to check the partitions details)

#parted /dev/sdb print (to list partition table)

#gdisk /dev/sdb

press enter

press enter

+544

8e00

#partprobe /dev/sdb

#udevadm settle

#pvcrate /dev/sdb2

#vgcreate -s 32M datastore /dev/sdb2

#lvcreate -n database -l 15 datastore

#mkfs.ext3 dev/datastore/database

#mkdire /database

#vi /etc/fstab

add the below line

/dev/datastore/database /database ext3 defaults 0 0

wq!

#mount -a

#df -h
18- you have a logical volume which is mounted with /image file system , extend /image filesystem by
1 GiB.

#df -h

#lvextend /dev/mapper/vg1-image -L +1G -r

#lvs (to verify)

#df -h (to verify)

----------------------------------------------------------------------------------------------------------------------------------

19-create a swap partition of 700MiB without disturbing the current swap volume , it should be

persistant across reboot

#free -h

#gdisk /dev/sdb

press enter

press enter

+700M

8200

#partprobe /dev/sdb

#udevadm settle

#mkswap /dev/sdb3

#vi /etc/fstab

add the below line

/dev/sdb3 swap swap default 0 0

wq!

#swapoff -a

#swapon -a

#free -h (to verify)

----------------------------------------------------------------------------------------------------------------------------------
20- container part

1. need to download the container file from a link provided and build container image

with name httpd24 (no username and password required)

2. create container named webserver

3. container will run an webserver , default document root of the container need to be

mounted with ~/webserver/html directory , the index.html file kept in the directory

will get published from this container

4. container should got published through port 8080 of the local system

5. container will run as a service named container-webserver and controller by user named alex

# dnf install container-tools

#su - alex

#mkdir container-tools

#cd container-tools/

#wget http://link provided (file name : containerfile)

#podman build -t httpd24 .

#podman images

#mkdir -p ~/webserver/html

#podman create --name webserver -v /home/alex/webserver/html:/var/www/html:Z -p 8080:8080


localhost/httpd24:latest

#podman ps -a

#podman start webserver

#mkdir -p ~/.config/systemd/user

#cd ~/.config/systemd/user

#podman generate systemd -n webserver -f

#systemctl --user deamon-reload

#systemctl --user enable container-webserver.service

#podman stop webserver

#podman ps -a (to verify)


#systemctl --user start container-webserver.service

#loginctl enable-linger

You might also like