RHKN
Lernen
Lernen
Set of flashcards Details
Flashcards | 67 |
---|---|
Language | Deutsch |
Category | Technology |
Level | Other |
Created / Updated | 03.02.2025 / 03.02.2025 |
Weblink |
https://card2brain.ch/box/20250203_rhkn
|
Embed |
<iframe src="https://card2brain.ch/box/20250203_rhkn/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>
|
Find all files with the name "passwd" and copy them into directory /mnt/copy
- sudo find / -name passwd -exec cp {} /mnt/copy \;
Find all files owned by the user "Rohit" and copy them in direcory /mnt/rohit
- sudo find / -user rohit -exec cp {} /mnt/rohit \;
The user owner should have all rights on directory "Dir"
- chmod u+x Dir (chmod 7xx DIR)
Create a compressed archieve of /etc directory and name it as /root/com.gz
- tar cvzf /root/com.gz /etc (mit Komprimierung)
Create a archieve of /etc directory and name it as /root/com.gz
- tar -cvf /root/com.gz /etc (ohne Komprimierung)
Copy the lines containing the word "root" in /etc/passwd and copy them into a file /mnt/pass
- grep "root" /etc/passwd >> /mnt/pass
Configure the repositories https://xyz.server.com/basos & https://xyz.server.com/appstream
- vi /etc/yum.repos.d/local.repo
[BaseOS]
name=baseOS
baseurl=https://xyz.server.com/baseos
enabled=1
gpgcheck=0
[AppStream]
name=AppStream
baseurl=https://xyz.server.com/appstrem
enabled=1
gpgcheck=0
Change tuned profile from virtual-guest to balanced
- dnf install tuned
- tuned-adm profile balanced
- tuned-adm active
Configure NTP server to run xyz.
- dnf install chrony
- vi /etc/crony.conf
- server <ip> iburst
- systemctl restart cronyd
- chronyc sources -v
- timedatectl
- timectl set-ntp true (falls es nicht true sist)
Create a group newgroup:
a) create a user harsh and make newgroup as secondary group
b) create a user nitin do not add to newggroup. nitin should have no login shell
c) assign al the above users password redhat
a) - groupadd newgroup
- useradd harsh -G newgroup
b) useradd nitin -s /sbin/nologin
c) passwd nitin/harsh
Copy the file /etc/fstab to /var/fstab
a) the user owner of /var/fstab should be root
b) the user natasha should have read and write access
c) the grou Mac should have no access
a) chwon root /var/fstab
b) useradd natashe & setafcl -m u:natasha:rw- /var/fstab
c) groupadd Mac
- setafcl -m g:Max:--- /var/fstab
Create a directoy /linux
a) Make the group owner to be Mac
b) Ensure that all files within /linus the grorup owner is Mac
c) Ensure that for all future files within /linux the group owner is Mac
d) Ensure that no user other that the user-owner of /linux is able to delet the content within /linux
a) - chown :Mac /linux
b) chwon -R :Mac linux
c) chmod g+s /linux
d) chmod +t /linux
LVM:
a) Create a LV named LV1 of size 8G
b) Extend the LV, LV1 by 2G
c) Create a LV named LV2 with 10 extend where each size is extend is 8Mb
a) - vgcreate VG1 /dev/sdX1
- lvcreate -name LV1 -L 8G VG1
- mount
b)- (vgextend LV1 /dev/sdX3)
- lvextend -r -L +2G /dev/VG1/LV1
c) vgcreate -s 8M VG2 /dev/sdX2
- lvcreate -name LV2 -l 10 /dev/
Create Filesystem from Stratis
- dnf install stratisd
- systemctl enable stratisd
- stratis pool create poolX /dev/sde
- stratis pool list
- stratis filesystem create poolX fsX
- stratis filesystem list
- vi /etc/fstab
- defaults,x-systemd.requires=stratisd.service
Execute the command /usr/local/bin/backup at 10:00a, on Feb 4. every yewr
- 0 10 4 2 * /user/local/bin/backup
Configure a cron job that runs for baljit at 12:08 every thursday and execute script.sh
- 08 12 * * 2 script.sh
Search fo all Files greater than 100M an pass id witch ls -l to /tmp/bigfiles
- find / -size +100M -exec ls -l {} \; > /tmp/bigfiles
Using Loop construct to move files with .text to .text.bak
#!/bin/bash
echo "type dir"
read DIR
for i in ${DIR}
do
SHORTNAME=${i%.txt}
mv $i ${SHORTNAME}.bak
done
Script which checks if a user exists or not
#!/bin/bash
if [-z $1]
then
echo provide names
read USERS
else
USERS=$@
fi
echo pritn each user
for i in ${USERS}
do
grep $i /etc/passwd
done
Create a volume Group vglabs and a lvm with 2g called lvlabs and 50% usage of vg
- vgcreate vglabs /dev/sdX1
- lvcreate -n lvlabs -l 50%FREE vglabs
- mkfs.xfs /dev/vglabs/lvlabs
Configure autofs sucht that /dev/sda1 device ist mounted on directory /start/files when it is accessed:
vi /etc/auto.master
- /start /etc/auto.start
vi /etc/auto.start
- files -fstype=xfs :/dev/sda1
systemctl enable --now autofs
1. create a group sales and users lisa and lori whitch are members
2. ensure that the group sales has full acces to dir /data/sales. Alll files created in this should be gourp owned by the group sales
3. Also ensure that files can only be deleted by the user that has created the file, as well as user lisa who is member of the group
1. groupadd sales & useradd lisa -G sales & useradd lori -G sales
2. chgrp sales /data/sales & chmod g+w /data/sales
3. chmod +t /data/sales & chown lisa /data/sales
DNS Configuration (DNS Server):
- /etc/resolv.conf
DNS Configuration (No DNS Server):
- vi /etc/hosts
Password Expiration (Userbezogen ohne defualt)
- passwd -x 90 lisa
- Überprüfen: chage -l <username>
Password Expiration für alle:
- vi /etc/login.defs
- Überprüfen: chage -l <useranme>
Sarah is allowd to change passwd but not for root:
visudo
- /%users
- sarah ALL=/usr/bin/passwd, ! /usr/bin/passwd root
Was musst man machen um journalctl | grep sealert zu brauchen?
dnf install setroubleshoot-server
Mehr Infos zu SE Logs
grep AVC /var/log/audit/audit.log
Bedingungen um container automatisch als systemd zu runnen
loginctl enable-linger <user>
mkdir -p .config/systemd/user & cd .config/systemd/user
podman generate systemd --files --new --name mydb
Wie erweitert man eine vgroup "vgname" mit /dev/sdx2
vgcreate vgname /dev/sdx2
Run a container MariaDB in home/user/mydb, Steps:
- login via sshs
- mkdir mydb/
- dnf install container-tools
- podman login registryname
- podman pull imagesname
- podman unshare chown 27:27 mydb
- podman run -d --name mydb -e MYSQL_ROOT_PASSWORD=password -p 3206:3206 -v /home/student/mydb/:/var/lib/mysql:Z <images>
Run a Container mydb as Systemd as user
- loginctl show-user <username>
- mkdir -p .conf/systemd/user; cd .conf/systemd/user
- podman generate systemd --name mydb --files --new
- systemctl --user daemon-reload
- systemctl --user enable container-mydb.service
- reboot
- ps faux | less
Reset Root PW
- init=/bin/bash
- mount -o remount,rw /
- passwd root
- touch /.autorelabel
- exec /usr/lib/systemd/systemd
Local Repository's
Files erstellen in
- /etc/yum.repos.d/local.repo
Inhalt:
[BaseOS]
name=BaseOS
baseurl=url
enabled=1
gpgcheck=0
[AppStream]
name=AppStream
baseurl=
enabled=1
gpgcheck=0
Install bash-completion
- dnf install bash-completion
- source /etc/profile.d/bash-completion.sh
- echo "source /etc/profile.d/bash-completion.sh" >> .bash_profile
Partition (die 4. MBR Partition ist eine Extended!!)
- fdisk /dev/sdX
- blkid
- /etc/fstab
- mount -a / swapon -a
Installieren vfat via dnf
- dnf install dosfstools
Suchen nach software:
- dnf provides */mkfs.vfat
LVM:
1. dnf install lvm2
2. Partition erstellen mit fdisk
3. - vgcreate vgdata /dev/sdX1
- vgcreate -s 8M vgdata /dev/sdX1 falls eine Extend gerwünscht ist:
4.1 - lvcreate -n lvdata -L 1G /dev/vgdata
4.2 - lvcreate -n lvdata -l 75 /dev/vgdata (Extends)
5. mkfs.xfs /dev/vgdata/lvdata
Erweitere das LVM um +5G (hat platz)
vgextend -r -L +5G /dev/vgdata/lvdata