RHEL 7 tips and tricks
- Set SElinux to enforcing mode, Persistent across reboot.
- info- SELinux stands for Security-Enhanced Linux. It is a way to improve the server security.The
getenforcecommand returns Enforcing, Permissive, or Disabled. - vim
/etc/selinux/config - set
SELINUX=enforcing - reboot (to make it persistent)
- Confirm that
getenforcereturnsEnforcing
- List all lines which have string
enterfrom/usr/share/dict/wordsfile and copy the lines to/root/words.foundfile.
grep "enter" /usr/share/dict/words >>/root/word.found
- Download file from
"http://classroom.example.com/content/rhcsa/sample.txt"Search lines which contains alpha-numeric words( combination of alphabets and number) and copy those lines is sorted order to/root/samplelinesfile.
grep -Ei "[a-z][0-9]|[0-9][a-z]" sample.txt |sort >>/root/samplelines
- Locate the files of owner
larryand copy to the directory/root/founddirectory
mkdir -p /root/foundfind / -user larry -type f | xargs cp -rp {} /root/found
- Create the user "dax" with uid 4223.
useradd -u 4223 dax
- Compress
/etcfolder withgun ziptechnique under the directory/opt
cd /opttar -cvf etc.tar /etcgzip etc.tar
- Create the SWAP space of "250 MB” dont remove the existing swap.
free -mfdisk /dev/sda#create partition with 250MBmkswap /dev/sda#- make entry in
/etc/fstab mount -aswapon -afree -m
- Create the "LVM" with the name "store" by using 15PE's from the volume group "data". Consider the PE size as "16MB". Mount it on /mnt/store with filesystem vfat.
- Make sure extended partition is already created , if not create it by doing
fdisk,eand select the default options and save it. fdisk /dev/sdawith type LVM and part size +256M (since (16*15) = 240 , +16M(size of each PE))pvcreate /dev/sda#vgcreate -s +16M vgdata /dev/sda#lvcreate -L +240M -n lvdata vgdatamkfs.vfat /dev/vgdata/lvdatamkdir /mnt/stroremake the entry in fstab(to make it persistent)- mount -a (to check if mount details were right)
df -h
- List all lines which have string "enter" from /usr/share/dict/words file and copy the lines to /root/words.found file.
grep enter /usr/share/dict/words > /root/words.found
- Create the "LVM" with the name "slab" of 160MB from the volume group "marvel". Consider the PE size as "8MB". Mount it on /mnt/slab with filesystem xfs. Resize the lvm "/dev/marvel/slab" so that after reboot size should be 320MB.
- use fdisk to create partition of 328M (because we need to resize it to 320M)
pvcreate /dev/sda#vgcreate -s +8M marvel /dev/sda#lvcreate -L +160M -n slab marvelmkfs.xfs /dev/marvel/slab- make the entry in /etc/fstab
lvextend -L +160M /dev/marvel/slab(if it shows no space, add volume using vgextend ) (checklvs)xfs_growfs /dev/marvel/slab(checkdf-h)
- Create a group named "stoogs".A user “curly” and “larry” should belongs to "stoogs" group as a secondary group . A user “moe” should not have access to interactive shell and he should not be a member of "stoogs" group. passwd for all user created should be "jenny".
groupadd stoogsuseradd curlyuseradd larryusermod -aG stoogs curlyusermod -aG stoogs larryuseradd -s /sbin/nologin moepasswd curlypasswd larrypasswd moe
- Create the Directory "/home/manager" with the following characteristics. Group ownership of "/home/manager" should go to "stoogs" group. The directory should be have full permission for all members of "stoogs" group but not to any other users except "root". Files created under "/home/manager" should get the same group ownership is set to the "stoogs" group.
mkdir -p /home/managerusermod -aG stoogs /home/managerchmod 770 /home/managerusermod g+s /home/manager(g+s means that all new files and subdirectories created within the current directory inherit the group ID of the directory)
- Copy the file /etc/fstab to /var/tmp and configure the "ACL" as mention following. The file /var/tmp/fstab is owned by the "root". The file /var/tmp/fstab belongs to the group "root" The file /var/tmp/fstab should not be executable by other's. The user "curly" should able to read and write to the file. The user "larry" can neither read nor write to the file. other users (future and current) shuold be able to read /var/tmp/fstab.
cp /etc/fstab /var/tmp/chown root /var/tmp/fstabchgrp root /var/tmp/fstabsetfacl -m o::r /var/tmp/fstabsetfacl -m u:curly:rw /var/tmp/fstabsetfacl -m u:larry:--- /var/tmp/fstab(without rd/w , we cannot execute a file in linux)