RHCSA Study Notes
RHCSA Study Notes
ll /home
tail /etc/passwd
vi /etc/exports
/home/tom serverip(rw,sync,no_root_squash)
/home/sam serverip(rw,sync,no_root_squash)
======================================================================
======================================================================
======================================================================
vi /etc/auto.master
/misc /etc/auto.misc
/home /etc/auto.home
vim /etc/auto.home
* -fstype=nfs,rw,sync nfs-server-hostname:/home/&
su - sam
ll /home
pwd
exit
======================================================================
======================================================================
======================================================================
REGISTER REPO SERVERS:
yum config-manager --add-repo http://xyz.repo.com/baseos
yum config-manager --add-repo http://xyz.repo.com/appstream
======================================================================
======================================================================
======================================================================
partprobe /dev/sdc
mkswap /dev/sdc1
swapon -a
vim /etc/fstab
UUID="xxxxx" swap swap defaults 0 0
lsblk (confirm swap is present)
======================================================================
======================================================================
======================================================================
groupadd newgroup
ACL
- copy the file /etc/fstab to /var/fstab
- the user owner of /var/fstab should be root
- the user natasha should have read and write access
- the group Mac should have no access
cp /etc/fstab /var/fstab
ls -lah /var/fstab (confirm root is the owner)
chown root /var/fstab (if is not owned by root)
STICKY BIT
- create a directory /linux
- make the group owner be Mac
- ensure that all files within /linux, the group owner is Mac
- ensure that all the future files within /linux, the group owner is Mac
- ensure that no user other than the user-owner of /linux is able to delete the
content within /linux
mkdir /linux
chown :Mac /linux
mkdir /linux/d1
touch /linux/004
Ensure that only user/owner of the directory /linux can delete files
chmod +t /linux
Test that only the user/owner of the directory /linux can delete files
su - natasha
rm -rf /linux
rm: cannot remove '/linux/001': Permission denied
rm: cannot remove '/linux/002': Permission denied
rm: cannot remove '/linux/003': Permission denied
rm: cannot remove '/linux/004': Permission denied
rm: cannot remove '/linux/d1': Permission denied
======================================================================
======================================================================
======================================================================
TUNED PROFILE
yum install tuned
tuned-adm active (shows active profile)
tuned-adm list (shows list of profiles)
tuned-adm recommend (gives recommended profile)
tuned-adm profile <profile-name> (change profile)
tuned-adm off (turns off)
NTP
yum install chrony
vim /etc/chrony.conf
server <ip> iburst
systemctl restart chronyd
chronyc sources -c
timedatectl set-ntp true
======================================================================
======================================================================
======================================================================
podman images
REPOSITORY TAG IMAGE ID CREATED
SIZE
registry.access.redhat.com/rhscl/httpd-24-rhel7 latest 847db19d6cbc 2 months
ago 332 MB
podman ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS NAMES
d40bbb0c94ca registry.access.redhat.com/rhscl/httpd-24-rhel7:latest /usr/bin/run-
http... 8 seconds ago Up 7 seconds web1
======================================================================
======================================================================
======================================================================
mkdir -p ~/.config/systemd/user
podman generate systemd web2 > ~/.config/systemd/user/web2-container.service
vim ~/.config/systemd/user/web2-container.service
WantedBy=default.service
systemctl --user daemon-reload
======================================================================
======================================================================
======================================================================
LVM - LOGICAL VOLUME MANAGEMENT
- create a LV named LV1 of size 8GB
- extend the LV, LV1 by 2GB
- create a LV named LV2 with 10 extent, where the size of each extent is 8MB
mkfs.xfs /dev/VG1/LV1
vim /etc/fstab
/dev/mapper/VG1-LV1 /testmount xfs defaults 0 0
EXTEND LV BY 2GB
lvextend -r -L +2G /dev/VG1/LV1
create a LV named LV2 with 10 extent, where the size of each extent is 8M
- default extent size is 4MB, will need to create a new VG with 8MB extent size
vgcreate -s 8M VG1 /dev/sdc /dev/sdd
vgdisplay
--- Volume group ---
VG Name VG1
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 31.98 GiB
PE Size 8.00 MiB
Total PE 4094
Alloc PE / Size 0 / 0
Free PE / Size 4094 / 31.98 GiB
VG UUID P1JcMp-lQ1I-0MTM-OvwH-0aTd-iofm-VkqCiv
======================================================================
======================================================================
======================================================================
mkfs.xfs /dev/mapper/VDO1
mkdir /vdo-mount
vim /etc/fstab
/dev/mapper/VDO1 /vdo-mount xfs defaults,x-systemd.requires=vdo.service 0 0
======================================================================
======================================================================
======================================================================
STRATIS
mkdir /stratis-fs1
vim /etc/fdisk
UUID=43effeac-72f0-4b18-8118-8fe8d219c706 /stratis-fs1 xfs defaults,x-
systemd.requires=stratisd.service 0 0
mount -a
======================================================================
======================================================================
======================================================================
LINUX PERMISSIONS
1000 - Sticky Bit - when set on a directory, it ensures that only the file owner,
the directory owner, or the root user can delete or rename the files within that
directory.
chmod +t /linux
2000 - Set Group ID, SGID - when set on a file, it allows the file to be executed
with the permissions of the group owner. When set on a directory, new files created
within the directory inherit the group ID of the directory, rather than the primary
group ID of the user who created the file.
4000 - Set User ID, SUID - when set on a file, it allows the file to be executed
with the permissions of the file owner. This is often used for executable files
that need to perform tasks requiring higher privileges.
6000 - SUID and SGID - this is a combination of both the SUID and SGID bits,
meaning the file will be executed with the permissions of both the file owner and
the group owner
chmod u+s,g+s file_name
chmod u+s,g+s /path/to/file
======================================================================
======================================================================
======================================================================
#!/bin/bash
EXECUTE
./find_sticky_bit.sh
FIND ALL THE FILES WITH THE NAME 'PASSWD' AND COPY THEM INTO THE /MNT/COPY
DIRECTORY
mkdir /mnt/copy
find / -name passwd -exec cp {} /mnt/copy \;
FIND ALL FILES OWNED BY THE USER 'ROHIT' AND COPY THEM INTO THE DIRECTORY
/MNT/ROHIT
mkdir /mnt/rohit
find / -user rohit -exec cp {} /mnt/rohit \;
======================================================================
======================================================================
======================================================================
SELINUX
- selinux modes
- selinux booleans
- selinux port
- selinux context
MODES
enforcing / permissive / disabled
vim /etc/sysconfig/selinux
SELINUX=disabled (restart VM for change to take place)
BOOLEAN
getsebool -a (list all the booleans)
getsebool -a | grep "httpd"
PORT
allow httpd to be accessed on port 82
CONTEXT
ensure that httpd service can access and host files from the /test directory
default for httpd is /var/www/html
vim /etc/httpd/conf/httpd.conf
change path on DocumentRoot to "/test"
also change Directory path
======================================================================
======================================================================
======================================================================
ls /etc | wc -l
CHMOD
chmod u+x out.txt
chmod o-r out.txt
UMASK
umask 024 (is the opposite 024 is the same as 742)
TAR
tar cvf file.tar file1 file2 (creates archive)
tar tf (views contents of the tar file)
tar xf file.tar (extracts contents of the tar file)
Create a compressed archive for all the files in the /etc directory
tar cvf /mnt/etc.tar /etc
tar tf /mnt/etc.tar
COPY THE LINES CONTAINING THE WORD 'ROOT' IN /ETC/PASSWD AND COPY THEM INTO A
FILE /MNT/PASSWD
cat /etc/passwd | grep -i root > /mnt/passwd
======================================================================
======================================================================
======================================================================
HOSTNAME
======================================================================
======================================================================
======================================================================
CRON
Execute the command /usr/local/bin/backup at 10AM on Feb 4th, every year.
crontab -e
0 10 4 2 * /usr/local/bin/backup
Configure a cron job that runs for the user baljit at 12:08 every Thursday and
execute /bash/echo hello
crontab -e -u baljit
8 12 * * 5 /bash/echo hello
GREP
List the lines containing the word root (case insensitive) in /etc/groups file
grep -i root /etc/groups
Find the word "sbin" in /etc/passwd and copy it into the file /tmp/pass
grep sbin /etc/passwd > tmp/pass
RESET PASSWORD
interrupt grub boot, and select most recent kernel, hit "end" key to go to end of
text
add rd.break then continue booting the VM
SET PASSWD
useradd test
passwd test (enter in password twice)