RHCSA Cheat Sheet 2
RHCSA Cheat Sheet 2
RHCSA Cheat Sheet 2
Archive, compress, unpack, and uncompress files using tar, star, gzip, and bzip2
gzip big.jpg
bzip2 big.jpg
gzip -d big.jpg.gz
bzip2 -d big.jpg.bz2
tar czvf home.tar.gz /home
tar xzvf home.tar.gz /home
yum install star
star -xattr -H=exustar -c -f=home.star /home/
star -x -f=home.star
chmod 777
chmod g+s
chmod g+t
Locate, read, and use system documentation including man, info, and files in
/usr/share/doc
man -k [_selinux |command]
appropos [command]
ls /usr/share/doc | grep [command]
List, create, delete, and set partition type for primary, extended, and logical
partitions
fdisk -l
fdisk /dev/XXX
*Remember* 4th partition must ALWAYS be extended
82/83 SWAP/8e LVM
Create and remove physical volumes, assign physical volumes to volume groups, and
create and delete logical Volumes
pvcreate /dev/XXXX
vgcreate VGNAME PVNAME
vgextend VGNAME PVNAME
lvcreate -n NAME -l %FREE [-L 50G] VGNAME
lvextend LVNAME VGNAME
lvremove
vgremove
pvremove
Create and configure LUKS-encrypted partitions and logical volumes to prompt for
password and mount a decrypted file system at boot
Requires dm_crypt: lsmod grep dm_crypt ; modprobe dm_crypt
vim /etc/rc.init
yum install cryptsetup-luks
Create partition
fdisk /dev/xx
Encrypt partition
cryptsetup luksFormat /dev/xx
Open it
cryptsetup luksOpen /dev/xx /newname
Check in /dev/mapper
ls /dev/mapper/newname
Format it
mkfs.ext[3|4] /dev/mapper/newname
Add it to crypttab
vi /etc/crypttab
newname /dev/xxx (NOTE: PARTITION NOT DEV MAPPER)
Create a directory
mkdir /mnt/newname_dir
Edit fstab
vi /etc/fstab
/dev/mapper/newname /newname_dir ext4 defaults
Mount -a
REMEMBER:
You are adding the name you assigned with luksOpen to crypttab and linking it
to the encrypted partition.
You are adding the same to fstab with a preceeding /dev/mapper and linking it
to the mount point in fstab.
--with UUID--
blkid /dev/xx: UUID=xxxx (again, PARTITION)
fstab
UUID=xxxxx /newname_dir ext4 defaults
mount -a
Add new partitions and logical volumes, and swap to a system non-destructively
Unmount the partition or LV to be expanded.
Add the new PV, extend the vg
vgextend VG PV
Extend the unmounted LV
lvextend -L [AMOUNT]G lv
Resize
resize2fs lv
resize2fs lv specifiedsize : e.g. resize2fs /dev/vg1/lv1 2G
Remount
Create, mount, unmount, and use ext2, ext3, and ext4 file systems
mkfs.ext[2|3|4] /dev/XXXX (for LVM: /dev/mapper/vg-lv)
mkswap
mount
umount
NFS
showmount -e instructor.example.com
mkdir /mountpoint
mount instructor.example.com:/exported/path /mountpoint
(remember you can browse via /net)
OR
mount —o rw -t nfs /server:/exported/path /mountpoint
Persistence:
server:/path /mountpoint nfs option(defaults) 0 0
CIFS
smbclient (samba-client package MUST be installed)
smbclient -L cifsserver.domain
mkdir /mountpoint
Automount:
vim /etc/fstab
make sure autofs is running
find the path in /net and validate
/etc/auto.demo
public -ro nfsserver.domain:/exported/path
Restart autofs
For home directories:
/etc/auto.master
/home/guests /etc/auto.ldap
/etc/auto.ldap
* -rw instructor.exaple.com:/home/guests/&
getfacl
setfacl -m(odify) u:g:o
eg setfacl -m u:ruth:rwx file.txt or setfacl -m g:webteam:rwx file.txt
setfacle -m u:user rw filename
setfacl -x u:user (removes all acls for that user)
setfacl -m o::- filename (changes other permissions)
system-config-network
IPADDR=xxx.xxx.xxx.xxx
NM_CONTROLLED=no
BOOTPROTO=[dhcp|static]
/etc/init.d/networkmanager stop
chkconfig /etc/init.d/networkmanager off
Set a secondary IP
Add an eth0:0 file with just the above.
If needed:
Gateway=host.machine.ip
Netmask=255.255.255.0
id:5:initdefault:
vim /etc/sysconfig/iptables
iptables -I INPUT 5 -p tcp -m tcp --dport 20 -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 21 -j ACCEPT
iptables save
Install and update software packages from Red Hat Network, a remote repository, or
from the local file system
yum / rpm
vim /etc/yum.repos.d/
[name]
name=Whatever Name
baseurl=http://instructor.example.com/repo/
enabled=1
(REMEMBER THE TRAILING /)
Kernel Packages
/lib/modules/VERSION/
lsmod
modprobe {modulename}
modinfo (shows parameters that module supports)
/etc/modprobe.d/local.conf
Modify the system bootloader
vim /boot/grub/grub.conf
Change passwords and adjust password aging for local user accounts
chage
Configure a system to use an existing LDAP directory service for user and group
information
system-config-authentication
dc=example,dc=com