RHCSA Commands
RHCSA Commands
sestatus-Command
getenforce - command
setenforce 0 - command
setenforce 1 - command
chcon - command
restorecon - command
FIREWALL
Firewall-cmd
firewall-cmd –list-all
RPM
RPM install
YUM
yum
Repo file path = /etc/yum.repos.d/filename.repo
Repo code
[Name (Appstream)]
name=name(appstream)
baseurl=location(file:///dvd/AppStream)
enabled=0 or 1
gpgcheck=0 or 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-rellease
VI
Vi commands
(i | insert) to insert
yy copy line
cc cut line
p paste line
dd delete line
yw cw dw copy cut delete a word
gg to move the cursor to first line
shift g to move the cursor to last line
:line_number to move the cursor to a specific line
:set nu to turn on line number
:set nonu to turn off line number
o to place a new line below the cursor
Shift o to place a new line above the cursor
u undo
ctrl r to redo
/word to search a word
n next search element
Shift n previous search element
:%s/word1/word2 replace word1 by word2
:w write the file changes
:q quite the file
:x write and quite
! override
crontab
Crontab - demo file /etc/crontab
crontab -e edit
-l list
-r remove
-u to a specific user
To deny a user from cron enter user in /etc/cron.deny
LVM
fdisk -l to list the available disk
fdisk /dev/file to edit
n new partition
p print the partition
t edit the partition type
w write the changes to the disk
m help
partprobe - inform the OS of partition table changes
vgcreate — Create a volume group
-s size of pe
pvcreate — Create a physical volume group
vgdisplay vgname- to see the info
lvcreate -l size name_source -n name(destination) to create a logical volume
Eg: lvcreate -L 2G vg0 -n lv1
-L in bites
-l in pe
mkfs.partition_type dev - to change partition type
lvextend -l size dev
Eg: lvextend -L 4G lv1
resize2fs dev
Eg: resize2fs /dev/vg0/lv1
xfs_growfs dev for xfs file system
Or
-r in lvextend
lvreduce -l size dev -r
Eg: lvreduce -L 1G lv1 -r
Container
yum module install container-tools
podman login registry_location
podman login registry.lab.example.com -to login
Container naming conventions:
registry_name/user_name/image_name:tag
Eg: registry.access.redhat.com/ub8/ubi:latest
podman pull container_name - to download the container to local
podman images - to see the downloaded images
podman run container_name - to run a container
Eg: podman run -it registry.access.redhat.com/ub8/ubi:latest
-i indicates interactive
-t to allocate a terminal
-d to run in background
--name to assign a name to the container
--rm to run commands and stop the container
-e to pass a environment variable
-v to mount a volume
host_dir:container_dir:z
Container registries config file - /etc/containers/registries.conf
podman info
podman search container_name to search a container
podman inspect container_name to see the details of a container
podman rmi container_name to delete a container local
podman ps -a to see the all containers even offline
podman generate systemd --name myweb --files to generate the service file
SYSTEMCTL
JOURNALCTL
journalctl - to see the logs
journalctl -n 5 last 5 lines of log
journalctl -f to follow for new upcoming logs
journalctl --since today for todays log
journalctl --since “(YYYY-MM-DD HH:MM:SS)” --untill “(YYYY-MM-DD HH:MM:SS)”
to see the log between specific time
journalctl _SYSTEMD_UNIT=service to see the log a service
journalctl _SYSTEMD_UNIT=service _PID=PID to see the logs of a service process
CONFIG FILE /etc/systemd/journald.conf
service systemd-journald
journalctl -b n(1,2.3…n) to see the logs before reboot
TIMEDATECTL
Ntp config file /etc/chrony.conf
server (server_name or IP) iburst
Service chronyd.service
chronyc sources -v to see the server details
STRATIS
Rpms required
stratisd
stratis-cli.noarch
stratis pool create pool_name dev to create a pool
list to see the available pools
blockdev list to see the available bloc devices
stratis pool add-data pool_name dev to add a additional storage to an existing pool
stratis filesystem create pool_name filesystem_name -to create a file system
stratis filesystem list - to see the available file system
Entry in fstab add these lines near defaults
x-systemd.requires=stratisd.service
stratis fielsystem snapshot pool_name fs_name snapshot_name
stratis filesystem destroy fs_name -to destroy a filesytem
stratis pool destroy pool_name -to destroy a pool
VDO
Rpms required
vdo kmod-kvdo
vdo create --name vdo_name --device dev --vdoLogicalSize size - to create a vdo
udevadm settle -to apply changes
mkfs.xfs -K /dev/mapper/vd_name to format the vdo
Entry in fstab add these lines near defaults
x-systemd.requires=vdo.service
vdo list - to list the available vdo
vdo status --name vdo_name - to see the status of a vdo
vdostats --human-readable to see the actual status of a vdo
PROCESS MANAGEMENT
Ps -a -to see the process running in that terminal
tty -to see the terminal number
/proc/ - process directory
ps -A to see the whole computer process
?- background process
ps -ef to see the more detailed list
pstree -to see the tree structured process list
ps -aux - to see in percentage
ps -eo pid,ppid,cmd,%cpu,%mem --sort=%mem | head -to sort
ps -eo pcpu,user,uid,args | sort -k 1 -r | head -n 10 - to sort
uptime - to see the system up time ,connected user,load values
top - to see the live stats
pgrep p_name -to see the process
kill -9 pid - to kill a process
9 to force
killall -9 p_name - to kill the process by name
jobs -to see the background jobs
fg job_id -to bring the job foreground
nice -n (-20 to +20) process -to assign a priority to a process
Eg: nice -n -20 sleep 200
Top level priority -20
Low level priority +20
Default priority 0
renice -n pri_no -p pid - to change the priority of a running process
Eg: renice -n 0 -p 5642
Tuned
Rpm required tuned
tuned-adm list -to see the available profiles
tuned-adm recommend -to recommend a profile
tuned-adm available -to see the current profile
tuned-adm profile profile_name -to set the profile
USER ADMINISTRATION
useradd user_name - to add a user
-d /dir - to change the default home directory
-s shell to change the default shell
-u to change the user id (ID)
-r to create system user id
-g for primary group
-G for secondary group
-a to add
-c for comment or contact details
-e for expiry
-M for no home directory