Skip to content

Instantly share code, notes, and snippets.

@atharva-lipare
Last active February 26, 2020 14:31
Show Gist options
  • Save atharva-lipare/c1a457334b875f336e9fa367273d761c to your computer and use it in GitHub Desktop.
Save atharva-lipare/c1a457334b875f336e9fa367273d761c to your computer and use it in GitHub Desktop.
RHCSA exam
note down given IP's and password
@ end of linux16 -> rd.break
ctrl-x
<enter>
mount -o remount,rw /sysroot/
chroot /sysroot
passwd
<given-password>
touch /.autorelabel
ctrl-d
ctrl-d
login:root
<given-password>
systemctl set-default graphical.target
systemctl isolate graphical.target
//login through root and given passwd
setenforce 1
vim /etc/selinux/config
SELINUX=enforcing
Esc:wq
//configure network
//settings button -> ipv4 settings
//enter Address, Netmask, Gateway, DNS
vim /etc/hostname
serverX.example.com
Esc:wq
//download Q.paper
//download kernel using firefox on VM
rpm -ivh Downloads/kernel*
init 6(reboot)
//repo
vim /etc/yum.repos.d/server.repo
[server]
name=server
baseurl=http://content.example.com/rhel7.0/x86_64/dvd
gpgcheck=0
enabled=1
Esc:wq
yum clear all
yum repolist all
yum install authconfig* sssd* autofs* system-config-date* -y
//resize lv to 150M
df -hT
// extend:
lvextend -L 150M /dev/mapper/myvol-vo
resize2fs /dev/mapper/myvol-vo
df -hT
// reduce:
umount /dev/mapper/myvol-vo
fsck.ext4 /dev/mapper/myvol-vo
resize2fs /dev/mapper/myvol-vo 150M
lvreduce -L 150M /dev/mapper/myvol-vo
resize2fs /dev/mapper/myvol-vo
mount -a
df -hT
lsblk
//before adding any partition make extended partition and then make logical partitions
fdisk /dev/vdb
n -> e -> enter(FS) -> enter(LS) -> p -> w
partprobe
lsblk
//make swap of 150M
n -> enter(logical) -> enter(FS) -> +150M -> t -> 82(Linux Swap) -> p -> w
partprobe
mkswap /dev/vdb5
vim /etc/fstab
/dev/vdb5 swap swap defaults 0 0
Esc:wq
swapon -a
swapon -s
free -h
lsblk
df -hT
//create VG of name newvg, vg-extent 32MiB, create LV of name newlv under newvg, with size of 10 extents, with ext4 filesystem and mount on /mnt/newdir
//first make partition of size more than 32*10=320 i.e 500M
fdisk /dev/vdb
n -> enter(logical) -> enter(FS) -> +500M -> t -> 8e(Linux LVM) -> p -> w
partprobe
pvcreate /dev/vdb6
vgcreate -s 32M newvg /dev/vdb6
vgdisplay
lvcreate -l 10 -n newlv newvg
lvdisplay
mkfs.ext4 /dev/newvg/newlv
mkdir /mnt/newdir
vim /etc/fstab
/dev/newvg/newlv /mnt/newdir ext4 defaults 0 0
Esc:wq
mount -a
df -hT
lsblk
init 6
//LDAP
yum install authconfig-gtk* sssd* -y
LDAP search base DN is [dc=networkX,dc=example,dc=com]
LDAP Server is [classroom.example.com]
select check box -> TLS to encrypt connections
Click on download CA certificate
enter given link in text box, eg-> http://classroom.example.com/pub/example-ca.crt -> OK
Change Authentication Method to LDAP password -> Apply
//configure autofs to automount home dir's of LDAP users
//classroom.example.com, NFS-exports /home/guests to your system, whereX is your server Number.
//LDAP userX's home directory is classroom.example.com:/home/guests/ldapuserX
//LdapuserX's home directory should be automounted locally beneath /home as /home/guests/ldapuserX
//home directories must be writable by their users.
yum install autofs* -y
vim /etc/auto.master
/home/guests /etc/auto.ldap
Esc:wq
vim /etc/auto.ldap
ldapuserX -rw,soft,intr,nfsvers=4 classroom.example.com:/home/guests/ldapuserX
Esc:wq
systemctl restart autofs
systemctl enable autofs
//NTP
yum install system-config-date* -y
system-config-date
//delete all existing NTP server
//add classroom.example.com
//advanced options -> select check box -> use local time source
//add users
useradd -s /sbin/nologin <username> //for no access to interactive shell
useradd -G <groupname> -u <uid> <username>
cat /etc/passwd
//add group
groupadd -g <gid> <groupname>
cat /etc/group
//ACL
getfacl <filename>
setfacl -m u:<username>:rwx,g:<groupname>:r-x <filepath>
//file permission
chmod
chown <user>:<group> <filepath>
//cron job
crontab -eu <user>
<minute> <hour> <dayOfMonth(1-31)> <numberOfMonth(1-12)> <dayOfWeek(0-6)> <command>
eg -> The user harry must configure a cron job that runs daily at 14:23 local time and executes - /bin/echo hiya
crontab -eu harry
23 14 * * * /bin/echo hiya
Esc:wq
cat /etc/crontab for crontab format
//grep
grep <string> <filepath>
//find
eg-> find the files which owned by user julia and copy the file into /root/findresults directory
find / -user julia -exec cp -rvf {} /root/findresults \;
//tar
tar -zcvf file.tgz <filepath>
tar -zcvf file.gz <filepath>
tar -jcvf file.bz2 <filepath>
tar -Jcvf file.xz <filepath>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment