RHCSA Cheatsheet
RHCSA Cheatsheet
# - root user
$ - regular user
—help
Absolute path : An absolute path is a fully qualified name, specifying the files exact location in the
file system hierarchy. It begins at the root (/) directory and specifies each subdirectory that must be
traversed to reach the specific file.
Relative Path : A path name with anything other than a forward slash as the first character is a
relative path name.
Navigating Path
pwd - print working directory
cd - check directory
ls - list the contents
-l : long list format, -a : hidden files, -R : recursive, -h : human readable
cd ~ - check home directory
cd .. - one directory back
touch - create files
mkdir - create directory
cp - copy file
cp -r : copy directory
mv - move file , rename
rm - remove files
rm -r - remove directory containing files
rmdir - remove directory without files
soft link ( symbolic link) : connecting new name for a existing file (shortcuts)
ln -s newfile.txt /home/user/documents/oldfile.txt
man - manuals
pinfo - print info
pipeline : is a sequence of one or more commands separated by the pipe character (|). A
pipe connects the standard output of the first command to the standard input of the next
command.
ls -l /usr/bin | less ls -l | we -l
- command mode
- extended command mode
- edit mode
- visual mode
i - insert
y - copy
p - past
u - undo
x - delete
:q! - quit discarding all file changes since the last write.
assigning variable
VARIABLENAME=value
echo $VARIABLENAME
su - to switch users
sudo - to get access to certain admin power
useradd - create users
password aging
chage -m 0 -M 90 -W 7 -I 14 user03
accessing files
- User permission
- Group permission
- Other permission
permission on files:
- r - read
- w - write
- x - execute
_ is regular file
d is directory
l is soft link
changing file permission
start with 0
which = 7
chown user:group sample file change user and group ownership at once
linux process
sleep 1000 & - run a job in the background for 1000 sec
bg%#
signal short
definition purpose
number name
Used to report termination of the controlling process of a
1 HUP Hungup
terminal
2 INT keyboard interrupt Causes program termination. (Ctrl+C)
suspend - CTRL + Z
terminate - CTRL + C
systemctl mask service name. -completely stop the services both manually and at the boot
SSH
ssh user@hostname
-f - to specify passkey
/etc/ssh/ssh_config
syslog priorities
journalctl
shows details and extra information about log events
journalctl -n 5
journalctl -f
journalctl -p err
journalctl —until
journalctl -o verbose
by default it save log in /run/log/journal it means it will be removed after every reboot
timedatectl
timedatectl list-timezones
chronyd
sync RTC hardware clock with NTP
managing networks
ethernet -en
wlan -wl
wwan -ww
Network Manager
a daemon that monitor and manage network setting and save config file at
/etc/sysconfig/network-scripts
nmcli
Hostname
Tar
-c —create
-x —extract
-t —list
-v —verbose
-f —file=
-z —gzip
-j —bzip2
-J —xz
scp
sftp
sftp user@host
rsync
-n -dry run
-v -verbose
-a -archive
-r -recursive
-D - device files
rpm
yum
yum list
yum help
yum info
yum install
yum remove
yum update
yum search
yum history
umount /mnt/data
The locate command searches a pregenerated index for file names or file paths and returns the
results instantly.
updatedb
locate passwd
locate -n 5 passwd
The find command searches for files in real time by crawling through the file-system hierarchy.
find / -name ssd_config
WEB console
systemctl enable —now cockpit.socket
firewall-cmd —reload
https://servarname:9090
scheduling task
at,atd -schedule a task with at in RHEL
at timeing
now +5mins
noon +4days
crontab -r - remove
crontab -e -edit
0 9 2 2 * /usr/local/bin/yearly_backup
/etc/crontab
/etc/cron.d
/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
dynamic tuning, the tuned daemon monitors system activity and adjusts settings depending on
runtime behavior changes. Dynamic tuning is continuously adjusting tuning to fit the current
workload, starting with the initial settings declared in the chosen tuning profile.
tuned profiles
Power saving profiles
performance-boosting profiles
Ideal for systems that require a compromise between power saving and
balanced
performance.
Derived from the balanced profile. Provides faster response of
desktop
interactive applications.
throughput performance Tunes the system for maximum throughput.
Ideal for server systems that require low latency at the expense of
latency performance
power consumption.
It enables additional network tuning parameters to provide low network
network latency
latency
powersave Tunes the system for maximum power saving.
Optimized for Oracle database loads based on the throughput-
oracle
performance profile.
Tunes the system for maximum performance if it runs on a virtual
virtual guest
machine.
Tunes the system for maximum performance if it acts as a host for
virtual host
virtual machines.
tuned-adm recommend
nice/renice
setfacl -m o: : - - filename
Managing SELinux
SELinux consists of sets of policies, defined by the application developers, that declare
exactly what actions and accesses are proper and allowed for each binary executable,
configuration file, and data file used by an application.
SELinux context
SELIinux labels
ps axZ
ps -ZC httpd
-a —add
-d —delete
-l —list
selinux booleans
SELinux booleans are switches that change the behavior of the SELinux policy. SELinux
booleans are rules that can be enabled or disabled
semanage boolean -l -C - list booleans in which the current state differs from
the default state
SELinux troubleshooting
- Before thinking of making any adjustments, consider that SELinux may be doing its job
correctly by prohibiting the attempted access.
- Another remedy for overly restrictive access could be the adjustment of a Boolean.
- It is possible that the SELinux policy has a bug that prevents a legitimate access.
sealert -l id number from /var/log/message -shows extra info about selinux error
managing storage
- 2TIB
- 32 bit
-15 partitions
GPT - UEFI
- 64bit
-128 partitions
- 8 millions TIB
- mount
_______________________50GiB________________________________
-create
fdisk /dev/sdb
m -help
p -info
n -new partition
d -delete a partition
udevadm settle - wait for the system to detect the new partition device
mkfs.ext4 /dev/sdb2
-mount
mount /dev/sdb1 /mnt
umount /dev/sdb1
umount /mnt
persistently mount
edit /etc/fstab
vim /etc/fstab
device name mount point, format options disk check disk sync
UUID=7a20315d-ed8b-4e75-a5b6-24ff9e1f9838. /dbdata xfs defaults 0 0
mount -a
swap
A swap space is an area of a disk under the control of the Linux kernel memory
management subsystem. The kernel uses swap space to supplement the system RAM by holding
inactive pages of memory.
create a partition
mkswap /dev/sdb2
udevadm settle
swapon /dev/sdb2
swapon —show
vim /etc/fstab
Physical devices
Physical devices are the storage devices used to save data stored in a logical volume. These are
block devices and could be disk partitions, whole disks, RAID arrays, or SAN disks. A device must
be initialized as an LVM physical volume in order to be used with LVM. The entire device will be
used as a physical volume.
mkfs.xfs /dev/myvg/mylv
mount
then extend VG
reducing LV
- umount
-mount
Stratis
Stratis runs as a service that manages pools of physical storage devices, and
transparently creates and manages volumes for the file systems being created.
stratis-cli
stratisd
df -hT
stratis filesystem snapshot pool1 filesystem1 snapshot1 -take time point back up
VDO
- Zero-Block Elimination filters out data blocks that contain only zeroes (0) and
records the information of those blocks only in the metadata. The nonzero data
blocks are then passed to the next phase of processing.
- Compression is the last phase. The kvdo kernel module compresses the data blocks using
LZ4 compression and groups them on 4 KB blocks.
yum install vdo kmod-kvdo
vdo list
format
mkfs.xfs /dev/mapper/myvdo1
mount
configure
Autofs
The automounter is a service (autofs) that automatically mounts NFS shares "on-demand,"
and will automatically unmount NFS shares when they are no longer being used.
/etc/auto.master
/share /etc/auto.misc
/etc/auto.misc
Boot process
- Interrupt the boot loader countdown by pressing any key, except Enter.
- Move the cursor to the kernel command line (the line that starts with linux).
- Append rd.break. With that option, the system breaks just before the system hands control
from the initramfs to the actual system.
- Type exit twice. The first command exits the chroot jail, and the second command
exits the initramfs debug shell.
Network Security
The Linux kernel includes netfilter, a framework for network traffic operations such as
packet filtering, network address translation and port translation.
The Linux kernel also includes nftables, a new filter and packet classification subsystem that has
enhanced portions of netfilter's code, but retaining the netfilter architecture such
as networking stack hooks, connection tracking system, and the logging facility. The advantages
of the nftables update is faster packet processing, faster ruleset updates, and simultaneous IPv4
and IPv6 processing from the same rules.
Introducing firewalld
Firewalld is a dynamic firewall manager, a front end to the nftables framework using the
nft command. Until the introduction of nftables, firewalld used the iptables command to configure
netfilter directly, as an improved alternative to the iptables service.
firewall-zones
pre-define firewalld-services
- /etc/firewalld
- firewall-cmd
firewall-cmd
—get-default-zone
—set-default-zone=zonename
—get-zones
—get-active-zone
—list-all
—list-all-zones
—list-all —zone=public
—add-port=portname/protocol —zone=zonename
—reload
SELinux does more than just file and process labeling. Network traffic is also tightly enforced by the
SELinux policy. One of the methods that SELinux uses for controlling network traffic
is labeling network ports; for example, in the targeted policy, port 22/TCP has the label ssh_port_t
associated with it. The default HTTP ports, 80/TCP and 443/TCP, have the label http_port_t associated with
them.
If you decide to run a service on a nonstandard port, SELinux almost certainly will block the traffic. In this
case, you must update SELinux port labels
semanage port -l -list the all the ports with selinux label