Exam preps Rhcsa 6 Flashcards
password recovery
- Edit GRUB2 boot menu
Start your system and once you see your GRUB2 boot menu use e key to edit your default boot item.
Move your cursor ( HINT: move to end of the line with CTRL+E ) on rhgb quiet keywords and replace them with init=/bin/bash
Once you edit the boot line as show above press CTRL + x to start booting your RHEL 7 system into a single mode. At the end of the system boot you will enter a single mode: - Read&Write root partition remount
Once you enter a single your root partition is mounted as Read Only ro. You ca confirm it with the following command:
# mount | grep root
In order to mount our partition with Read/Write flag we use mount with a remount option as follows:
# mount -o remount,rw /
Next, confirm that the root file system is mounted Read/Write rw:
# mount | grep root
3. Change root's password Still in the single mode we can proceed with the actual root password recovery. To do this we use passwd command: # passwd
4. SELinux relabeling The additional step which needs to be taken on SELinux enables Linux system is to relabel SELinux context. If this step is ommited you will not be able to login with your new root password. The following command will ensure that the SELinux context for entire system is relabeled after reboot: # touch /.autorelabel
5. Reboot System The final step when resetting your lost root password on RHEL 7 linux system is to reboot. This can be done with a following command: # exec /sbin/init
create yum client base url
#vi /etc/yum.repos.d/Server.repo [Server] name=Server baseurl=ftp://instructor.example.com/pub/rhel6/dvd/Server enabled=1 gpgcheck=0 \:wq #init 6 to reboot After reboot check connectivity with Server #ping 192.168.0.254 #nslookup instructor.example.com #yum list #yum clean all #yum repolist
LVM ReduceResize your LVM /home to 150MB will range to (130M-160M)
#df -h #lvdisplay ***check the lvm partition*** #umount /home #lvdisplay ****check the name of lvm*** #e2fsck -f /dev/vgsrv/home #resize2fs /dev/vgsrv/home 150M #lvreduce -L 150M /dev/vgsrv/home #df -h **** You will not find the partition**** #mount /dev/vgsrv/home /home #df -h
LVM ExtendResize your LVM /home to 250 will range to (230M-260M)
#lvextend -L 250M /dev/vgsrv/home #resize2fs /dev/vgsrv/home #df -h
LDAPExampleConfigure an ldap client, where your ldap server is instructor.example.comLDAP Base DN: (dc=example,dc=com).Authenticate your ldap server using the certificate(ftp://instructor.example.com/pub/EXAMPLE-CA=CERT)You should be able to login as ldapuserX via LDAP. This configuration must be persistant after restart. You will get the home directory only after solving automount question.
#yum groupinstall directory-client #system-config-authentication Note: dialog box will open in that Enter details User Account Dattabase = LDAP LDAP Search Base DN = dc=example,dc=com LDAP Server = ldap://instructor.example.com Check mark TLS and then click download certificate and give the path ftp://instructor.example.com/pub/EXAMPLE-CA-CERT authentication Method = LDAP Apply the setting Check LDAP #getent passwd ldapuserX #su ldapuserX $exit
NTP, configure your NTP server as instructor.example.com
#system-config-date check mark Synchronize date and time over network. Remove all the NTP SERVER and click ADD and type Instructor.example.com Press Enter and press OK
Automount LDAPConfigure automount in such a way that the ldapuserX’s home directory in instructor.example.com:/home/guests/ldapuserX should be mounted as local directory /home/guests/ldapuserX when ldapuserX logs in. This configuration must be persistant after restart password for ldapuser is “password”
#rpm -qa autofs #vim /etc/auto.master Below /misc add the line/home/guests /etc/auto.misc:wq #vim /etc/auto.misc Below CD line OR end of the script add the line:ldapuserX -rw,soft,intr instructor.example.com:/home/guests/ldapuserX \:wq! #service autofs stop #service autofs start #su - ldapuserX #df -h
Kernel Installation update Install new kernel from UDATE dir on Server. boot the system with the new kernel
#yum install lftp #lftp 192.168.0.254 ~>cd pub~ >cd UPDATE ~>mget *kern* ~> bye #ls #rpm -ivh kern[+TAB] #vi /etc/grub.conf Check the position of the new kernel if it is 1st position then defaults=0 if it is in 2nd position, the default=1
Create a cron job which will run everyday at 1:30 for user harry
crontab -e -u harry30 1 * * * /bin/ech “hiya”
Findlocate all files owned by user susan & copy them to /home/lost+found/
#find / -user susan -exec cp -vp {} /home/lost+found/ \; #cd /home/lost+found #ls
grepSearch for the text ‘strato’ in the file /usr/share/dict/words & copy this file to a file /root/lines.txt. The new file should not have any blank spaces or lines.The order of the names in the new file should be same as the order in which it appears in the original file
#grep strator /usr/share/dict/words > /root/lines.txt #cat /root/lines.txt to verify
LVMCreate a logical volume wshare from the volume group wgroupThe volume group should have extents of size 8MiB. The logical volume should have 50 extents. Mount this lvm as /mnt/lvm
#fdisk /dev/vda (set an lvm partition to 500M #partx -a /dev/vda #pvcreate /dev/vda6 #vgcreate -s 8M wgroup /dev/vda6 #vgdisplay wgroup #lvcreate -l 50 -n wshare wgroup #lvdisplay /dev/wgroup/wshare #mkfs.ext4 /dev/wgroup/wshare note use the right format based on the question#mkdir /mnt/lvm #vi /etc/fstab/dev/wgroup/wshare /mnt/lvm ext4 defaults 0 0 #mount -a #df -h #init 6
Set up a default configuration FTP server.Block ftp connections from hackers.net
# yum install vsftpd # chkconfig vsftpd on # service vsftpd start # vi /etc/sysconfig/iptables-configIPTABLES_MODULES=”nf_conntrack_ftp nf_nat_ftp” # iptables -I INPUT -m state –state NEW -m tcp -p tcp –dport 20 -j ACCEPT # iptables -I INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT # service iptables save# service iptables restart # vi /etc/hosts.denyvsftpd: .hackers.net: DENY
expire user’s account in one week
# date -d “+1week” # usermod -e YYYY-MM-DD bob
or # chage -E YYYY-MM-DD bob # chage -l bob
Set up a default configuration webserver. In the index file, place the sentence “This is a test.”.Make this webserver only accessible to your machine and server1.example.com.
# yum install httpd # chkconfig httpd on # service httpd startecho “This is a test.″ > /var/www/html/index.html # iptables -I INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT # service iptables save # vi /etc/httpd/conf/httpd.confOrder allow,deny Allow from 127.0.0.1 server1.example.com # service httpd reload