RHCSA Exam EX200 Cheat Sheet Part 2

Here’s the RHCSA EX200 cheat sheet part 2. Enjoy:

Software Management

To search a package

yum search package-name

To display info of a package

yum info package-name

To install a package

yum install package-name

To remove a package

yum remove package-name

To list a group of available software

yum grouplist

To install a software group

yum groupinstall "group name"

To remove a software group

yum groupremove "group name"

yum repo config is under /etc/yum.repos.d/

To install a rpm package

rpm -i package-name

To check if the package is previously installed

rpm -qa | grep package-name

To remove a rpm package (no need a full name)

rpm -e package-name

To upgrade a package /w status

rpm -Uvh package-name

To list for the documentation of an installed pacakge

rpm -qd | grep package-name (no need a full name)

To list the config file of an installed package

rpm -qc package name (no need a full name)

To display the info of an installed package

rpm -qi package-name

To display kernel number and release version

uname -r

To install a new kernal

yum install kernel

File System

To refresh the system with new partition

partprobe or partx -a /dev/xxx

To create filesystem

mkfs.ext4 /dev/sdb1

To run a filesystem check

fsck /frv/sdb1

To mount a filesystem:
First create a new directory

mkdir /directory
mount -t ext4 /dev/sdb1 /directory

To unmount

umount /directory

To add a swap space on a new partition
First

mkswap -L NEWSWAP /dev/sdb2
swapon -L NEWSWAP

Then, add an entry on fstab

LABEL=NEWSWAP swap swap defaults 0 0

To setup a user quota
1. Edit fstab,
2. Add usrquota beside defaults
3. mount the partition:

mount -o remount /home

4. Create a userquote file:

quotacheck -cum /home

5. Create username

quota: edquota -u username

6. set a quota:

setquota -u username 30000 35000 0 0 /home

7. Turn on the quota:

quotaon /home

To copy user quota settings

edquota -up username1 username2

To setup a group quota
1. Edit fstab, add grpquota
2. Create a group quota file:

quotacheck -cgm /sales

3. Set a quota:

setquota -g grpname 30000 35000 0 0 /sales

4. Turn on the quota:

quotaon /sales

To view quota usage:

edquota -g sales

To view quota statistic

repquota -ga (for group)
repquota -a (for users)

To create a dump file

dd if=dev/zero of=filename bs=1024 count=25000 (~25MB)

To view an inode

ls -li filename

To create a hard link (cannot cross disk device)

ln filename Desktop/filename-link

To create a symbolic link (can cross disk device)

ln -s /full-path/filename /full-path/filename-link

To setup an ACL
1. Edit fstab,
2. Add acl beside defaults
To view acl:

getfacl /directory

to set acl:

setfacl -m u:username:x /home/directory/

to remove acl:

setfacl -x u:username: /home/directory/

LVM

PV(/dev/sda) –> VG –> LV –> directory

Create PV change system ID to LVM (8e) under fdisk

pvcreate /dev/sdb1

To check PV: pvs or pvdisplay

create VG vgcreate vg-name /dev/sdb1 /dev/sdb2

To check VG: vgs or vgdisplay

create LV lvcreate -L 800M -n lv-name vg-name

To check LV: lvs or lvdisplay

create filesystem mkfs.ext4 /dev/vg-name/lv-name

Increase size

resize LV lvresize -L 900M /dev/vg-name/lv-name
resize filesystem resize2fs /dev/vg-name/lv-name

Shrink size
1. unmount the volume first
2. run filecheck fsck -f /dev/vg-name/lv-name

resize filesystem resize2fs /dev/vg-name/lv-name 800M
resize LV lvresize -L 800M /dev/vg-name/lv-name

Snapshot
1. Create a directory for snapshot
2. Create a snapshot of 100M on LV

lvcreate -L 100M -s -n lvmsnapshot /dev/vg-name/lv-name

3. mount the snapshot to retrieve file

mount -t ext4 /dev/vg-name/lvmsnapshot /directoy

delete snapshot:

lvmremove /dev/vg-name/lvmsnapshot

GUI tool for LVM

yum install system-config-lvm
Advertisements