Monday, August 17, 2015

RHCSA Notes (Work in Progress) RHEL 7 EX200

Wanted a place to store my RHCSA Notes.  This is from a test from the book:  "RHCSA & RHCE Red Hat Enterprise Linux 7: Training and Exam Preparation Guide (EX200 and EX300), Third Edition" http://amzn.to/1K2Yg14 (Kindle) / http://amzn.to/1WAsvl0 (Paperback).  I've been very happy with the book.

Q: Reset root password
A: Stop boot process
-edit line with vmlinz
-append init=/sysroot/bin/sh
-control+x to boot
-chroot /sysroot
-mount -o remount, rw /
-passwd
-touch /.autorelabel
-exit
-reboot

Q: Set specific IP
A: Edit /etc/sysconfic/network-scripts/ifcfg-xxx
-IPADDR=xxx.xxx.xxx.xxx
-PREFIX=xx
-GATEWAY=xxx.xxx.xxx.xxx
-DNS1=xxx.xxx.xxx.xxx
-onboot=yes
-BOOTPROTO=static
-edit /etc/sysconfig/network
-HOSTNAME=xxx
-GATEWAY=xxx.xxx.xxx.xxx
-edit /etc/resolv.conf
-DNS1=xxx.xxx.xxx.xxx
-systemctl disable NetworkManager
-systemctl stop NetworkManager
-systemctl restart network

Q: Set default boot target to multiuser
A: -systemctl get-default (shows current)
-systemctl set-default multi-user.target
-systemctl —t target (shows target)
-systemctl isolate multi-user.target (like init 5)

Q: Set SELinux to enforcing
A: -edit /etc/sysconfig/selinux
-SELINUX=enforcing

Q: search for “then” in /etc/profile and save results to /var/tmp/pattern.txt, no empty lines
A: grep then /etc/profile 2>/dev/null | tee -a /var/tmp/pattern.txt

Q: Modify the command prompt to be hostname, username, pwd
A: export PS1=“<$LOGNAME@$HOSTNAME:\$PWD>”

Q: Create users: barry, harry, larry, mary, gary w/ home directories in home
-Passwd: Temp123$
-Mary/Barry expire Dec 31 2017
-Larry/Gary 2nd group dba, create it not there

Q: Create a directory in mary’s home directory called testdir2 and set default ACLs on it so barry can read and write to that folder. 
A:  -First you need to give barry rx to mary’s home directory.  
-chmod -R 705 /home/mary
-setfacl -m d:u:barry:rw testdir2
-verify with getfacl testdir2
-su - barry
-cd /home/mary/testdir2
-Note: doesn’t work if you use setfacl-m u:barry:rw testdir2

Q: Setup yum repo using ftp
A: -yum install vsftpd
-systemctl enable vsftpd
-systemctl restart vsftpd
-mkdir /var/ftp/pub/rhel7
-cp /cd /var/ftp//pub/rhel7
-Create ftp.repo in /etc/yum.repo.d/
-[ftp] name=ftp repo baseurl=ftp://x.x.x.x/rhel7 
-Might have to change permissions on directory to 755 if it can’t be read
-Also test ftp by going to address in firefox

Q: Create a logical volume called linuxadm of size equal to 10 LEs in vgtest volume group (create vgtest with PE size 32MB) with mount point /mnt/ linuxadm and xfs file system structures. Create a file called linuxadmfile in the mount point. Set the file system to automatically mount at each system reboot.
A: -lsblk shows the current structure

Create group folder all new files must be created with set group
A: chmod g+s dir

Q: Create a logical volume called linuxadm of size equal to 10 LEs in vgtest volume group (create vgtest with PE size 32MB) with mount point /mnt/ linuxadm and xfs file system structures. Create a file called linuxadmfile in the mount point. Set the file system to automatically mount at each system reboot.

A: fidsk /device
n for new partition
t for the new type which is 8e
w to write the partition
either reboot or type part probe

lsblk
pvcreate /dev/***
pvs
when creating volume group set the extent size
vgcreate -s 8m vgname /dev/*** (Sets the physical extents)
lvcreate -l 8 (lowercase l sets extents)
lvcreate -L 10M (capital L sets in MB/GB)
Full Command:
lvcreate -l —name lv_name vg_name
mkfs.filesystem /dev/mount point

Q: Add swap 50MB
lvcreate -L 50M lv_swap vgtest
lvdisplay
mkswap /dev/vgtest/lv_swap
swapon /dev/vgtest/lv_swap
swapon -s

*to show all UUID run blkid
*find specific UUID blkid “lvm path”

Q: increase size by 45MB
A: lvresize -L+45M -r /dev/mapper/name

Q: change the hostname to rhcsa
A: hostnamectl set-hostname rhcsa

—Test2——
Q: Create a user account called jerry with UID 2929 and shell /bin/ tcsh. Create a user account called terry without login access. Create another user account called mary with all the default values. Set their passwords to Temp123 $.
A:  useradd -u 2929 -s /bin/tcsh jerry
-useradd terry -s /bin/false
-useradd mary
-passwd jerry; passwd terry; passwd mary

Q: Create a file called testfile as user jerry in his home directory and give user mary read and execute rights, and user terry no permissions at all. Make sure that existing rights on the file are unaltered.
A: cd /home/jerry/
-chmod o+rx /home/jerry/
-setfacl -m u:mary:rw testfile
-setfacl -m u:terry:--- testfile
-su - mary 
-more /home/jerry/testfile

Q: Create a directory called /testdir1 as root and configure it for collaboration among members of the admins group. Create the group with members jerry and terry.
A: mkdir -p /testdir1
-groupadd admins
-usermod -g admins jerry
-usermod -g admins terry
-chgrp admins /testdir1/
-chmod g+ws /testdir1/

Q: Set permissions on /linuxadm so that all files created underneath get the membership of the parent group.
A: chmod g+s /linuxadm

Q:Create a logical volume lvol1 of size 100MB in vg02 volume group with mount point /mnt/ lvol1 and ext4 file system structures. Create a file called lvolfile in the mount point. (Help)
A: fidsk /device
-n for new partition
-t for the new type which is 8e
-w to write the partition
-either reboot or type part probe

-pvcreate /dev/sda3
-vgcreate vg02 /dev/sda3
-lvcreate --name lvol1 -L 100M vg02
-mkfs.ext4 /dev/vg02/lvol1
-mkdir -p /mnt/lvol1
-vim /etc/fstab
/dev/vg02/lvol1 /mnt/lvol1 ext4 defaults 0 0
-mount -a
-touch /mnt/lvol1/lvolfile

Q: Create a swap logical volume called swapvol1 of size equal to 12 LEs in vg02 volume group, and activate it persistently.s
A: -lvcreate -l 12 --name swapvol1 vg02
-mkswap /dev/vg02/swapvol1
-swapon /dev/vg02/swapvol1
-vim /etc/fstab
/dev/vg02/swapvol1 swap swap defaults 0 0

Q: Search for all files in the entire directory structure that have been modified in the past 30 days and save their copies in /var/ tmp/ modfiles.txt.
A: find / -mtime 0 | tee -a /var/tmp/modifies.txt
A: find / -mtime 0 > /var/tmp/modifies.txt

Q: If you wanted to copy the files in stead of just save their location
A:  find / -mtime 0 -exec cp '{}' /destfolder/ \;

Q: Change the default base home directory for new users to /usr.
A: - vim /etc/default/useradd
-change HOME= to /usr

Q: Enable cron access for user jerry and deny for user terry.
A: -Add terry to /etc/cron.deny

Q: Set up a cron job as user mary to display the output of the /usr/ local directory at 15: 35 every day.
A: -vim /etc/crontab
-35 15 * * * mary ls -la /usr/local

Q: Upgrade the kernel to a higher version and set it as the default boot kernel. The existing kernel and its configuration must remain intact. 
A: -wget “download path”
-rpm -ivh “package”

Q: Configure the system as an NTP client of server hv2 
A: -vim /etc/ntp.conf
-make sure service it enabled and started

Q: Set up a FTP yum repository in the /var/ ftp/ pub/ rhel7 directory on hv2, and configure a repo on rhcsa2.
A:  - [FTP]
name=FTP Yum

gpgcheck=0

Also if I needed to setup authentication I would switch to the gui and install authconfig-gtk.x86_64.

ShareThis