RHCSA Exam (EX200) Commands Cheatsheet
RHCSA Exam (EX200) Commands Cheatsheet
RHCSA Exam (EX200) Commands Cheatsheet
------
## Cheatsheet:
* `man 5 shadow` *show man pages for `SHADOW(5)`, the password file.*
* `apropos -a ext4 tunable` *search man pages and descriptions for both
keywords.*
* `tar -cjf etc-bkp.tar /etc` *same as above but compressed with `bzip2`.*
* `chown root:sgrp /sdir` *change ownership and owning group to `root` and
`sgrp` respectively.*
* `chmod +1000 /tmp`, `chmod o+t /tmp` *sets the sticky bit on the specified
directory without altering existing underlying permissions. (sticky bit on
public and shared writable dirs are used to protect files and subdirs owned
by normal users from being deleted or moved by other normal users)*
* `find . -name socket -o -name pipe -exec rm '{}' \;` *search for all files
name `socket` or `pipe` on current dir, and remove all of them.*
* `find . -cmin 30` *search for all files modified on the past 30 min on
current dir.*
* `find /usr -type f -atime +100 -size -5M -user root` *find all regular
files accessed more than 100 days ago, are not bigger tahn 5MB and owned by
`root`.*
* `lastlog` *reports the most recent login of all users of a given user.*
* `user1 ALL=(ALL) NOPASSWD: ALL` *on `sudoers` file gives full root access
to the system without prompting for password.*
* `ls /etc /dvd 2> /tmp/lserror` *list both dirs but redirect errors to
`/tmp/lserror`.*
* `ps -eo pid,nice,cmd | grep top` *show `pid` and `nice` for the `top`
running process.*
* `nice -n +8 top` *run `top` cmd with a lower priority (by 8).*
* `23 8 * * * echo "Hello World" > /dev/pts/0` *in a `crontab` file, this
entry will make the terminal `/dev/pts/0` print the message everyday at
8:23.*
```
[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0
```
* `dnf repoquery --repo "AppStream"` *list all the packages available for a
specific repository.*
* *append* `rd.break` *to the end of the boot cmd, when editing the grub
menu entry, and start it with Ctrl+x.*
* `chroot /sysroot` *make the mounted (read-only) root file system
(`/sysroot`) appear as mounted on `/`.*
* `mount -o remount,rw /` *remount root file system in read/write mode for
the `passwd` cmd to be able to modify the shadow file with a new pwd.*
* `passwd` *change password for the root user.*
* `touch .autorelabel` *create `.autorelabel` file to instruct the OS to
run SELinux relabeling on all files on the next reboot (including the
`shadow` that was updated).*
* `exit` *the `chroot` shell.*
* `reboot` *the system.*
* `linux-firmware`
* `kernel`
* `kernel-core`
* `kernel-headers`
* `kernel-modules`
* `kernel-tools`
* `kernel-tools-libs`
*(If kernel update was previously installed from file, you might need to
download and install `vdo` and `kmod-kvdo` from file too.)*
#### VDO
* `vdo status --name testvdo | grep -i dupl` *check if vdo volume has
deduplication enabled.*
#### LVM
* `vgs`, `pvs`, `lvs` *list `volume groups`, `physical volumes` and `logical
volumes`.*
* `wipefs --all /dev/vdg` *wipe any partition table, fs, RAID signatures from
block device.*
#### Stratis
* `stratis pool create strpool /dev/vdg` *create `strpool` stratis pool using
`/dev/vdg` block device.*
* `stratis pool add-data strpool /dev/vdh` *expand the stratis pool adding
another block device.*
* `du -sc /etc /usr/bin` *show disk usage for each dir and the sum of both.*
* `lsblk -f` *list block devices, show file system type and UUID.*
* `mkdir /local`
* `mount 192.168.0.120:/common /local` *to mount manually.*
* On `/etc/fstab` add: `192.168.0.120:/common /local nfs _netdev 0 0` *to
mount on system startup.*
* `mount | grep local` *to confirm mounting success.*
(If using AutoFS for a sharing, do not mount manually or via `/etc/fstab`!)
* `ssh-keygen -N "" -q` *generate RSA keys without password, on silent mode.*
### SELinux
* `semanage login -l` *show mapping between Linux user and SELinux user.*
* `semanage port -at http_port_t -p tcp 8010` *add port `8010` with type
`http_port_t` and protocol `tcp`, to the policy.*
* `semanage port -d -p tcp 8010` *delete port `8010` with protocol `tcp` from
the policy.*
------