Notes Compiled
Notes Compiled
dnf-config-manager
dnf config-manager --add-repo http://repo.eight.example.com/BaseOS
dnf config-manager --add-repo http://repo.eight.example.com/Appstream
dnf update
or
cd /etc/yum.repos.d/
vim server.repo
[server]
baseurl=http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
NB--> if file path location where the CD/DVD contenets are copied to /rpms folder:-
"baseurl=file:///rpms/BaseOS"
enabled=1
gpgcheck=0
name=rhel8.0
[server1]
baseurl=http://content.example.com/rhel8.0/x86_64/dvd/AppStream
NB--> if file path location where the CD/DVD contenets are copied to /rpms folder:-
"baseurl=file:///rpms/AppStrem"
enabled=1
gpgcheck=0
name=rhel8.0.1
esc
:wq
ip forwarding.
vi /etc/sysctl.conf
net.ipv4.ip_forward=1
umount /dev/sdb
fdisk /dev/sdb
m
n
p
1
+2G
fdisk -l /dev/sdb
pvcreate /dev/sdb1
pvs
mkfs.xfs /dev/mapper/vgpraclvprac
fstab entry
mount -a
lvextend -r
lvextend -L +500M -r /dev/vgprac/lvprac
Thin Volume
VDO
mkfs.xfs -K /dev/mapper/vdo01
udevadm settle
mkdir /mnt/vdo01
mount /dev/mapper/vdo01 /mnt/vdo01/
x-systemd.requires=vdo.service
The -K option in the preceding mkfs.xfs command prevents the unused blocks
in the file system from being discarded immediately which lets the command return
faster
wget 127.0.0.1
vi /var/www/html/index.html
firewall-cmd --get-active-zones
firewall-cmd --list-all
firewall-cmd --zone public --add-service http --permanent
firewall-cmd --zone public --add-service https --permanent
mkdir -p /find/largefiles
vim awesome.sh
if [ "$1" =="me"]; then
echo "Yes I am awesome"
elif ["$1" == "them" ] ; then
echo "They are awesome"
else
echo "Rubbish"
fi
Users
touch /etc/skel/welcome
ls -lhtra /etc/skel/welcome
vim /etc/login.defs
mkdir /home/admins
chown :admingroup /home/admins
setfacl -m g:admingroup:rwx /home/admins
setfacl -m u:root:--- /home/admins
setfacl -m o:--- /home/admins
chown -R :admingroup /home/admins/
chmod g+s /home/admins
note:- [a] – Minute [b] – Hour [c] – Day [d] – Month [e] – Day of the Week
crontab -e -u natasha
*/2 * * * * /usr/bin/logger "EXAM IS IN PROGRESS"
Hard Link
ln logsfileSJ.txt /root/folder1/newhardlink.txt
/etc/passwd
/etc/shadow
/etc/group
/bin/bash
/dev/null
/bin/bash
/sbin/nologin
/etc/sudoers
/etc/profile & etc/bashrc --> umask value
cat /etc/bashrc--> for Umask default value setup
cat /etc/profile
/etc/selinux/config
=======================================================
To enable full sudo access for the user user01, you could create
/etc/sudoers.d/user01
with the following content:
user01 ALL=(ALL) ALL
To enable full sudo access for the group group01, you could create
/etc/sudoers.d/group01
with the following content:
%group01 ALL=(ALL) ALL
example:-
echo "%admin ALL=(ALL) ALL" >> /etc/sudoers.d/admin
USER Removal
=========================================================
• The userdel username command removes the details of username from /etc/passwd,
but
leaves the user's home directory intact.
• The userdel -r username command removes the details of username from /etc/passwd
and also deletes the user's home directory.
CHMOD Command
=====================================================
chmod WhoWhatWhich file|directory
• Who is u, g, o, a (for user, group, other, all)
• What is +, -, = (for add, remove, set exactly)
• Which is r, w, x (for read, write, execute)
chmod -R g+rwX demodir --> change permission of demo directory for group
recursively ( read write and execute)
chmod a+x file2 --> Setting executable permission for ( user & group&Other users)
chmod go-rw file1--> removes the read and write permission for the gropu and other
user permissions
1. Start with 0.
2. If the read permission should be present for this access level, add 4.
3. If the write permission should be present, add 2.
4. If the execute permission should be present, add 1.
CHOWN Command
=====================================================
chown student test_file --> ownership of the test_file file to the student
chown -R sijo softhardlink/ -->user ownership of the folder and the contents are
changed to user sijo
chown -R :ictsupport softhardlink/ --> group ownership of the folder and the
contents are changed to group ictsupport
chown visitor:guests test_dir --> changing the user and group ownership
accordingly
=======================================================
u+s (suid) File executes as the user that owns the file, not the user that ran the
file. No effect.
g+s (sgid) File executes as the group that owns the file.
Files newly created in the directory have their group owner set to
match the group owner of the directory.
o+t (sticky) No effect. Users with write access to the directory can only remove
files that they own; they cannot remove or
force saves to files owned by other users.
umask
umask 007
vi ~/.bashrc
cat /etc/bashrc
cat /etc/profile
•SE Linux.
----------------------
Enforcing
Permissive
Disabled
semanage port -l
ps axZ
ps -ZC httpd
List all port definitions
# semanage port -l
Allow Apache to listen on tcp port 81
# semanage port -a -t http_port_t -p tcp 81
Allow sshd to listen on tcp port 8991
# semanage port -a -t ssh_port_t -p tcp 8991
Question
Open a web browser on workstation and try to view http://servera/index.html.
You will get an error message that says you do not have permission to access the
file.
6. To permit access to the index.html file on servera, SELinux must be configured.
Define
an SELinux file context rule that sets the context type to httpd_sys_content_t for
the
/custom directory and all the files below it.
chmod 711
setsebool -P httpd_enable_homedirs on
Tuning Profile
=======================================================
tuned-adm
tuned-adm profile <available profile from tuned-adm list command> --> sets that
profile.
renice -n 19 3521 --> 3521 (process ID) old priority 15, new priority 19
ps u $(pgrep sha1sum)
ps aux --sort=pcpu
YUM
=======================================================
List installed and available packages by name --- yum list [NAME-PATTERN]
List installed and available groups --- yum group list
Search for a package by keyword --- yum search KEYWORD
Show details of a package --- yum info PACKAGENAME
Install a package --- yum install PACKAGENAME
Install a package group --- yum group install GROUPNAME
Update all packages --- yum update
Remove a package --- yum remove PACKAGENAME
Display transaction history --- yum history
Mounting
=======================================================
lsblk -f ( Shows the UUID also)
Parted
parted /dev/sdb
mklabel ( msdos/gpt)
select the file systems --> parted /dev/vdb help mkpart --> commands shows the
available file systems can be parted.
quit
udevadm settle -->This command waits for the system to detect the new
partition and to create the associated device file under the /dev directory
fstab entry
parted /dev/sdb
mkpart ( crate partition)
quit
mkswap /dev/sdb2
fstab entry
swapon /dev/vdb2
swapon
•SYSTEMCTL
----------------------
systemctl list-units --type=service
systemctl status sshd.service
•LV CRREATION.
udevadm settle
pvcreate /dev/sdc1 /dev/sdc2
mkfs.xfs /dev/srv1vg1/srv1lv1
lsblk -f
vgdisplay srv1vg1
parted /dev/sdc
parted -s /dev/sdc mkpart primary 2148MiB 3218MiB
parted -s /dev/sdc set 3 lvm on
pvcreate /dev/sdc3
vgextend srv1vg1 /dev/sdc3
vgdisplay
vgdisplay srv1vg1
lvdisplay /dev/srv1vg1/srv1lv1
Notes
lvextend -l 128 --> Resize the logical volume to exactly 128 extents in size.
lvextend -l +128 --> Add 128 extents to the current size of the logical volume.
lvextend -L 128M --> Resize the logical volume to exactly 128 MiB.
lvextend -L +128M --> Add 128 MiB to the current size of the logical volume.
lvextend -l +50%FREE --> Add 50 percent of the current free space in the VG to the
LV.
xfs_growfs /root/lvmount
resize2fs /dev/vg01/lv01 also can be used
•STRATIS CREATION Create a stratis volume on the disk which is not used for
partition purpose.Create the stratis filesystem "stratisfs" in the pool
"stratispool"Mount the volume under the directory "/stratisvolume".Put a copy of
the file in "/stratisvolume" which got from the link Create snapshot of "stratisfs"
named as "stratisnap"
lsblk
Deleting
# umount myfs1
# umount myfs1-experiment (if you created it)
# stratis fs destroy mypool myfs1
# stratis fs destroy mypool myfs1-experiment
# stratis pool destroy mypool
stratis pool add-data pool1 /dev/vdc --> add additional block devices to a pool.