Main Points Flashcards

(34 cards)

1
Q

Explain setuid, setgid, and stickybits

A

THESE BITS ONLY WORK ON C EXECUTABLE AND NOT SHELL SCRIPTS

setuid - the root user made the process/application but anyone that attempts to run it will run it as root, or whatever user initially made it

setgid -The setgid affects both files as well as directories. When used on a file, it executes with the privileges of the group of the user who owns it instead of executing with those of the group of the user who executed it.
When the bit is set for a directory, the set of files in that directory will have the same group as the group of the parent directory, and not that of the user who created those files. This is used for file sharing since they can be now modified by all the users who are part of the group of the parent directory.
Finally, the sticky bit makes it to where only the user that created the file/directory can delete it. This must be placed on the directory and not the file!

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

1) Become root user

2) Create a directory called Animals

3) Create Animals group add users to Animals group then make the Animals directory group Animals.

At this point, your users should be able to enter the directory if the group has execute capabilities.

4) You want group members to create files that they can all access since normally if a group member creates a file it will just be in their personal group. Change this to where it will be accessible for all users and make it’s group always Animals

5) You don’t want to let the other members be able to delete files one another has created aside from the owner who created initially, make it so.

6) Create an executable file as root that allows all users to use as root. (ONLY WORKS ON C NOT SHELL SCRIPTS)

7) Lastly, remove all of your special bits

A

su
mkdir Animals
groupadd Animals
usermod -aG Animals delsinm
chgrp Animals Animals
chmod g+s Animals
chmod o+t Animals
cd Animals
touch executable
chmod u+s executable

chmod u-s executable
cd ..
chmod o-t,g-s Animals

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

Describe the process of changing the root password when it’s forgotten

A

rd.break - this will break off to the ram disk, this will drop you to where before the root filesystem is mounted ( the system locates that info in /etc/fstab. /sysroot will contain the filesystem for the time being but it’s read only so:

mount -o remount/rw /sysroot
this just makes it to where we can modify the filesystem now that we have rw permission

chroot /sysroot
Your root directory is set to / by default, but since the filesystem is on /sysroot now, we’ll want to change that root directory over to /sysroot

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

Recover root password

A

reboot
Stop at the menu that shows the recovery mode and standard (should be the top one)
press e to edit
after rhgb quite:
rd.break
^x
mount -o remount,rw /sysroot

chroot /sysroot

passwd root

touch /.autorelabel

exit
exit

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

Create a temporary environmental variable

A

export VAR=test

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

Create a permanent environmental variable

Update the PATH global varaible to contain /opt/this directory

or

Add a script to your path so you can use it without having to type ./this.sh

A

make a backup just in case
cp .bashrc bahrc.backup
vi .bashrc
TEST=’123’
export TEST

export PATH=”$PATH:/opt/this”

mkdir -p ~/bin (~ says go to your home)
mv your.sh /bin/your.sh

export PATH=”$PATH:$HOME/bin”
source ~/.bashrc <or></or>

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

Set a permanent global variable

A

vi /etc/profile or /etc/bashrc
I think /etc/profile needs a relogin

TEST=’123’
export TEST

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

What is the nice scale?

A

-20 - 19
Lower the number, higher priority

This is ONLY for cpu priority and has nothing to do with startup times

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

Run sleep and give it a nice value

A

nice -n 5 sleep 10

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

show logs from system boot

A

cat /var/log/boot.log

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

Show info on hardware - specifically cpu

A

dmidecode -t processor

status: populated, enabled means that’s the actual cpu core

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

rollback a download

A

yum history undo 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
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
14
Q

Show info about ens33

A

ethtool ens33

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
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

17
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

18
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

19
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/

20
Q

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

A

!/bin/bash

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

21
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

22
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

23
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

24
Q

Create a case script

A

!/bin/bash

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

25
create an alias for pwd and ls -la together
alias pl="ls -la; pwd" unalias pl
26
Adding a disk Show added disk Create new partition Add file system type (We want linux shit) Mount that ol' girl to a directory you make called data Make it mounted on boot Unmount
Add hard drive fdisk -l fdisk /dev/sdb n p (primary) (enter) (enter) +1G (if you wanted to make a 1G partition) w (write table to disk and exit) fdisk -l mkfs.xfs /dev/sdb1 (xfs is linux shit) mkdir /data mount /dev/sdb1 /data vim /etc/fstab at end: /dev/sdb1 /data xfs defaults 0 0 (this allows this on boot) umount /data You can use UUID located in blkid in /etc/fstab instead of /dev/sdb1
27
Create an NFS Server
yum install nfs-utils libnfsidmap (probably aleady installed) systemctl enable rpcbind systemctl enable nfs-server systemctl start rpcbind, nfs-server, rpc-statd, nfs-idmapd ( do each on their own line mkdir /mypretzels chmod a+rwx /mypretzels cp /etc/exports /etc/exports_orig vim /etc/exports /myprezels 192.168.12.7 (rw,sync,no_root_squash) exportfs -rv firewall-cmd --permanent --add-service=nfs and rpcbind ====================================== 192.168.12.7 (client) If you want to give it to everyone just put "*" sync - write to disk immediately - root onl client machine will have same level of access to files as root on server -r republish everything in /etc/export -v verbose =================================================================
28
Create an NFS client
Steps for NFS client configuration yum install nfs-utils rpcbind systemctl rpcbind start firewall-cmd --permanent --add-port=111/tcp firewall-cmd --permanent --add-port=rpc-bind mkdir /mnt/app (just make a mount point) mounnt 192.168.1.5:/mypretzels /mnt/app
29
Configure Samba
yum install samba samba-client samba-common firewall-cmd --permanent --zone=public --add-service=samba mkdir -p /samba/moreprezels (-p make parent directories as needed) chmod a+rwx /samba chown -R nobody:nobody /samba chcon -t samba_share_t /samba vim /etc/selinux/config SELINUX=disabled reboot (from samba dir /etc/samba/) cp smb.conf smb.conf.orig (delete everything below the comments copy contents from guide and paste.) test par (test parametar) (hit enter) systemctl enable smb systemctl start smb systemctl enable nmb systemctl start nmb cd /samba/morepretzels touch apples ======================================= NOW LOOK AT THE SHARE VIA WINDOWS \\192.168.1.95 (whatever your ip is on linux) Right click -> new -> text document -> save and call it yara to check if it pops up on linux ======================================= NOW LOOK AT THE SHARE VIA ANOTHER LINUX yum install cifs-utils samba-client mkdir /mnt/sambashare (creating mnt point) mount -t cifs //192.168.1.95/Anonymous /mnt/sambashare (-t which file system) ================================================== HINTS Nobody is used for NFS - particularly when using root_squash which maps uid 0 (root) to nobody's uid preventing the client from access the file as a super user. I think Nobody might actually be used since it is an account that anyone can use and it has limited rights.
30
Configure autofs
yum install autofs -y systemctl start autofs systemctl enable autofs vim /etc/auto.master add: /nfs /etc/auto.nfs --timeout=60 --ghost (ghost creates directories inside the nfs) or instead of /nfs do /- vim /etc/auto.nfs nfs -fstype=nfs 192.168.1.114:/nfs or if you used /- /nfs -fstype-nfs 192.168.1.114:/nfs
31
Look up unit httpd in journalctl Show incrementing logs from httpd Show just errors
journalctl -u httpd jounalctl -fu httpd journalctl - p err -u httpd -r reverse -n 5 show last 5
32
Make the journalctl persistent
System logs are ephemeral, they go away on boot vim /etc/systemd/journal #Storage=persistent if it's #Storage=auto This means if /var/log/journal exists it will stay perminant, if not it will make an ephemeral log. systemctl daemon-reexec or systemctl reload systemd-journald mkdir -p /var/log/journal/
33
Automount all filesystems specified in fstab
mount -a
34
Find all directories named fart in my home directory How would you search for a file with this name?
find /home/delsinm -iname "fart" -type d -type f