Linux 1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 28

Linux® is an open source operating system (OS).

An operating system is the


software that directly manages a system’s hardware and resources, like CPU,
memory, and storage. The OS sits between applications and hardware and makes the
connections between all of your software and the physical resources that do the
work.

Think about an OS like a car engine. An engine can run on its own, but it becomes a
functional car when it’s connected with a transmission, axles, and wheels.
Without the engine running properly, the rest of the car won’t work.

The Linux® kernel is the main component of a Linux operating system (OS) and is
the core interface between a computer’s hardware and its processes. It
communicates between the 2, managing resources as efficiently as possible.

The kernel is so named because—like a seed inside a hard shell—it exists within
the OS and controls all the major functions of the hardware, whether it’s a
phone, laptop, server, or any other kind of computer.

What the kernel does


The kernel has 4 jobs:

1. Memory management: Keep track of how much memory is used to store what, and
where
2. Process management: Determine which processes can use the central processing
unit (CPU), when, and for how long
3. Device drivers: Act as mediator/interpreter between the hardware and processes
4. System calls and security: Receive requests for service from the processes

Where the kernel fits within the OS


To put the kernel in context, you can think of a Linux machine as having 3 layers:

1. The hardware: The physical machine—the bottom or base of the system, made up
of memory (RAM) and the processor or central processing unit (CPU), as well as
input/output (I/O) devices such as storage, networking, and graphics. The CPU
performs computations and reads from, and writes to, memory.

2. The Linux kernel: The core of the OS. (See? It’s right in the middle.) It’s
software residing in memory that tells the CPU what to do.

3. User processes: These are the running programs that the kernel manages. User
processes are what collectively make up user space. User processes are also known
as just processes. The kernel also allows these processes and servers to
communicate with each other (known as inter-process communication, or IPC).

Create an account in redhat.com


Go to https://developers.redhat.com -- login -- Download RHEL
Install RHEL and Register

Prof. Andrew Tanenbaum ===> Minix [ a miniature version of Unix ]


Linus Torvalds ==> Developed a Kernel and named it as Linux .. uploaded in internet
... community..known
as the "Father of Linux"
Linux kernel is open source.
Linux is a kernel

Kernel ==> It is the core/heart of any OS. It can interact with the system H/W
directly.
What is the kernel file name? Where does kernel reside?
vmlinuz is the name and it resides with the /boot directory
How to see the kernel version? uname -r
Kernel interacts with system H/W using System Calls (are some special 'C'
functions)
eg. ioctl(), fork() rtc.

Shell ==> is a utility program which acts as an interface between the user and the
kernel. User processes
would be running here.
Shell also works as an interpreter which translates human language to machine
language and vice versa.

The default shell in Unix ==> Bourne shell (sh)


The default shell in Linux ==> Bourne Again Shell (bash)
Other Shells ==> Korn Shell (ksh), C Shell (csh)
Available shells can be found in ==> /etc/shells

Unix variants ==> SCO Unix / IBM AIX / HP-UX / Oracle Solaris

Windows vs. Linux


-----------------
1. Windows is proprietory and Linux is Open Source
2. Windows is case sensitive but Linux is 100% case sensitive
3. In Windows the superuser is Administrator but in Unix and Linux, it is root
4. We do use backslash(\) while defining path of a file, but in Linux it is
frontslash(/)
5. Normal user/Administrator ==> c:\ , in Linux for root ==> # and for normal
users ==> $
6. Linux has single-rooted diectory structure but windows has multi-rooted
directory structure

---------------------------------------------------
Linux Distribution ==> Kernel + GNU Utils + Shell
Distributions ==> Slackware / Oracle Linux / Suse Linux / Ubuntu / CentOS /
Fedora / RHEL
Redhat ==> Redhat Linux [ FREE ] --> 4 / 5 / 6 / 7 / 8 / 9
Enterprise Distribution ==> RHEL [ Redhat Enterprise Linux ] --> RHEL8
Community Distribution ==> Fedora / CentOS

Linux Commands
-------------
1. Create a user and assign a password
useradd student
passwd student

2. To switch to a particular user ==> su [ Switch User ]


su student [ It will only switch the UID but not the home directory ]
su - student [ Will change the UID and the Home directory ]

Note: By default, root user will have home directory as /root and non-root users
will have home directory
within /home

3. To list the files/directories ==> ls


ls -l [ long listing ]
4. To display the current working directory ==> pwd

5. To change to a directory ==> cd <dir_name>


To go to the home directory => cd OR cd ~

6. Symbolic representations ==>


. ==> Current Directory
.. ==> Parent Directory
../.. ==> Parent to Parent directory
- ==> Previous directory

7. Shell commands have 3 basic parts - Command to run / Options to adjust the
command behavior / Arguments
ls -l /tmp

8. cal ==> to display the calender


cal 2020
cal 12 2020

9. To redirect the output of a command to a file => ls -l /boot > boot.txt

10. mkdir => To create a directory


mkdir database
cd database
mkdir oracle
mkdir mssql
mkdir {oracle,mssql}
mkdir database/{oracle,mssql}
mkdir -p database/{oracle,mssql}

Path ==> Absolute Path and Relative Path


/home/student/database/oracle/ora.txt ==> Absolute Path
database/oracle/ora.txt ==> Relative Path

rmdir ==> To remove an empty directory


rm -rf ==> To remove a directory along with the contents

11. Create files ==>


touch ==> to create empty file
touch file1 file2 file3 OR touch file{1..3} touch file{1..3}.mp3
touch file{1..3}.{mp3,txt}
cat > file1
hello
<ctrl> + d

cat file1 ==> To display the content of the file


>> => Append
cat file1 >> file2 ==> Content of file1 would be appended to file2

12. Copy ==> cp


Move ==> mv

13. logout / exit ==> To logout from the system

Lab: Create a directory structure along with some file in it


------------------------------------------------------------
mkdir database
cd database
mkdir mysql
mkdir oracle
OR
mkdir -p database/{mysql,oracle}
mkdir database/mysql/{dir1,dir2}
mkdir database/oracle/dir3
touch database/mysql/dir1/file{1..3}
touch database/mysql/dir2/file4
cp database/mysql/dir1/file1 database/oracle/dir3
mv database/mysql/dir1/file3 database/oracle/dir3

ls -lR database

To display the directory structure in tree format ==> tree


yum install tree

================================================================
14. who ==> To list the currently logged-in users
who am i / whoami ==> To list the current user only
15. history ==> To list all commands which we have executed
!NO ==> To recall a command from hsitory
history -c ==> To clear the history
history -d NO ==> To delete a specific command from history
To display the value of HISTSIZE Environment variable ==> echo $HISTSIZE
To set a custom value for HISTSIZE variable ==> HISTSIZE=100

16. Word Count ==> wc


wc /etc/passwd ==> Displays no. of lines/words/characters within /etc/passwd
file
wc -l /etc/passwd ==> Lines
wc -w /etc/passwd ==> Words
wc -c /etc/passwd ==> Characters
wc -lc /etc/passwd ==> Lines+Characters

17. Help commands in Linux ==> man / info / pinfo


man ls
pinfo is more advanced than the original info command. It provides a browser-
like functionality where in
we can browse options using hyperlinks. eg. pinfo tar
To get the man pages section ==> yum install man-pages
man -k passwd
man 5 passwd ==> This will take us to the 5th section of the passwd manual
page

18. Linux Editors ==> vi [ Visual Editor ]==> Default editor of Unix
vim [ Visual Improved ] ==> Default editor of Linux
nano => simple editor just like notepad
gedit => Graphical Editor
gvim => Graphical version of vim

vi / vim commands==>
-------------------
i => Insert Mode
a => Append Mode
x => To delete a single character
dd => To delete a line
2 yy(yank) p => Copies 2 lines and paste
2 dd p => Deletes 2 lines and paste
o => To insert a line below
O => To insert a line above
u => Undo the last operation
/expression => To search for an expression
:nohl => To remove highlights
:wq => To save and Quit
:w! => Save without Quit
:q! => Quit without Save
:se nu => To display the line numbers
:set nonumber => To remove the line numbers
Find and Replace ==> :%s/linux/RHEL/g ==> It will replace all occurances of
linux by RHEL

Visual Modes of vim ==>


a. Character Mode - v
b. Line Mode - V
c. Block Mode - <CTRL>+v

19. Linux Filesystem Hierarchy -> All files in Linux system are stored on file
systems, which are organized into
a single inverted tree of directories known as file-system hierarchy.

==> which command displays the path of a Binary File

Linux has a single-rooted, inverted tree like structure.

7 Fundamental File types : file command displays the type of a file


--------------------------
a. Ordinary File : Text file / Program file / Binary file / Audio..Video file
Represented by ==> '-'
b. Directory file : Represented by 'd'
c. Device file : Character Device file ==> Represented by 'c'
d. Device file : Block Device file ==> Represented by 'b'
e. Symbolic Link : Represented by 'l'. We can create symbolic link file using ln
-s command
f. Socket file : Represented by 's'
g. Name Pipe : Represented by 'p'

Note : In RHEL7, 2 popular display managers are available - GNOME and KDE. The
default desktop
environment in RHEL8 is provided by "Wayland"

Default Graphical Framework till RHEL7 ==> "X WIndow System"


Default Graphical Framework in RHEL8 ==> "Wayland"

==========================================
System Initialization / Booting Sequence
==========================================
Red Hat Enterprise Linux 8 Boot Process
1. The machine is powered on. The system firmware, either modern UEFI or older
BIOS, runs a Power On Self Test (POST) and starts to initialize some of the
hardware.

2.The system firmware searches for a bootable device, either configured in the UEFI
boot firmware or by searching for a Master Boot Record (MBR) on all disks, in the
order configured in the BIOS.
3. The system firmware reads a boot loader from disk and then passes control of the
system to the boot loader. On a Red Hat Enterprise Linux 8 system, the boot loader
is the GRand Unified Bootloader version 2 (GRUB2).

4. GRUB2 loads its configuration from the /boot/grub2/grub.cfg file and displays a
menu where you can select which kernel to boot.

5. After you select a kernel, or the timeout expires, the boot loader loads the
kernel and initramfs from disk and places them in memory. An initramfs is an
archive containing the kernel modules for all the hardware required at boot,
initialization scripts, and more. On Red Hat Enterprise Linux 8, the initramfs
contains an entire usable system by itself.
6. The boot loader hands control over to the kernel, passing in any options
specified on the kernel command line in the boot loader, and the location of the
initramfs in memory.

7. The kernel initializes all hardware for which it can find a driver in the
initramfs, then executes /sbin/init from the initramfs as PID 1. On Red Hat
Enterprise Linux 8, /sbin/init is a link to systemd.

8. The systemd instance from the initramfs executes all units for the initrd.target
target. This includes mounting the root file system on disk on to the /sysroot
directory.

Configured using /etc/fstab

9. systemd looks for a default target, either passed in from the kernel command
line or configured on the system.

------------------------------------
Repairing File System Issues at Boot
====================================
The following table lists some common errors and their results::
-----------------------------------------------------------------------------------
--------------------------------------------------
Problem Result
-----------------------------------------------------------------------------------
--------------------------------------------------
Corrupt file system----------------------------------> systemd attempts to repair
the file system. If the problem is too severe for an
automatic fix, the system
drops the user to an emergency shell.
Nonexistent device or UUID referenced in /etc/fstab --> systemd waits for a set
amount of time, waiting for the device to become available
If the device does not become available, the system drops the user to an emergency
shell after the timeout.
Nonexistent mount point in /etc/fstab-----------------> The system drops the user
to an emergency shell.
Incorrect mount option specified in /etc/fstab--------> The system drops the user
to an emergency shell.

In all cases, administrators can also use the emergency target to diagnose and fix
the issue, because no file systems are mounted before the emergency shell is
displayed.

===============================================
User and Group Administration ==>
===============================================
a. A user account is used to provide security boundary for a specifc user
b. 3 main types of user accounts - superuser [ Privileged user ], system users
and regular
users [non-privileged users]
The name of superuser is root and the it has UID 0
Users do NOT interactively login using system user accounts
c. id command can be used to display user information
d. Every user is assigned a unique UID by the OS
e. To create a user ==> useradd <username>
By default, system uses the /etc/passwd file to store user information.
Each line in /etc/passwd file contains information about one user and it
contains 7 fields
separated by ':'
username:password(x):UID:GID:GECOS Field:Home Directory:Login Shell

Group ==> is collection of users.


a. Each group will have a unique GID. root users has default GID 0
b. Group information is stored in /etc/group file
groupadd sysadmin
c. Each line in /etc/group file contains information about one group
groupname:group_password(x):group_id:list_of_group_members

d. userdel <username> ==> deletes a user account but home directory still
exists
usrdel -r <username> ==> deletes a user account along with the home
directory
e. usermod -c "DevOps Enginner" sarah
f. User password are stored in a file called /etc/shadow
g. How to Lock a user account?
usermod -L(Lock) <username>
usermod -U(Unlock) <username>
g. UID Ranges :
UID 0 is reserved for root user
UID 1-200 is a range of "system users" assigned statically to system
processes by Redhat
UID 201-999 is a range of "system users" used by system processes that
do not own files in the
filesystem.
UID 1000+ is the range of "regular users"
h. User and group specific default values are stored in /etc/login.defs

Primary Group and Secondary Group


--------------------------------
a. Whenever we create a user in Linux, a group is also created automatically in
the same name of that user.
One user can have only one Primary Group but can have multiple Secondary
Group(s)

head => It dislays first 10 lines of a file


head -n 5 => 5 lines
tail => It dislays last 10 lines of a file
tail -n 5 => 5 lines

b. root has a reserved GID as 0


c. Create a group with a specifc group id ==> groupadd -g 10001 hr
d. groupdel and groupmod commands are there like userdel and usermod
e. Secondary Group assignment ==> usermod -G <group_name> <user_name> [ -G is
for secondary group ]
Primary Group assignment ==> usermod -g <group_name> <user_name> [ -g is
for primary group ]
Lab :
1. Create a group called sysadmin
groupadd sysadmin
2. Create 2 users called john and jane. Set the password to redhat for both
users.
useradd john
useradd jane
passwd john
passwd jane
3. john user should have real name as "Cloud Architect" and a default shell
as /bin/bash
usermod -c "Cloud Architect" john
4. jane user should have real name as "Automation Engineer" and a default
shell as /bin/sh
usermod -c "Automation Engineer" jane
5. sysadmin should be the secondary group for john and jane
usermod -G sysadmin john
usermod -G sysadmin jane
6. Create a user called cloud-user with a UID 5001. This user should have no
interactive shell access
in the system.
useradd -u 5001 cloud-user
usermod -s /sbin/nologin cloud-user
7. Create a group called cloudadmins with a GID 10001
groupadd -g 10001 cloudadmins
8. Store the first 5 lines from the file /etc/passwd into a file called
/root/mypass.
head -n 5 /etc/passwd > /root/mypass
9. Lock and unlock the useraccount cloud-user and notice the changes in
/etc/shadow file.
usermod -L cloud-user
usermod -U cloud-user
10. Remove the jane user along with his home directory.
userdel -r jane

===========================================================================
Managing User Passwords
------------------------------
1. User Passwords are stored in /etc/shadow file and Group passwords are stored
in /etc/gshadow file
2. Format of /etc/shadow file :
<user_name>:Encrypted_Password:The_Day_Password_Last_Changed:Minimum number of
days between password change:
Maximum number of days between password change:Warning Period:Inactivity Period
3. Setup password policies using chage command. All changes would be recorded
within /etc/shadow file
useradd devops
grep devops /etc/shadow [ We should see !! in the password field ]
passwd devops [ We should see an encrypted password in the password field ]
chage -l devops [ list the password policies fordevops user ]
==> Set Min. no. of days to 3, Max. no. of days 30, Warning period to 5 and
Inactivity period to 2
chage -m 3 -M 30 -W 5 -I 2 devops
To set the account expiry date to 31.12.2021
chage -E 2021-12-31 devops
To revert back the expiry date to "never"
chage -E -1 devops
grep devops /etc/shadow
4. To create a password-less linux user
passwd -d devops
5. To force a user to change his/her password at next login :
chage -d 0 devops

6. Format of an Encrypted Password


-------------------------------
The encrypted password stores 3 pieces of information -
a. the hashing algorithm :: The number 6 represents SHA-512 has [ SHA=Secure
Hash Algorithm ] which
is the default in RHEL7 and RHEL8. The number 1 indicates MD5 [Message Digest
5 ] and the number
5 indicates a SHA-256

b. the salt :: It is used to encrypt the password. It provides random vales.

c. the encrypted hash :: The salt and the unencrypted password are combined
and encrypted to
generate the encrypted hash of the password

passwd <username>
Enter password : redhat
Retype password : redhat

A salt value will be generated randomly and the it will combined with the
unencrypted password
i.e. redhat here and then the combined string would be encrypted using the
hashing algorithm.

redhat[uncrypted]+Rs#%12e[salt]----[sha512]---> redhatRs#%12e [encrypted


hash]
redhat[uncrypted]+slp#%34e[salt]----[sha512]---> redhatslp#%34e [encrypted
hash]

===================================================================================
==========
Linux Filesystem Permissions
--------------------------------
1. File permissions control access to files
2. Linux users types --> Owner(u) / Group Owner(g) / Others(o)
3. Basic Permissions --> 3 types --> read(r-->4) / write(w-->2) / execute(x-->1)
4. ls -l /tmp ==> The first character of the long listing is the File Type,
interpreted like this -
7 Fundamental File Types ::
a. - => is an ordinary file [ text / program / binary / audio / video
file ]
b. d => is a directory
c. l => is a soft link
d. b => is a block device file
e. c => is a character device file
f. s => is a socket file
g. p => is a named pipe
What is the command to display the file type ? ==> file <filename>

-rw-rw-r-- ==> [File_Type][Owner-u][Group-g][Other-o] ==> 4+2+0 4+2+0 4+0+0 ==> 664


===================================================================================
======
Disk Management
-------------------------------
Partitioning Scheme : MBR [ Master Boot Record ] == GPT [ GUID Partition Table ]
MBR Partitioning Scheme -
------------------------
1. Since 1982, this partitioning schme has dictated how disks are partitioned on
systems using BIOS firmware.
2. This scheme supports a maximum of 4 Primary Partitions
3. With the use of exteneded and logical partitions, admins can create a maximum of
15 partitions on Linux Systems. In MBR scheme, a partition can have a max size of 2
TiB
5. Logical partition always starts from 5

GPT Partitioning Scheme


-----------------------
1. For systems running UEFI [ Unified Extensible Firmware Interfcae ], GPT is the
standard
2. Using GPT, we can create a maximum of 128 partitions
3. Supports partitions and disks of uptp 8 Zebibytes(ZiB) or 8 billion tebibytes.
4. A GPT uses a globally unique identifies(GUID) to identify each disk and
partition.
5. In contrast to MBR which has a single point of failure(SPOF), a GPT offers
redundancy of its partition
table information. The primary GPT resides at the head of the disk, while a
backup copy, the secondary GPT
is housed at the end of the disk

Partitioning Tools :: parted / fdisk


lsblk ==> to list the block devices
fdisk -l /dev/sda
parted /dev/sda print
parted /dev/sda
parted>print

Note: In Linux, we do not have any drive letter concept like windows. We have mount
point which is nothing
but a directory. This directory needs to be mapped with the disk partition. This
mapping process is known
as Mounting. We use the mount command for this mounting/mapping process.

Lab:
===
Section 1 :: Create a partition of 100 MB. Create an extended partition and assign
rest of the disk space to it.
Create a logical partition of 1 GB

Section 2 :: Format the primary partition using xfs filesystem and mount it
under /mnt/primary
Format the logical partition using ex4 filesystem and mount it
under /mnt/logical

Linux native filesystems ==> ext2 / ext3 / ext4 / xfs [ default filesystem in
RHEL7/RHEL8 ]

Command (m for help): p [ to list the partitions available in the partition table ]
Command (m for help): n [ create a new partition ]
First Sector : <Press Enter>
Last Sector : +100M
Command (m for help): w [ to save ]
Command (m for help): q [ to quit from fdisk ]
Command (m for help): d [ to delete a partition ]
Exit from fdisk utility.

Run the udevadm settle command to register the changes means mkaing the system
wait to detect the new partition
and to create the associated device file under /dev/directory.

For RHEL6/RHEL7 ==> partprobe /dev/sdb

Create Filesystem on the partition


mkfs.xfs /dev/sdb1
mkfs.ext4 /dev/sdb5

Create mount point directories


mkdir /mnt/{primary,logical}

Mount the partitions


mount /dev/sdb1 /mnt/primary
mount /dev/sdb5 /mnt/logical

Mount partitions persistently so that it remains mounted across reboot


vim /etc/fstab
Device/Partition Mount_Point Filesystem Mount_Options Dump_Level
FSCK_Order
/dev/sdb1 /mnt/primary xfs defaults 0
0
Save and Quit
mount -a

Note: It is recommended that we use the UUID value for the partition instead of
using the device name
UUID="4ebd0de5-fe18-4d3f-b109-6ef1a3af19c9" /mnt/primary xfs
defaults 0 0
To get the UUID value, run the blkid command ==> blkid /dev/sdb1

-----------------------------------------------------------------------
A swap space is an area os a disk under the control ofthe Linux kernel memory
management subsystem.
The combiled system RAM plus swap space is called Virtual Memory.

Steps to create Swap Partition


1. Create a partition of 1 GB and change the partition ID from 83 to 82 to make it
a Linux Swap Partition
Linux Native Filesystem(ext2/ext3/ext4/xfs) ==> 83
Linux Swap ==> 82
Linux LVM ==> 8e
Linux RAID ==> fd
2. Format the SWAP partition
mkswap /dev/sdb6 ==> The mkswap command applies a swap signature to the
device. It writes a single block of
data at the beginning of the device, leaving the rest of the device unformatted
so that kernel can use it to store memory pages.
mkswap /dev/sdb6
3. Activate the SWAP partition
swapon /dev/sdb6
swapoff /dev/sdb6 [ to deactivate swap partition ]
4. Make the SWAP partition persistent across reboot

Device/Partition Mount_Point Filesystem Mount_Options Dump_Level


FSCK_Order
/dev/sdb6 swap swap defaults 0
0

5. To check the status swap partition -


swapon -s
swapon -v
===================================================================================
==
Logical Volume Manager [ LVM ]
-----------------------------------------------------------------------------------
-
Partition vs. Volume
1. Partition can not be spanned across multiple disks but volume can
2. Partition can not be resized easily but volumes can be extended online keeping
the existing data intact.

LVM1 ==> To increase volume size, we had to unmount it and then extend it.
LVM2 ==> Online extension of volume is possible

LVM creation process flow :


--------------------------
Disk[/dev/sdb]---[fdisk]-->/dev/sdb1[2 GB]-->Toggle the partition ID from 83 to 8e
to make it a Linux
LVM partition---[pvcreate]--->Physical Volume----[vgcreate]--->Volume Group---
[lvcreate]-->Logical Volume
---[mkfs]-->Create Filesystem----[mount]--->Mount the logical volume---
[/etc/fstab]-->Persistent Mount

Extent==>It is the building block of a volume. The default size of an extent is 4


MB.

Create Physical Volume ==>


pvcreate /dev/sdb1
pvs ==> To display brief description of PV
pvdisplay ==> To display detailed description of PV

Create Volume Group ==>


vgcreate <vg_name> <pv_name>
vgcreate vg1 /dev/sdb1
vgs ==> To display brief description of VG
vgdisplay ==> To display detailed description of VG

How to change the extent size?


vgcreate -s 8M vg1 /dev/sdb1

Create Logical Volume ==>


lvcreate -n <lv_name> -L <lv_size> <vg_name>
lvcreate -n lv1 -L 300M vg1 [ -L is to specify the LV size ]
lvcreate -n lv1 -l 50 vg1 [ -l is to specify the no. of extents ]
lvs ==> To display brief description of LV
lvdisplay ==> To display detailed description of LV

Create Filesystem on LV ==>


mkfs.ext4 /dev/vg1/lv1

Mount the LV ==>


mount /dev/vg1/lv1 /mnt/lv1
vim /etc/fstab
/dev/vg1/lv1 /mnt/lv1 ext4 defaults 0 0

Lab:
----
1. Create a partition of 2 GB. Convert it to Linux LVM partition.
2. Create a PV using that partition.
3. Create a VG called vg1 using the PV
4. Create an LV called lv1 having 50 extents. Assign this LV to the VG called vg1
5. Create ext4 filesystem on the lv1 LV
6. Mount the LV into /mnt/lv1
7. Create another LV called lv2 having 60 extents. Assign this LV to the same VG
called vg1
8. Create xfs filesystem on lv2 LV.
9. Mount the LV called lv1 into /mnt/lv2
===================================================================================

1. Extend the logical volume called lv1 by 200 MB keeping the existing data intact
lvextend -L +200M /dev/vg1/lv1
If the Logical volume is having ext3/ext4 filesystem,
resize2fs /dev/vg1/lv1 [ this command will actually resize the LV
online ]

But if the Logical Volume is having xfs filesystem, then the command would
be
xfs_growfs /dev/vg1/lv1
OR
xfs_growfs /mnt/lv1

===================================================================================
=
Extend the VG
----------------
1. Create PV
2. Extend the VG by using the newly created PV
vgextend vg1 <new_pv_name>

-----------------------------------------------------------------------------------
---
Remove LV
--------
1. Unmount the volume
umount /mnt/lv1
umount /mnt/lv2
2. Remove the entries from /etc/fstab
3. Remove LV
lvremove /dev/vg1/lv1
lvremove /dev/vg1/lv2
4. Remove VG
vgremove vg1
5. Remove PV
pvremove /dev/sdb1 /dev/sdb2
6. Delete the partitions using fdisk

==============================================================

User Profiles
-------------
~/.bash_profile ==> We can setup some startup script or startup message
~/.bashrc ==> We can configure variables, aliases etc.

How to list the currently configured aliases?


alias
How to create an alias called cls for the clear command?
alias cls='clear'
To remove an alias?
unalias cls
============================
~/.bash_history ==> Contains all history commands
~/.bash_logout ==> To configure some exit message

================================================
Standard I/O Pipes / Redirect I/O channels to files / Combining commands using
Pipes
-----------------------------------------------------------------------------------
A running program, or process, needs to read input from somewhere and write output
to
somewhere. A command run from the shell prompt normally reads its input from the
keyboard and
sends its output to its terminal window.

A process uses numbered channels called file descriptors to get input and send
output. All
processes start with at least three file descriptors. Standard input (channel 0)
reads input from
the keyboard. Standard output (channel 1) sends normal output to the terminal.
Standard error
(channel 2) sends error messages to the terminal.

Standard Input Device (STDIN) keyborad ==> 0


Standard Output Device (STDOUT) Monitor ==> 1
Standard Error Device (SRDERR) Monitor ==> 2

Redirection
-----------
1. Input
echo "Hello World" > hello
cat < hello ....is internally translated as cat 0< hello

2. Output
cat hello > myhello ..is internally translated as cat hello 1>myhello

3. Error
cat hello123 ...hello123 file does not exist
cat hello123 2>helloerror

----------------------------------------------------------------------------
Examples of Input Redirection ::
==> Save the current system date and time to a file called /tmp/saved-timestamp
date > /tmp/saved-timestamp
==> Copy the last 5 lines from /etc/passwd to a file called /tmp/passwd
tail -n 5 /etc/passwd > /tmp/passwd

==> Search the location of passwd file in the entire filesystem hierarchy and store
the output to a file /tmp/passwd.out
find / -name passwd 1>/tmp/pass.out

==> Search the location of passwd file in the entire filesystem hierarchy and store
the output to a file /tmp/passwd.out and store the errors to another file called
/tmp/passwd.error
find / -name passwd 1>/tmp/passwd.out 2>/tmp/passwd.error

Constructing Pipelines
---------------------
A pipeline is a sequence of one or more commands separated by the pipe character.
A pipe connects the standard output of the left-hand side command to the standard
output of the right-hand side command.

Examples
-------
ls -l /dev | less
cat /etc/passwd | head -n 15 > passwd.15

Pipeline Example using the tee command


-------------------------------------
ls -l /dev | tee /tmp/dev.out | less ==> This command will redirect the ouput of
ls command to dev.out file
and passes it to the less command to get it displayed pagewise.

======================================================================
Managing Networking
----------------------------
Upto RHEL5 ==> network service ===> service network start ===> /etc/init.d/network
start
In RHEL6 ==> NetworkManager
In RHEL7/8 ==> NetworkManager is the default networking service

Network Interface Name : Upto RHEL6 ==> eth0, eth1....[eth stands for ethernet ]
RHEL7/RHEL8 ==>
--> Ethernet interfaces begin with en
--> WLAN inetrfaces begin with wl
--> WWAN interfaces begin with ww
The rest of the interface name after the type will be based on information provided
by server's firmware or determined by the
location of the device in the PCI topology.
=> oN indicates that this is an on-board device and the server's firmware
provided index number. So eno1 is an on-board
Ethernet device 1.
=> sN indicates that this device is in PCI hotplug slot N. So ens3 is an Ethernet
card in PCI hotplug slot 3

To display the IP configuration ==> ifconfig /// ip a s


To display the default gateway ==> route -n /// netstat -r
To display the DNS server IP ==> cat /etc/resolv.conf

Upto RHEL6 ==>


----------
To configure network ==> setup / system-conig-network
RHEL7/RHEL8 ==> nmtui / nmcli

Interface configuration file ==> /etc/sysconfig/network-scripts/ifcfg-eth0

To display hostname : upto RHEL6 ==> hostname


in RHEL7/RHEL8 ==> hostname / hostnamectl
If we change the machine name using hostname command, that is not permanent. If we
need to make it persistent, then
we have to edit /etc/sysconfig/network file
But hostnamectl command makes the changes persistent by writing the entry in
/etc/hostname file.

Lab
---
1. Note down the IP configuration of your system by using ifconfig and ip command.
2. How to display the MAC address of the NIC?
3. Display the default gateway. ==> route -n /// netstat -r
4. Note the DNS server IP from /etc/resolv.conf file
5. What is location of the Interface Configuration files?
6. Configure network for your linux server -
IP Address : 192.168.1.100
Subnet Mask : 255.255.255.0
Default Gateway : 192.168.1.1
DNS Server IP : 192.168.1.254
The interface should be configured to be activated onboot.
7. What is the command to change the system name temporarily?
8. What is the command to change the system name permanently? What is the name of
the file that stores the hostname?

===================================================================================
=====
System Admin tools ==> setup / system-config-*

NTP ==> Network Time Protocol . used for time synchronization


Daemon ==> ntpd[RHEL6] / chronyd[RHEL7/8]
To configure NTP client ==> system-config-date
Config file ==> /etc/ntp.conf
server <NTP_Server_IP> iburst
service ntpd restart
chkconfig ntpd on

To check ==>
ntpq
ntpq> peer ==> displays the NTP server name with which my system is
synchronized

RHEL7/8 ==>
chronyc sources -c

sync command
------------
sync command in Linux is used to synchronize cached writes to persistent storage.
If one or more files are specified, sync only them, or their containing file
systems.

On Unix-like operating systems, the sync command synchronizes corresponding file


data in volatile memory and permanent storage. Cached writes are immediately
written to disk.
By default, the Linux kernel writes data to disk asynchronously. Writes are
buffered (cached) in memory, and written to the
storage device at the optimal time. The sync command forces an immediate write of
all cached data to disk.

Run sync if you anticipate the system to be unstable, or the storage device to
become suddenly unavailable, and you want to ensure all data is written to disk.

========================================================================
Controlling Services and Daemons
------------------------------------------------------------------------
Prior to RHEL7, we used to manage the services using the service and chkconfig
command.
But in RHEL7 and RHEL8, we use a single command called systemctl to manage the
services.

Upto RHEL6, the first process was => init [ PID = 1 ]


In RHEL7 and RHEL8, the first process is ==> systemd [ PID = 1 ]

The systemd daemon manages startup for Linux, including service startup and service
management. It activates
system resources, server daemons and other processes both at boot time and on a
running system.

Daemons
-------
1. Daemons are processes that either wait or run in the background, performing
various tasks.
2. Generally, daemons start automatically at boot time and continue to run until
shutdown or until they are
manually stopped.
3. It is a convention that daemin names end with the letter called 'd'. eg. httpd /
sshd / chronyd

Service
-------
1. is nothing but a process which may not keep on running always
2. On-demand start/stop

Managing Services : the commands


--------------------------------
Prior to RHEL7
service sshd start
service sshd stop
service sshd restart
service sshd status
To put a service into the system startup so that the service gets started
automatically whenever the system
is started :: chkconfig sshd on

------------------------------------------
In RHEL7 & RHEL8 ==>
systemctl start sshd
systemctl stop sshd
systemctl restart sshd
systemctl reload sshd
systemctl status sshd

To put a service into the system startup so that the service gets started
automatically whenever the system
is started :: systemctl enable sshd

systemctl enable sshd --now ==> Will start and enable the sshd service

To verify that a service is currentily active(running)


systemctl is-active sshd

To verify that a service is enabled or not


systemctl is-enabled sshd

===========================================================
Package Management
---------------------
Install/Remove/Update/Query

Package Managent Tools --> rpm / yum / dnf

1. rpm does NOT have a repository concept and it does NOT support dependency
resolution but yum has support
for both
2. DNF is an advanced version of yum

To list the currently installed packages ==> rpm -qa <==> yum list installed
To query a package ==> rpm -q <package_name> <==> yum list installed
<package_name>
To remove a package ==> rpm -e <package_name> <==> yum remove <package_name>
To install a package ==> rpm -ivh samba...rpm <==> yum install samba
To display the owning package for a file ==> rpm -qf /etc/passwd <==> yum
whatprovides /etc/passwd
To list the files within a package ==> rpm -ql <package_name>
To update the system ==> yum update
To display information about a package ==> rpm -qi <package_name> <==> yum info
<package_name>
To list the available and installed groups ==> yum group list
To install a group ==> yum group install "Group_Name"
To remove a group ==> yum group remove "Group_Name"
To display a summary of installed and removed packageas/yum transactions ==> yum
history
To display info about a particular yum transaction ==> yum history info
<transaction_no>
To reverse a yum transaction ==> yum history undo transaction_no

========================
Runlevel vs. Target
====================
Runlevel indicates the running state of the system
0 ==> Halt
1 ==> Single User Mode
2 ==> Multi-user without network support
3 ==> Multi-user with network support. CLI mode
4 ==> Unassigned
5 ==> GUI.. X-Window System
6 ==> Reboot

init 0 => will halt the system


init 1 => Will put the system in single user mode. It doesn't ask for the password
in single user mode.
To change the Runlevel permanantly, edit the /etc/inittab file =>
vim /etc/inittab ==> change the default runlevel here...

-------------------------------------------------------------------------
graphical.target ==> System supports multi-user, graphical and text-based logins.
multi-user.target ==> System supports multiple users, text-based login only
rescue.target ==> sulogin prompt, root filesystem gets mounted in read-write mode
emergency.target ==> sulogin prompt, system root gets mounted in read-only mode

How to display the default Target?


systemctl get-default
How to change the default Target?
systemctl set-default graphical.target
To switch from one target to another target ==>
systemctl isolate multi-user.target

=============================================================================
Linux Filesystem Permissions
--------------------------------
1. File permissions control access to files
2. Linux users types --> Owner(u) / Group Owner(g) / Others(o)
3. Basic Permissions --> 3 types --> read(r-->4) / write(w-->2) / execute(x-->1)
4. ls -l /tmp ==> The first character of the long listing is the File Type,
interpreted like this -
7 Fundamental File Types ::
a. - => is an ordinary file [ text / program / binary / audio / video
file ]
b. d => is a directory
c. l => is a soft link
d. b => is a block device file
e. c => is a character device file
f. s => is a socket file
g. p => is a named pipe
What is the command to display the file type ? ==> file <filename>

-rw-rw-r-- ==> [File_Type][Owner-u][Group-g][Other-o] ==> 4+2+0 4+2+0 4+0+0 ==> 664

Changing Permissions with Symbolic Method


-----------------------------------------
What is u,g,o
What is r,w,x
What is +,-,= ( add / remove / set exactly )
The command ==> chmod

Changing file ownerships


------------------------
chown ==> to change owner / group owner / owner+group
chgrp ==> to change only the group owner

Special Permissions
-------------------
3 Special Permissions -
a. suid [ Set User ID ==> s ==> 4 ] ==> can be implemented on Owner(u)
b. sgid [ Set Group ID ==> s ==> 2 ] ==> can be implemented on Group(g)
c. sticky bit [ t ==> 1 ] ==> ==> can be implemented on others(o)

-rwsr-xr-x ==> 4755


-rwsr-sr-x ==> 6755
-rwsr-sr-t ==> 7755
Lab on Permission and Ownerships
-------------------------------
1. Create a group called consultants
2. Create 2 users called consultant1 and consultant2
3. consultants should be the secondary group for consultant1 and consultant2 users.
4. Create a directory called /home/consultants
5. Change the group owner to consultants for the /home/consultants directory
6. Give write permission to the consultants group
7. Use the chmod command to forbid others from accessing files in /home/consultants
directory.
8. Exit the root shell and switch to consultant1 user.
9. Navigate to /home/consultants directory and create a file called consultant1.txt
10. Ensure all members of the consultants group can edit the consultant1.txt file.
11. Exit the shell and switch to consultant2 user.
12. Navigate to the /home/consultants directory. Ensure that consultat2 user can
add content "Hello
World" to the consultant1.txt file
13. Ensure that all files and directories within the /home/consultants directory
will have the group owner
set to consultants.
14. Ensure that all files created within /home/sonsultants directory have the group
owner set to
consultants automatically.
15. Also make sure that only owner can delete his/her file(s) within
/home/consultants.

===================================================================================
=========
Network File Sharing Services --> NFS / FTP / SMB
-----------------------------------------------------------------------------------
--------
NFS ==> Network File System. It allows remote hosts to mount file systems over a
network
and interact with those filesystems as though they are mounted locally. This
enables us to consolidate resources onto centralized servers in a network.

NFS shares are generally defined in /etc/exports file or /etc/exports.d/*.exports


RHEL8 supports NFS version 3(NFSv3) and NFS version 4(NFSv4). NFSv2 is not
supported
in RHEL8.

The default NFS version in RHEL8 is 4.2

NFS exports are by default read-only


Package name : nfs-utils
Services required by NFS :
nfsd ==> The NFS server kernel module that services requests for shared NFS
filesystems
rpcbind => Accepts port reservations from local rpc services.
rpc.nfsd => This corresponds to the nfs-server service

NFS shares==> directory / entire filesystem


vim /etc/exports
<dir_name/filesystem_name> FQDN/DOMAIN/IP/NETWORK(access_mode)
/storage 192.168.1.0/24(ro,sync)
/public *.example.com(rw,sync) *.cracker.org(ro,sync)
/confidential 192.168.1.100/24(rw,sync)

systemctl restart nfs-server


systemctl enable nfs-server
exportfs -r

Firewall
-------
systemctl status firewalld
firewall-cmd --list-all
firewall-cmd --list-services
firewall-cmd --list-ports

firewll-cmd --permanent --add-service=nfs


firewll-cmd --permanent --add-service=mountd
firewll-cmd --permanent --add-service=rpc-bind
firewall-cmd --reload

Lab: Install and configure NFS server


=====================================
Server End Configuration
-------------------------
1. Install nfs-utils package
2. Create 2 directories --> /data and /storage
Create some files within /data directory
3. Export the /data directory to all in Read-Only mode
4. Export the /storage directory to all in Read-Write mode
5. Start and Enable NFS server
systemctl enable --now nfs-server
6. Verify the shares from the NFS server
showmount -e
7. Provide write access to others for /storage directory
chmod o+w /storage

Client End Configuration


------------------------
1. Create 2 mount points --> /mnt/data and /mnt/storage
2. Mount the /data share from the NFS server into /mnt/data directory
3. Mount the /storage share from the NFS server into /mnt/storage directory
4. List the contents of /mnt/data should be successful but touch /mnt/data/newfile
should be unsuccessful as
the share is read-only
5. List the contents of /mnt/storage should be successful but touch
/mnt/storage/newfile should be unsuccessful even
if the share is writable.
Workaround :: We need to provide write permission also for the writable share
Once the permission is given in the serevr end, we should be able to write
into /mnt/storage directory

===================================================================
Installing and Configuring FTP Server
-------------------------------------
FTP = File Transfer Protocol. Used for transferring files (upload/download) across
systems in the network.
Ports : 20 ( Data ) 21 ( Connection )
Package : vsftpd [ Very Secure FTP Daemon ]

Install vsftpd package ==> yum install vsftpd


Start and Enable vsftpd daemon ==> systemctl enable --now vsftpd
Configuration File ==> /etc/vsftpd/vsftpd.conf
FTP user ==> 1. Registered User 2. Anonymous User
Anonymous user can download files but can NOT upload files by default.

To check on which port the server is listening on ==>


netstat -tlpn | grep ftp

FTP root directory ==> /var/ftp


Install FTP client package ==> yum install ftp

Allow Anonymous access to the FTP server ==> anonymous_enable=YES


Allow/Deny User access ==>
/etc/vsftpd/user_list
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and do not
even prompt for a password.

/etc/vsftpd/ftpusers ==> List the users who can NOT login to FTP server

Lab :
---
1. Install vsftpd package. Start and Enable the service
2. Install the ftp client
3. Try to login to FTP srever as anonymous/ftp user and it should be allowed. Make
necessary changes in
vsftpd.conf to disallow anonumous user login.
4. Create 2 users called ftpuser1 and ftpuser2
5. Run the FTP command from root and then login to FTP server as ftpuser1 and
ftpuser2 respectively and
upload some files. It should work.
6. By default root login is disabled in FTP server. Consult necessary files to
enable root login for
testing purpose.
7. Allow FTP ports through Firewall -
firewall-cmd --permanent --add-port=20/tcp
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --reload
10. Enable and Monitor FTP logs
vim /etc/vsftpd/vsftpd.conf
xferlog_enable=YES ==> This will enable FTP server logging

tail /var/log/xferlog

===================================================
Configuring SAMBA Server
==================================================
What is SMB?
Server Message Block(SMB) / CIFS (Common Internet File System) is the standard
file-sharing protocol for Microsoft servers
and clients.

1. Install Samba Packages


yum install samba samba-common samba-client
2. Prepare the permissionsa and Selinux Context on the directory to be shared
mkdir /smbshare
ls -dZ /smbshare
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?'
restorecon -Rv /smbshare/
3. Configure /etc/samba/smb.conf [ Samba Configuration File ]
[myshare]
path = /smbshare
public = yes
browseable = yes
writable = no

[private]
path = /confidential
browseable = yes
valid users = fred, @dba
write list = fred

Validate the smb.conf ==> testparm

4. Setup appropriate Linux users to work as samba only user


useradd -s /sbin/nologin fred
smbpasswd -a fred
5. Start Samba service and open the ports in the firewall
systemctl start smb nmb
systemctl enable smb nmb
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
6. Verify the samba shares from client system
Install cifs-utils package because it provides the mount.cifs command
Create a mount point
mkdir /mnt/{smbshare,private}
Mount the share
mount -o username=brian //Samba_Server_IP/private /mnt/private
Validate the smb.conf ==> testparm

=====================================================================
Shell Scripts
-------------
#!/bin/bash
clear
echo "Welcome To DXC Technology"
--------------------------------
#!/bin/bash
echo "Enter a number :"
read num1
echo "Enter another number :"
read num2
sum=$[$num1+$num2]
echo "The sum is : $sum"
--------------------------------
#!/bin/bash
groupadd group1
useradd user1
echo redhat | passwd --stdin user1 &>/dev/null
usermod -G group1 user1
---------------------------------

# Script to check if a number is odd or even


#!/bin/bash
echo "Enter a number: "
read num
rem=$[$num % 2 ]
if [ $rem = 0 ];then
echo "Even number"
else
echo "Odd number"
fi

-------------------------------
#!/bin/bash
for x in `seq 1 10`
do
echo $x
done

--------------------------------------------------------------------
Troubleshooting
==================
Resetting the ROOT Password
--------------------------
Append rd.break ===> system breaks just before the system hands control from the
initramfs to
the actual system.
At this point, the system presents a root shell with the actual root filesystem on
the disk
mounted as read-only on /sysroot.
We need to remount the / filesystem as RW ==> mount -o remount,rw /sysroot
Switch into the chroot jail, where /sysroot is treated as the root of the file-
system tree.
chroot /sysroot
passwd root

Make sure that all unlabelled files, including /etc/shadow at this point, get
relabelled during
boot.

touch /.autorelabel

=============================
Transferring files using Secure Copy
------------------------------------
1. OpenSSH is useful for running shell commands on remote systems.
2. scp [ Secure Copy] command is used to securely copy files to remote systems.
scp /etc/hosts root@RemoteServerIP:/archive
scp /etc/passwd student@RemoteServerIP:/tmp

To copy a whole directory tree recursively, use the -r option.


scp -r data root@RemoteServerIP:/root

--------------------------------------------------------
To interactively upload or download files from an SSH server, sftp [ Secure File
Transfer Program ] can be used.
Just like scp command, sft also uses [user@]host to identify the target system
sftp root@RemoteServerIP
sftp> mkdir backup
sftp> cd backup
sftp> put /etc/hosts ==> This command will upload /etc/hosts file to the
remote directory called backup
sftp> get hosts ==> This will download hosts file from the remote directory
to the local system
Run sftp command to get connected to the remote host
sftp root@RemoteServerIP
Create a directory called backup in the remote server and change the directory
to /root/backup
Upload /etc/hosts file from the local system to remote system's /root/backup
directory
Upload /etc/passwd file from the local system to remote system's /root/backup
directory
Download the passwd file from the remote system's /root/backup directory to the
local system

----------------------------------------------------------------------------------
Synchronizing files between systems securely
----------------------------------------------
rsync - a fast, versatile, remote (and local) file-copying tool
rsync tool can be used for taking incremental backup

The rsync command is another tool to securely copy files from one system to another
system over the network.
It uses an algorithm that minimizes the amount of data copied by synchronizing only
the changed portions of the
files.

It differs from scp in that if 2 files or directories are similar between two
servers, rsync copies only the
differences between the files, while scp would still copy everything.

2 common options of rsync command are ==> -a (Archive) and -v (Verbose)


Archive mode is the same as specifying the following options -

Options Enabled with rsync -a (Archive Mode)


--------------------------------------------
-r ==> synchronize recursively the whole directory tree
-p ==> preserces permissions
-t ==> preserves time stamps
-g ==> preserves group ownership
-o ==> preserves the owner of the files

========================================
Selinux ==> Security Enahnced Linux
======================================
Selinux Modes :
1. Enforcing (1) - deny access and record the logs if policy is not matched
2. Permissive (0) - Warning-only mode.. allows access with a warning
message and records log even if the policy gets
mismatched
3. Disabled - no selinux policy is being checked

How to know the current Selinux Mode? ==> getenforce


How to change the Selinux mode temporariry? ==> setenforce 1 [ will change the mode
to enforcing ] and
setenforce 0 [ will change the mode
to permissive ]

How to change Selinux mode permanently? vim /etc/selinux/config

Security Context ==> User(_u)+Role(_r)+Type(_t)


How to display the security context?
ls -lZ

Subject ==> Processes


Object ==> Directory / File

yum install httpd


systemctl start httpd
ps -eZ | grep httpd ==> To display the Selinux type of httpd process(Subject)
ls -dZ /var/www/html ==> To display the Selinux Type of html directory(Object)
mkdir /webcontent
ls -dZ /webcontent ==> Note the type is default_t

Here, the type of the subject(httpd) does not match with the type of the
object(/webcontent). So, even if we give 777
permission to /webcontent directory, still httpd won't be able to access the
content(index.html) of /webcontent

How to change the Selinux type?


a. chcon ==> only runtime change is possible
chcon -t httpd_sys_content_t /webcontent
ls -dZ /webcontent
restorecon -Rv /webcontent ==> The type rolls back to default_t

b. semanage fcontext ==> persistent change


man semanage fcontext
semanage-fcontext - SELinux Policy Management file context tool
semanage fcontext -a -t httpd_sys_content_t "/webcontent(/.*)?"
restorecon -Rv /webcontent

========================
Automated Installation
=======================
You can automate the installation of Red Hat Enterprise Linux using a feature
called Kickstart. Using Kickstart, you specify everything Anaconda needs to
complete an installation, including disk partitioning, network interface
configuration, package selection, and other parameters, in a Kickstart text file.
By referencing the text file, Anaconda performs the installation without further
user interaction.

Kickstart Installation Steps ==>


--------------------------------
1. Create a Kickstart file.

2. Publish the Kickstart file to the installer.

3. Boot Anaconda and point it to the Kickstart file.

Creating a Kickstart File


-------------------------
Use either of these methods to create a Kickstart file:
==> Use the Kickstart Generator website.
==> Use a text editor.

The Kickstart Generator website at https://access.redhat.com/labs/kickstartconfig/


presents dialog boxes for user inputs, and creates a Kickstart directives text file
with the user's choices. Each dialog box corresponds to the configurable items in
the Anaconda installer.

Publish the Kickstart File to Anaconda


-------------------------------------
Make the Kickstart file available to the installer by placing it in one of these
locations:

==> A network server available at install time using FTP, HTTP, or NFS.
==> An available USB disk or CD-ROM.
==> A local hard disk on the system to be installed.

Boot Anaconda and Point it to the Kickstart File


Once a Kickstart method is chosen, the installer is told where to locate the
Kickstart file by passing the inst.ks=LOCATION parameter to the installation
kernel. Some examples:

inst.ks=http://server/dir/file
eg. inst.ks=http://192.168.1.254/ks-config/ks.cfg
inst.ks=ftp://server/dir/file

inst.ks=nfs:server:/dir/file

====================================
Network teaming
--------------
Network teaming is method for linking NICs together logically to allow for failover
or higher throughput. Teaming is a new implementation that
does not affect the older bonding driver in the Linux kernel; it offers an
alternate implementation.

Red Hat Enterprise Linux 7 implements network teaming with a small kernel driver
and a userspace daemon, teamd. The kernel handles network packets
efficiently and teamd handles logic and interface processing. Software, called
runners, implement load balancing and active-backup
logic, such as roundrobin.

The following runners are available to teamd:


• broadcast: a simple runner which transmits each packet from all ports.
• roundrobin: a simple runner which transmits packets in a round-robin fashing
from each of the ports.
• activebackup: this is a failover runner which watches for link changes and
selects an active port for data transfers.
• loadbalance: this runner monitors traffic and uses a hash function to try to
reach a perfect balance when selecting ports for packet transmission.
• lacp: implements the 802.3ad Link Aggregation Control Protocol. Can use the
same transmit port selection possibilities as the loadbalance runner.

==========================
Patching
---------------
Patches are updates that incorporate changes in source code. They can be applied to
the Linux kernel or to applications and other systems code running on a Linux
server. ... Patch management is basically the process of acquiring, testing and in-
stalling multiple code changes (patches) to systems software and applications.

Patch management consists of scanning computers, mobile devices or other machines


on a network for missing software updates, known as “patches” and fixing the
problem by deploying those patches as soon as they become available.

You can use the Red Hat Enterprise Linux kernel live patching solution to patch a
running kernel without rebooting or restarting any processes.
With this solution, system administrators:

Can immediately apply critical security patches to the kernel.


Do not have to wait for long-running tasks to complete, for users to log off, or
for scheduled downtime.
Control the system’s uptime more and do not sacrifice security or stability.

Kernel patch module


The delivery mechanism for kernel live patches.
A kernel module which is built specifically for the kernel being patched.
The patch module contains the code of the desired fixes for the kernel.
The patch modules register with the livepatch kernel subsystem and provide
information about original functions to be replaced, with corresponding pointers to
the replacement functions. Kernel patch modules are delivered as RPMs.
The naming convention is kpatch_<kernel version>_<kpatch version>_<kpatch release>.
The "kernel version" part of the name has dots and dashes replaced with
underscores.
The kpatch utility
A command-line utility for managing patch modules.
The kpatch service
A systemd service required by multiuser.target. This target loads the kernel patch
module at boot time.

You might also like