Difficult RHCSA Flashcards

1
Q

Create a localrepo

A

Add disk with an iso
cd /
mkdir localrepo
df -h (do this to find path)
(the name of your disk will have spaces in it, cd into it and space to find the correct way to put it)
cd /disk….
cd Appstream
cd Packages
ls -ltr | wc -l (just to see how many packages)
du -sh (to see if we have enough storage)
cp -rv * /localrepo, (just grab one or two to save space)
rm -rf /etc/yum.respos.d/*
vim /etc/yum.repos.d/local.repo

[centos7]
name=centos7
baseurl=file:///localrepo/ (this is the directory we created)
enabled=1
gpgcheck=0
:wq

yum install createrepo
createrepo /localrepo/ (creates database for yum command)

yum clean all (clears cache from old repository)

yum repolist all (shows all repos)

REMEMBER:
If you’re running selinux on your reposerver, you need to change the context of the repo!!!!!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

download ksh
Show ksh’s information
Show where configuration files are located

A

rpm -hiv ksh-23512.rpm
rpm -qa | grep ksh
rpm -qi ksh-23512.rpm
rpm -e ksh-23512.rpm
rpm -qa | grep ksh
which ksh
rpm -qf /usr/bin/ksh

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Install screen via yum
rollback screen
(if you have an older version of screen this will just rollback the new one/update that you just installed)

A

Yum history undo 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe dns record names

A

Host to IP - A Record

IP to Hostname - PTR Record

Hostname to Hostname - CNAME Record

Host - to - Host is if you have a bunch of servers and you all want them to have the same alias, since the other servers will technically have different names.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

View all available time zones
Set time zone to Newyork
Set the date
set date and time
Sync time with ntp

A

timedatectl list-timezones

timedatectl set-timezone “America/New_York”

timedatectl set-time 2023-05-12
timedatectl set-time ‘2023-05-12 00:39:00;
timedatectl set-ntp true
timedatectl
check if chronyd or ntpd is running if timedatectl shows it is not synced

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Install and use sendmail

A

yum install sendmail
yum install sendmail-cf
vim /etc/mailsendmail.mc

This is where you would put the FQDN of the mail server:
dnl define(‘SMART_HOST’,`smtp.your.provider’)dnl

(dns means comment)

systemctl restart sendmail

ps -ef | grep sendmail

mail -s “Hello!” joshcahoe@gmail.com
Welcome to fart
^d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Download and configure rsyslog

A

rpm -qa | grep rsyslog

vim /etc/rsyslog.conf
(If you’re sending syslog info to another server change the #*** @@remote-host:514)

systemctl start rsyslog
systemctl enable rsyslog

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Where would you go to access the ssh configuration to change the port?
disable root login

What should you do afterword?

A

/etc/sshd/ssh_conf
PermitRootLogin no

let selinux know
semanage port -a -t ssh_port_t -p tcp 5183

open port on firewall

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Send a keep alive message out every 600 seconds, if there is no response after 1 then close the ssh connection

This just makes sure there is a network connection

A

vim /etc/ssh/sshd_config
ClientAliveInterval 600 (seconds that a keep alive message is sent out)
ClientAliveCountMax 0 (You send one keep alive every 300 seconds and disconnect after 0 answers are missed.)
systemctl restart sshd

This checks if there is still a network connection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Remove empty password connections

A

vim /etc/ssh/sshd_config
remove hash from
PermitEmptyPasswords
systemctl restart sshd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Only allow one user in ssh

A

vim /etc/ssh/sshd_config
AllowUsers josh danny
systemctl restart sshd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Generate SSH-keys
Copy keys to the server
Login to test

A

ssh-keygen

Prompt will comup for where to save your key, this is the path, enter will use default location

Passphase enter

Copy the SHA256 key

ssh-copy-id root@lollipop
enter password for server’s root
(this copys to server’s folder : root/.ssh/authorized_keys)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Install and configure cockpit

A

via server

ping 8.8.8.8 to check network connectivity

yum install cockpit -y

rpm -qa | grep cockpit

systemctl start cockpit
systemctl enable cockpit
systemctl status cockpit

(cockpit is tcp 9090)

firewall-cmd –permanent –add-port=9090/tcp
firewall-cmd –permanent –add-service=cockpit
firewall-cmd –reload

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Where is your DNS server stored?

A

/etc/resolv.conf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Show info about ens33

A

ethtool ens33

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Bond two ports

A

modinfo bonding
if you don’t have it install it - modprobe bonding
In the description it should say if you have it here

Create Bond interface file
vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Bond
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.80
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BONDING_OPTS=”mode=5 miimon=100”

:wq

vim /etc/sysconfig/network=scripts/ifcfg-enp0s3
d10d
TYPE=Ethernet
BOOTPROTO=none
DEVICE=enp0s3
HWADDR=”MAC NUMBER FOR IFCONFIG”
MASTER=bond0
SLAVE=yes

:wq

Do this for the other NIC

BOOTPROTO - NONE/STATIC (FOR THE IP) (BOOT PROTOCOL - WHAT TO DO UPON BOOT)
ONBOOT=yes - ENABLE WHEN SYSTEM BOOTS

cat /proc/net/bonding/bond0

17
Q

What does this mean:
BONDING_OPTS=”mode=5 miimon=100”

A

mode =
0 Round Robin - Packets are sequentially transmitted received through each interface one by one

1 Active Backup - One up and the other comes up if the other goes down

2 XOR (exclusive OR) - MAC is recorded and all traffic coming from it goes down same link

3 Broadcast - Transmitted of all slaves

4 Dynamic Link Aggregation - NICS act as one so you get higher throughput

5 Transmit Load Balance - Based on load of slave.

6 Adaptive Load Balancing - Load Balanced through ARP negotiation

miimon (media independent interface monitoring)- Specifies the MII link monitoring frequency in milliseconds - determines how often the link state of slaves inspected for failure

18
Q

Edit the network via the text editor delete new adapters IP then create bonding/team (team is same thing) (remember this will cut off network connection so you have to do it locally)

A

nmtui
edit connection
Wired connection 1 -> delete this one we added from vmware
remove network connection main (this just deletes IP)
add Team (bond is older version)
Profile name - team1
tab down to slaves and add
Ethernet
Profile name - enp0s3
device enp0s3 (or whatever)
ok
(then add the next one)
change IPv4 to Manual
show
add the address, gateway, etc

19
Q

configure an interface with nmcli

A

nmcli device (shows all devices)

nmclie connection modify enp0s3 ipv4.addressess 10.253.1.211/24

nmclie connection modify enp0s3 ipv4.gateway 192.168.1.1

nmclie connection modify enp0s3 ipv4.method manual

nmclie connection modify enp0s3 ipv4.dns 8.8.8.8

nmcli connection down enp0s3

nmcli connection up enp0s3

nmcli connection show –active

nmcli connection modify enp0s3 +ipv4.addresses 10.253.1.211/24

nmcli connection reload (does the same as up/down)

systemctl reboot

ip address show

nmcli connection show enp0s3

20
Q

Create a bond with nmcli

A

nmcli connection add type bond con-name “Bondconn1” ifname bond0

nmcli connection modify Bondconn1 bond.options “mode=active-backup”

nmcli connection add type ethernet slave-type bond con-name bond0-if1 ifname ens5 master bond0

nmcli connection add type ethernet slave-type bond con-name bond0-if2 ifname ens6 master bond0

sudo nmcli connection delete bond0-if2

cat /proc/net/bonding/bond0

21
Q

Configure VSFTPD

A

cp /etc/vsftpd/vsftpd.conf vsftpd.conf.orig

vim /etc/vsftpd/vsftpd.conf
/anonymous
anonymous_enable=NO
/ascii
uncomment these
ascii_upload_enable=YES
ascii_download_enable=YES
/ftpd
uncomment
ftpd_banner=Welcom to blah FTP service

Go to end of file (shift g)
add
# Local Time
use_localtime=YES

systemctl start vsftpd
systemctl enable vsftpd
systemctl stop firewalld
systemctl disable firewalld

22
Q

Use SCP

A

touch jack
scp jack delsinm@192.168.11.2:/home/deslinm
(delsinm is the name on the SERVER
/home/delsinm is where you want it to go on the SERVER)

enter username and password

file has now been transferred

scp delsinm@remote:/home/delsinm/jack /home/delsinm

capisce?

directories can be sent with scp -r

23
Q

Use Rsync

A

rpm -qa | grep rsync
yum install rsync
tar cvf backup.tar

tar cvf backup.tar .
. <- current directory
mkdir /tmp/backups
rsync -zvh backup.tar /tmp/backups/

rsync -azvh /home/delsinm /tmp/backups/

24
Q

Create a script confirming if the variable number is equal to 100 then print something

A

!/bin/bash

# comment
count=100
if [ $count -eq 100 ]
then
echo “Count is 100”
else
echo “Count is not 100”
fi <- tell script to exit out, opposite of it

25
Q

Command to see options for statements

A

help test

26
Q

Create if then script for if error file exists

A

!/bin/bash

# comment
if [ -e /home/delsinm/error.txt ]
then
echo “file exists”
else
echo “file does not exist”
fi

27
Q

Create script for See jack run play laugh

A

!/bin/bash

# comment
for i in run play laugh
do
echo “See jack $i”
done

28
Q

Create candy script

A

echo
echo “What is your name?”
read name
echo
echo “Hello, $name. What do you like Candy? [y/n]”
read candy
if [ $candy == y -o yes ]
then
echo “I’ll be seeing you later then…”
elif [ $candy == n -o no]
then
echo “Hmm, no fun.”
else
echo “Learn to read”
fi

29
Q

Create the following output using loop and an arithmetic expression:
Weekday 2 : Mon
Weekday 3 : Tue
Weekday 4 : Wed
Weekday 5 : Thu
Weekday 6 : Fri

A

!/bin/bash

i=1
for day in Mon Tue Wed Thu Fri
do
echo “Weekday $((i++)) : $day”
done

30
Q

Create a do-while script that prints
Welcome (number 1-5) and increments up until 5

A

!/bin/bash

c=1
while [ $c -le 5 ] <- while c is less than and equal to 5
do
echo “welcome $c”
(( c++ )) <- allows c to accumulate
done

31
Q

Create a case script

A

!/bin/bash

# comment
echo
echo Please choose one of the options below
echo
echo ‘a = Display Date and Time’
echo ‘b = List users logged in’
echo ‘c = List current user
echo ‘d = Check System uptime’
echo

read choices
case $choices in

a) date;;
b) ls;;
c) who;;
d) uptime;;
*) echo Invalid choice - Bye
esac

;; <- these are like spaces in between

32
Q

Make an automated ping to 192.168.1.1, use a return value and echo responses to whether it was successful or not

A

!/bin/bash

ping -c1 192.168.1.1
if [ $? -eq 0 ] <- if return value is equal to 0
then
echo ok
else
echo not ok
fi

This displays the actual ping and your statement afterword

-c1 <- only ping once
$? < - return value
0 = successful
1 = fail

Let’s say we want to not see the output and only our statement. Just add > /dev/null after

33
Q

If I want to ping servers 192.168.1.1/7/24 how should I create the script?

A

Create a file called myhosts
192.168.1.1
192.168.1.7
192.168.1.24
:wq

vim mass_ping

hosts=”/home/delsinm/myhosts”

for ip in $(cat $hosts)
do

ping -c1 $ip > /dev/null
if [ $? -eq 0 ]
echo $ip is ok
else
echo $ip is not ok
fi

34
Q

create an alias for pwd and ls -la together

A

alias pl=”ls -la; pwd”

35
Q

create an alias for ls -la for everything that starts with “d”

A

alias gl=”ls -la | grep ^d”

^ - everything that starts with d

36
Q

When creating an alias for ls -la | awk ‘{print $1}’ how would you do this

A

alias look=”ls -la | awk ‘{print $1}’”

37
Q

Show aliases
now remove one

A

alias
unalias lap

38
Q

Where do you store your user/global permanent aliases?

A

/etc/bashrc
/home/user/.bashrc