RHCSA 9 My Notes
RHCSA 9 My Notes
#who :show current connected users. Pipping | :is to use the output of the first command as an input
for the second on
#w :same as who but with more details. (e.g cat/etc/hosts | grep linda).
#chvt 3 :change to the virtual terminal N° 3, or you can press #history :print commands history.
ctrl+alt+f3.
~/.bash_history :history file.
#man ls :to get ls command documentation.
HISTSIZE and HISTFILESIZE :to define entries number.
#man –k or apropos :to search for a command in mandb based on
keywords, but you need to run the mandb command #history –w :synchronize history to .bash_history.
first. #history –c :clear history.
#vim file1 :file editor, you can use some commands while using #history –d nn :delete command nn from history
vim:
yy :copy text,
dd :delete line, Expansion:
p :paste,
gg :go to the top of the file, #ls * : show all
G :go to the end of file, #ls a?* : show all file’s name starts with a and followed at
^ :go to start of line, least by 1one character.
$ :go to the end of line,
/hi :search for the word hi, #ls [a-e]* :show all files start with a or e.
%s/old/new/g :replace word “old” with the word #ls [a..e]* :show all files start with a,b,c..e.
“new”
se number :show lines number, #touch file{1..9} : create from file1 to file9.
a :start insert mode,
o :insert line. #useradd {linda,bob,rose} : create users linda, bob and rose.
#grep –A 5 –B 5 allow /etc/ssh/sshd_config :show 5 lines after and Lisa ALL=/usr/bin/passwd ,!/usr/passwd root
5 lines before the specific word. => lisa allowed to changer other users
password but not the root password.
#grep –R root * :recursive search in the current directory and
sub directory. #vim /etc/sudoers.d/group_users
#grep –l wassim /etc/* :print only the file that continent the text %users ALL=/usr/sbin/mount /dev/sdb
Wassim in it. =>members of the group users are allowed to
mount sdb.
#grep ‘^w’ file1 :grep all lines satarts with w.
#grep ‘$nova’ file1 :grep all lines ends with nova.
Users and Groups
#grep ‘anna\b’ file1 :grep word ends with anna
#useradd wassim :create uses (with default settings).
#grep ‘b.*t’ file1 :grep words starts with b and ends with t, and
whatever the nbr of character in between is 0 #useradd supernova –d /home/dir_super –g tekup –G wheel –s
or more. /sbin/nologin –u 3004
#grep ‘b.+t’ file1 : 1 or more. -d : to specify the user’s home directory
-g : to specify user’s primary group
#grep ‘b.?t’ file1 :0 or 1 caracter in between.
-G : supplementary groups
#grep ‘bo\{3\]t} file1 :start with b and ends with t and o repeated -u : to specify the user’s UID
4times (e.g boooot). -s : to specify user’s shell, example of shell:
/sbin/nologin : this shell
prevents interactive login.
Root privileges /bin/sh : It's less feature-rich
than Bash but still provides a
#su - :switch to root user. shell environment.
/sbin/bash : full interactive
#usermod –aG wheel Wassim :memebers of the group wheel shell login.
are allowed to use sudo.
linkedin.com/in/saadaouiwassim
RHCSA 9
#usermod –L linda : the user linda is locked. -W : set expiration warning days to
WARN_DAYS.
#usermod –U linda : unlock the user.
/etc/security/pwquality.conf : password policy config file.
#usermod –e 2023-09-12 linda : change user expiration date.
/etc/shadow : where the password hashage is stored.
#usermod –s /bin/bash linda :change user shell.
#userdel linda :delete user.
#newgrp dev linda :temporary primary group. File owner ship
#groupadd finance : create new group named fianance. Permission on folder and files are: read=r=1, write=w=2, execute=x=1.
#groupdel dev : delete a group. #chown linda file : change the file owner to linda.
#lid –g finance : list all members of the group finance. #chown :dev file : change the file groupe owner to dev.
/etc/default/useradd : config file of useradd. #chgrp dev file : change group owner.
/etc/login.defs : default setting of creating a new user. #chmod 750 file : change file access permission.
/etc/skel : files on this folder will be created to the user #chmod g+x o-rw u+rwx file : g+x add the execute permission for
home directory upon creation. group.
#passwd linda : change linda password. o-w : restric the permissions of read
and write for others.
# chage –d 0 linda : force linda to change the password next time u+rwx : add the all permissions to the
login
user (owner).
=> chage options:
-d set date of last password change to #chmod g+s folder : setgid : every file or folder will be created on
LAST_DAY. this folder, it will be owned
-E: set account expiration date to by the group ownership of the parent
EXPIRE_DATE. folder, can write also :
-I : set password inactive after expiration to chmod 2751 folder
INACTIVE.
#chmod +T folder : sticky bit : to make only the owner of file/
-m set minimum number of days before
password change to MIN_DAYS. sub-directory can delete it.
-M set maximum number of days before chmod 1751 folder
password change to MAX_DAYS. umask: is a shell setting that subtract the umask value from the default
permission on folde/file.
linkedin.com/in/saadaouiwassim
RHCSA 9
Default permission on a folder are 777 and for a file are 666 #ip link show : show current network devices.
e.g umask 022 on a file: #ip addr show : show network device configuration.
Owner: 6 (read and write) - 0 (umask) = 6
#hostnamectl hostname tekup :change hostname.
Group: 6 (read and write) - 2 (umask) = 4
Others: 6 (read and write) - 2 (umask) = 4 /etc/hosts : contain hosts and their IP.
you can set mask by running the cmd umask on the shell, or added it to .bashrc
/etc/resolv.conf : contain dns config.
or .bash_profile
/etc/nsswitch.conf : hostname resolution.
e.g: umask 752 or echo “umask 752”>> ~/.bashrc
When you try to ping google.com, your system will check /etc/hosts then
#getfacl file : show file access list.
dns, and then your hostname.
#setfacl -m u:alice:rw f1 :add the user alice to f1 ACL and
permissions are set to rw.
#ip addr add dev ens160 10.0.0.1/24 : add temporary address.
#setfacl -m g:operations:rw f1 : add the group operations to the acl. #ip route 2.2.2.2/24 via 10.0.0.1/24 : add route to the route table.
#setfacl -m u:bob:rw,g:tekup:rw f1 : add user and group to the acl. /etc/NetworkManager/system-connection : folder where you will find the
file for you network config.
#setfacl -m d:u:bob:rw folder1 : the option d is only applied to folders, to
make sure the acl will be inherited to #nmcli general permission : to check permission on network
sub-folders and files. manager.
#setfacl -b f1 : delete all acl for f1 #nmcli con show or nmcli dev status : show connection.
#setfacl -x g:tekup f1 : delete groupe tekup from acl. # nmcli connection add con-name mycon ifname ens160 type ethernet
ip4.add 192.168.1.11 ipv4.gatway 192.168.1.2 ipv4.method manual
#getfacl -R f1 >acl.save : save acl to a file
This command is used to a new connection
#setfacl -b f1 : delete all f1 ACL con-name: to set the new connection name
#setfacl --restore=acl.save f1 : retore f1 acl ifname: to set the interface name
type: to set the connection type
ipv4.method: used to specify the method used to
configure IPv4 settings for a network connection,
auto ( the coonection will receive ip@ from DHCP,
so the address we set may will be change), manual(
static address, so the address we set won’t change).
Network
linkedin.com/in/saadaouiwassim
RHCSA 9
#nmcli con up mycon : to activate the connection. #mkdir /repo : mount point.
# nmcli connection modify ens160 ipv4.add 192.168.130.229/24 #echo “/rhel.iso /repo iso9660 defaults 0 0” >> /etc/fstab : persistent
ipv4.gateway 192.168.130.1 ipv4.dns 192.168.130.254 +ipv4.dns 8.8.8.8 mount.
modify my current connection settings (this’s what you will be asked for #mount -a
on the RHCSA exam).
# dnf config-manage --add-repo="file///repo/BaseOS" : add baseos
# nmcli connection reload to reload all connection files repository to /etc/yum.repos.d
#nmtui : console where you can set hostname & #ls /etc/yum.repos.d : to check for the file.
connections.
#dnf repolist : list of repository.
#ss : investigate sockets.
or can be created manually
#vim /etc/yum.repos.d/BaseOS.repo
Managing software >[repo_BaseOS]
RPM : software on RHEL is installed using packages in RPM format. >name=BaseOS
#rpm –qa : show all installed packages. >baseurl=file///repo/BaseOS
#rpm –qf gedit : show from which packages gedit was >enable=1
installed.
>gpgcheck=0 disable gpg key check.
#rpm –ql gedi t : Shows u what files were put on ur computer
when u installed a program using RPM
#rpm –q --scripts podman : shows the executed scripts while installing Managing packages with dnf
the package.
#dnf list “selinux” :list selinux installed and available packages.
#dnf seach seinfo :search in packages name and summary.
Setting up Ripository access #dnf search all seinfo :search even in description.
#dh -h : check for available space (check / it should have #dnf provides */containerfile :search for packages that
available space >10GiB, or it won’t work provides a specific file.
#dd if=/dev/sr0 of=/rhel.iso bs=1M :copy files from sr0 to rhel.iso. #dnf info httpd : show package info.
linkedin.com/in/saadaouiwassim
RHCSA 9
#dnf install firewalld : install package. >f : shows available display field.
#dnf update : update installed packages. #nice -n 19 dd if=/dev/zero to of=/dev/null :nice and renice are
used to set the priority of a processit value
#dnf group list : show Available Environment Groups. between -20 and 19, -20 highest priority and
#dnf group list hidden : show all available groups ( include not 19 is the lowest.
installed groups). #renice -n 19 PID : renice process using PID.
#dnf group info “vitualization host” : list packages within group.
#dnf group install “ftp server” --with-optional : install with optional Profiles
packages.
#sysctl -a : show system variables.
/var/log/dnf.rpm.lop : all transaction that dnf perform.
#dnf history : summary of all installation and removal #sysctl vm.swappiness=40 : change variable value.
transaction. problem: sysctl containes about 1004 variable, which means it’s hard to set
all those variable.
#dnt history undo n : undo transaction number n.
solution: is to use a profile or to custom profiles.
#tuned-adm list : shows all available profiles.
process and jobs
#tuned-adm profile my profile : set a profile.
#command & : run a command on background.
#mkdir /etc/tuned/myprofile : create folder form my custom profile.
#jobs : list all jobs that runs on background.
#vim /etc/tuned/myprofile/tuned.conf :create my profle
#fg 1 : run back job 1 to forward ground.
>[sysctl]
#ps aux : review of all processes.
>vm.swappiness=66
# ps -fax : shows heirarical relation between processes.
#tuned-adm profile myprofile : change profile to myprofile.
#ps -fu wassim : show all processes owend by wassim.
#sysctl -a | grep vm.swappiess : check changes.
#ps -f --forest -c sshd : show a process tree.
Note: we should change the value reapply_sysctl to 0 in the config file
#ps L : show you a list of threads. /etc/tuned/tuned.main.conf.
#ps -eo pid, ppid, user, cmd : some specifiers to show a list of processes. #loginctl : manage users and sessions.
#top : realtime process monetering.
linkedin.com/in/saadaouiwassim
RHCSA 9
>RestartSec=5s
**** sretart a service automatically in failure case. >OnBootSec= 15min : service will be trigged 15min after
the system boot.
#systemctl edit httpd.service
>OnUnitActiveSec= 1w : this option will make sure service
>[service] will be trigged only after one week
sence the last time.
>Restart=always
linkedin.com/in/saadaouiwassim
RHCSA 9
>Persistent=true : when a timer is missed, persistent Logging
will make sure it will be run
immediately when the system boot. #journalctl : show the entire journal.
#journalctl -p err : show errors only.
other timer’s option:
OnActiveSec= 1h : to make sure the service is trigged 1h after booting #journalctl -f : show the last 10lines+ adds new massage
or after starting the timer. (synchronization).
OnBootSec= 15min : service will be trigged 15min after booting the #journalctl -u sshd : show journal of specific service.
system. the old option was (OnStartupSec= 15min). #journalctl --since “-1hour” : show journal of the last 1hour.
OnUnitSec= 1w : to make sure that timer will wait for 1week to #journalctl --since today : show today journal.
triggers the service again.
#journalct -o verbose : detailed journal.
PS: you should add Persistent=true , to make the
service will be trigged immediately next reboot if /etc/logrotate : logrotate config file
the timer is missed. logrotate.timer : timer to clean log files.
OnCalendar= 10:00 : trigged the service daily at 10:00. #df -h :shows available space.
OnCalendar= Mon 10:00 : every monday at 10:00. #lsblk : print block devices.
OnCalendar= Sun..Fri 13:00,19:00 : from sunday to friday at 13H #blkid : shows block’s UUID.
and at 19H, and after that the service won’t be trigged again. /proc/partition : partition and disk statistics.
OnCalenda= Mon, Tue *-*-* 14:00 : every Mon & Tue at 14H. /etc/fstab : persistent mount file.
On calendar= 2023-07-12..2023-07-23 19:00 :from 07/12 to 07/23 at /run/systemd/generator/ : folder for drop-in mount files (not encluded
19H on RHCSA exam)
****Crontab to create a new partion you can use: fdisk, gdisk or parted.
#crontab -e : create cron job ***create and mount a new partion:
/etc/crontab : a file that shows how to setup a cron job. #fdisk /dev/sda :create a new partition from sda device
/etc/cron.d : directory to drop you cronjob config file. >m :for help.
linkedin.com/in/saadaouiwassim
RHCSA 9
>n : create new partition ***LABLE
>w : write to disk table and exit. #xfs_admin -L super /dev/sda1 : set label named “super” to /dev/sda1
(xfs file system).
>q : exist without saving changes.
#echo “LABLE=super /xfs1 defaults 0 0” >>/etc/fstab
#mkfs.xfs /dev/sda1 : create xfs file system on sda1 partition.
#mount -a
#mkdir /xfs1 : folder which will the mount point for the new
partion ***Swap
# mount /dev/sda1 /xfs1 : for temporary mounting ( will be discard #fdisk /dev/sda : to create a new partition for swap
after reboot).
>n : new partition
#echo “ /dev/sda1 /xfs1 xfs default 0 0”>> /etc/fstab :
persistent mount >t : to change partition type
# mount -a : to make sure to mount all unmounted devices. >8200 : linux swap hexa code
#findmnt --verify : you can always use this command to verify if >w : save changes.
there’s any syntax errors in /etc/fstab. #mkswap /dev/sda2 : create swap file system on /dev/sda2.
**** mounting usig UUID and LABEL #swapon /dev/sda2 : activate the new swap partition.
#blkid : to get block UUID. #swapoff /dev/sda2 :disactivate the swap partition
#tune2fs -L : set a label on ext file system. #echo “/dev/sda2 none swap defaults 0 0” >>/etc/fstab
#xfs_admin -L : set a label on xfs file system.
#mkfs.* -L : set a label while creating a file syetem. ***LVM creation
in case of cloning device two device will be have the same UUID, so u need #pvcreat /dev/sda1 :create physical volume
to use the command:
#vgcreate vgdata /dev/sda1 : create a volumle groupe named vgdata from
#xfs_admin -U generate /dev/sda1 : to get a new UUID. the physical volume /dev/sda1.
**UUID #lvcreate -n lvdata -L 1G vgdata : create logical volume named lvdata
with a size of 1GiB from vgdata.
#blkid
#mkfs.xfs /dev/vgdata/lvdata : create file system on lvdata.
#echo “UUID=….. /xfs1 xfs defaults 0 0” >> /etc/fstab
#mount -a #echo “/dev/vgdata/lvdata /lvfolder xfs defaults 0 0” >>/etc/fstab
linkedin.com/in/saadaouiwassim
RHCSA 9
#mount -a #stratis blockdev list : list all pool blockdevices.
***extent (which mean to set volume based on block size) #stratis fs create mypool myfs1 : create file system on mypool.
#vgcreate -s 8M vgdata /sda1 :set the physical extent volume (echa #echo “UUID=… /myfs1 xfs
block size is 8MiB) defaults,x_systemd.requires=stratisd.service 0 0”>>/etc/fsrab
#lvcreate -l 2 -n lv1 vgdata : create a logical volume within a size of 2 mount stratis fs.
blocks,each block’s sized of 8MiB.
***stratis snapshot
***extend LVM size
#stratis fs snapshot mypool myfs mysnap : create a snapshot of myfs
#vgextend vgdata /dev/sda2 :extend vg volume.
#mkdir /mysnap :create mount point
#lvextend -r -l +50%FREE /dev/vgdata/lv1 : add 50% of the free
space on vgdata to lv1 #mount /dev/stratis/mypool/mysnap /mysnap : mount mysnap on
/mysnap
#lvextend -r -l +2 /dev/vgdata/lv1 : extend lv1 with two blocks. #ls -l /mysnap :check /mysnap
continent.
#lvextend -r -L +1G /dev/vgdata/lv1 : add 1GiB to lv1.
#stratis fs destroy mypool myfs : destroy myfs.
#lvextend -L +1G /dev/vgdata/lv1 /dev/sda2 : specify from which
physical volume you will add more volume to lv1.
***reduce volume Boot procedure
#pvmove -v /dev/sda2 /dev/sda1 : move all the contenant of sda2 /etc/default/grub : to edit persistently Grub2 parameters.
extents(blocks) to sda1.
#grub2-mkconfig -o /boot/grub2/grub.cfg : to compile changes to
#vgreduce vgdata /dev/sda2 : reduce vgdata volume. grub.cfg on xfs file system.
***startis volume #grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg : to compule
#dnf install stratis-cli startisd changes on EFI file system.
also you can boot into specific, from boot screen press “e” and add >else
system.unit=xxx.target to the end of line linux. > echo you typed something else
*****root password recovery >fi
step1: from boot screen press “e”. >if [ -f $1 ] same as test -f $1
step2: add init=/bin/bash to end of line linux >then
#mount -o remount, rw / : to change into read-write mode on / > echo $1 is a file
#passwd root :change password. >else
#touch /.autorelabel : to resolve problem related to selinux. > echo $1 is not a file
# exec /usr/lib/systemd/systemd :to restart the system on a normal way. >fi
#chmon u+x test.sh : to make the file executable.
Shell bash scripts #. test.sh : run the file
linkedin.com/in/saadaouiwassim
RHCSA 9
>do
**** for > echo $counter seconds remaining
#vim n-bonj.sh > counter=$(( counter -1))
>#!/bin/bash > sleep 1
>read num >echo break is over
>for((i=1; i<= $num; i++)) #chmon u+x break-counter.sh : to make the file executable.
>do #. break-counter.sh
>echo bonjour n: $i Note: you can use bash -x to to see in details what’s the script doing
while running
>done
#bash -x break-counter.sh
#chmon u+x n-bonj.sh : to make the file executable.
you can ckeck man test for test options
#. n-bonj.sh : run the file
****while SSH
linkedin.com/in/saadaouiwassim
RHCSA 9
#ssh -X server gedit : the optin -X is used to run application on the remote selinux=1 : enable selinux
server.
#semanage fcontext :to manage selinux context
/etc/ssh/ssh_config : client-side configuration file for OpenSSH.
#restorecon -Rv /var/www/html : to inherite selinux policy of the
/etc/ssh/sshd_config : server-side config file. parent folder.
#scp file1 file2 student@server:/home/student : copy file securely. #semanage -a -t httpd_sys_content_t “/web(/.*)? to change selinux
policy of the flolder /web.
#rsync -a * server:/home/student/ : synchronize files between current
directory and remote server path. #restore -Rv /web :apply the new policy.
***how to get the right selinux policy
#dnf install httpd #man -k _selinux |grep httpd : show all selinux policy
related to httpd.
/etc/httpd/conf/httpd.conf :config file
***changing port for ssh to 2022
/etc/httpd/conf.d/ :drop-in files storing folder.
#semanage port -a -t ssh_port -t -p tcp 2022
/var/www/htdocs : defaults document root.
***Boolean
#getsebool -a |grep ftpd : show all selinux Boolean related to
Selinux ftpd.
#setenforce : change between enforcing & permissive mode. #semanage boolean -l -c : shows all boolean that have non
default settings.
/etc/sysconfig/selinux : config file.
#journalctl | grep sealer : to get all selinux alerts.
selinux also can be context from the boot menu, in the end of line “linux”.
#grep AVC /var/log/audit/audit.log : used to search for entries related to
enforcing=0 : permissive mode AVC (Access Vector Cache) denials
enforcing=1 : enforcing mode in the audit log file on a system with
SELinux enabled.
selinux=0 : disable selinux
linkedin.com/in/saadaouiwassim
RHCSA 9
Firewalld
#ss :shows all sockets Remote file system and automation
#ss -tu :show connected tcp and udp sockets ***configure nfs server
#ss -tua :show sockets that are in listening state. #dnf install nfs-utils
#firewall-cmd --list-all : list complete config of the firewall #mkdir -p /nfsdata /home/ldap/ldapuser{1..9}
#firewall-cmd --get-services : show all managed services by the firewall #echo “/nfsdata *(rw, (no_root_squash))” >> /etc/exports
#firewall-cmd --add-service http : allow the http service temporary #echo “/home/ldap *”(rw, (no_root_squash))” >>etc/exports
#firewall-cmd --add-service http --permanent : allow the http service #systemctl enable --now nfs-server
permanently.
#for i in nfs mountd rpc-bind; do firwall-cmd --add-service $i --
#firewall-cmd reload : reload firemwall config. permanent; done
#firewall-cmd reload
Mannaging time #show mount -e nfsserver :to check the nfs server is accessible.
#hwclock --hctosys : set time from hardware clock to system time. ***client side
#hwclock --systohc :set time from system to hardware clock. #dnf install nfs-utils
#date : show date and time. #mount server:/nfsdata /mnt
#timedatectl status :show current time settings. ***automont (client side)
#timedatectl set-time : set system time. #dnf install autofs
#timedatectl set-timezone : set system time zone. #echo “/nfsdata /etc/auto.nfsdata”>>/etc/auto.master
#timedatectl set-ntp : enable/disable network time synchronization. #echo “files -rw nfsserver:/nfsdata”>>/etc/auto.nfsdata
#chronyd : used for time synchronization and clock management. #systemctl enable --now autofs
#chronyc sources : verify proper synchronization. ***automount for home directory
/etc/chrony.conf : chrony config file. #echo “/homes /etc/auto.homes”>>/etc/auto.master
linkedin.com/in/saadaouiwassim
RHCSA 9
#echo “* -rw nfsserver:/home/ldap”>>/etc/auto.homes #podman run -it --name mycontainer docker.io/library/httpd
#systemctl restart autofs -it : start a container with interactive terminal
#podman logs mycontainer :explore logs created by the container.
#podman login registr.redhat.io : to get your current login display metadata about container image
credentials. don’t forget to add docker:// or it won’t work
#podman search : search for images from registries #podman run -d --name mydb -e
#podman build : build an image from containe image. MYSQL_ROOt_PASSWORD=wasssim -p 8080:80
quay.io/centos7/mariadb-103-centos7
#podman run : run a container
-e : set container envirement variable, -p : publish a container’s port, or
#podman stop : stop a container range of ports. #firewall-cmd --add-port 8080/tcp : allow port access on
#podman rm : remove a container firewall.
#podman pull : pull (download ) image from registries with root user you can run this command with out problem:
#podman exec : run a command in a running container # podman run -d --name mydb -e
MYSQL_ROOt_PASSWORD=wasssim -p 8080:80 -v
#podman ps : list info abut active containers. /root/mydb:/var/lib/mysql quay.io/centos7/mariadb-103-centos7
but with a normal user you will face many problems related to files owner
ship and selinux
#podman run -d --name sleepy docker.io/library/httpd sleep 3600
solution:
-d: run a container in detached mode, which means container will run in
background, sleep 3600 : container will run a specific service and then will
sleeps for 1hour.
linkedin.com/in/saadaouiwassim
RHCSA 9
#podman run -d --name mydb -e #systemctl --user daemon-reload
MYSQL_ROOt_PASSWORD=wasssim -p 8080:80
#systemctl --user enable container-myngnix.service
quay.io/centos7/mariadb-103-centos7
#sudo reboot
run containe with out storage
#jounalctl | grep containee-myngnix : to check if the
#podman exec mydb grep mysql /etc/passwd :to get mysql uid:uid
container is working
#podman unshare chown 27:27 mydb :chande the folder mydb to
become owned by the containers. ***pdfconvert
#loginctl enable-linger linda :to make sure the container service $podman build -t pdfconvert -f ./Text-To-PDF/Dockerfile
will run even the user linda isn’t connected.
to build container image using docker file
#ssh linda@localhost
$podman run -d --name myapp1 pdfconvert
#mkdir ~/.config/systemd/user
$podman exec myapp1 cat /etc/passwd
#cd ~/.config/systemd/user
$podman unshare chown 65534:65534 ~/data/in
#podman run -d --name myngnix -p 8080:80 ngnix
$podman unshare chown 65534:65534 ~/data/out
#podman generate systemd--name mynginx --files --new
$podman stop myapp1 && podman rm myapp1
#echo “WantedBy=default.target” >>container-myngnix.service
$podman run -d --name myapp1 -v ~/data/in:/data/input:Z -v
wantedby should set only to default.target, otherwise, it won’t work. ~/data/out:/data/output:Z pdfcon
linkedin.com/in/saadaouiwassim
RHCSA 9
$podman generate systemd--name myapp1 --files --new $ systemctl --user daemon-reload
$vim container-myapp1.service $ systemctl --user enable container-container-logserver.service
check for the line WantedBy=default.target
$systemctl --user daemon-reload *********rsyslogpodman build
$systemctl --user enable container-myapp1.service 1. Create a container logserver from an image rsyslog
2. Configure the container with systemd services by an existing user “linda”,
3. Service name should be container-logserver, and configure it to start
automatically across reboot.
******** syslog
4. Configure your host journal to store all journal across reboot
#useradd bob 5. Copy all *.journal from /var/log/journal and all subdirectories to
/home/linda/container_logserver
#passwd bob set password to tekup 6. Configure automount /var/log/journal from logserver (container) to
/home/linda/container_logserver when container starts.
#loginctl enable-linger bob
#vim /etc/systemd/journal.conf
#mkdir /var/log/containerlog
make the following changes
#chown bob:bob /var/log/containerlog
Storage=persistent
#ssh bob@localhost
SystemKeepFree=100M
$podman login registry.access.redhat.com
RuntimeKeepFree=100M
$mkdir container_logserver
#systemctl restart systemd-journald
$ mkdir -p .config/systemd/user
#useradd linda && passwd linda
$ cd .config/systemd/user
#loginctl enable-linger linda
$ git clone https://github.com/aheimsbakk/container-syslog-example.git
#ssh linda@localhost
$ podman run -d --name container-logserver -v
/var/log/containerlog/:/var/log/:Z syslog:latest #podman login registry.access.redhat.com
$podman ps check for the container is working #mkdir -p .config/systemd/user
$ podman generate systemd --name container-logserver --files --new #cd .config/systemd/user
linkedin.com/in/saadaouiwassim
RHCSA 9
#mkdir container_logserver
# cp -r /var/log/journal/* ~/container_logserver/
# podman search rsyslog
# podman pull docker.io/lendingworks/rsyslog
# podman run -d --name container-logserver -v
/home/linda/container_logserver/:/var/log/journal/:Z
docker.io/lendingworks/rsyslog:latest
#podman ps
#podman generate systemd --name container-logserver --files --new
#systemctl --user daemon-reload
# systemctl --user enable container-container-logserver.service
linkedin.com/in/saadaouiwassim