LINUX
LINUX
LINUX
87
testuser
testuser@123
Overview of course
Mock test
Resume preparation
Uploading resume in naukri
How to handle the recruiter (HR)
How to face interview
Questions and answers
From 2018 till now working in one of the company in finance domain
Pre-requisites
1. Laptop/Desktop
Min 4 GB RAM
OS windows 7/10
3 years 6 lakhs
4 years 8 to 9 lakshs
6 Years 13 to 14 lpa
Universal license keys
Topics
1. what is OS(Operating system)
2. History of Unix and Linux
What is os?
Eg: OS is a mediator?
End User (prasad) playing one audio, with help of os programs(double click on audio
file).
OS will understand double click on audio file means i have Execute nothing playing
the song.
OS programs will understand program and send output to Hardware (speakers).we will
get sound from speakers
What is UNIX?
UNIX is aoperating system which is developed by ken Thomson, dennies and dugluss.
It has been released in 1969 Dec 31.
Feature of UNIX: multi user and multi tasking
Multiple users logged in system that is nothing multi user and all the users will
start executing some programs that is nothing multi tasking.
UNIX is accepting multiple connections from multiple users and same time all the
users can execute their own programs invidually.
UNIX flavaours
Linux Flavours:
UNIX Architecture
==========================================
1. Application Layer
2. Shell
3. Kernel
4. Hardware
Os is nothing collection of programs which will interact with enduser and Hardware.
1. Application layer:
Which is the layer interact with enduser that layer called as application layer.
Here only we will give input/task/process will be triggered.
2. Shell;
Shell will be there between application layer and Kernel layer. It is going verify
each and every task (program)
which is given by end user and send it to the kernel. Shell will pass task to
kernel layer if task valid one.
Shell will have pre-defined programs, if application layer give task and task is
matching with existing program then only shell will pass it to kernel.
3. Kernel;
Kernels are a heart of operating system or kernel is a core program of OS.
Shell is protecting kernel. Shell is not allowing unknown programs.
Default shells in Linux
1. Sh
2. Bash
3. Dash
4. Csh
5. Tcsh
6. Nologin
Extra shells
Ksh (korn shell)
3. Kernel
Kernel is a heart of the operating system and it's a core program of Operating
system programs.
What is the role of kernel?
Task management
Memory management
Resource management
4. HARDWARE
Kernel will pass task /program to processor (HW) and processor will execute task
and take data from Hardisk (HW)
and send the output to monitory (HW).
1. What is server?
2. What is DC (Data Center?)
3. Difference between Desktop and Server
Standalone server
Enclosure: collection of blade servers (16 Blade servers with common SMPS (5)).
Platforms
1. Physical
2. Virtual
3. Cloud VM
1. Physical:
We will install OS in invidual physcical box (server).
16 servers for 2 applications
2 applications are nothing but (3 web app servers, 6 app severs and 4
DB servers)
Data center engineer will connect the cables and power on the
server.
Data center engineer will assign IP address for console and also
create admin user for console access.
HP Servers DELL
servers
Console ILO3, ILO4 IDRAC
HBA card: using HBA card we can access storage (HDD) from server. -- host bus
adapter
->HBA use to connect to block level storage such as fiber chanel sata sscsi
=======================Virtual platform========================
Esxi is a baremetal operating system. Which can adjust with metal (physical)? Esxi
contains virtualization programs which can adjust with physcial component.
So we are injecting virtualization programs inside physical server.
physical platform:
virtual platform
physical server 3 ==>esxios (hypervizor)==> access through vcenter==> create
virtual machine(vm1) ==>redhatos installation ==> application
physical server 3 ==>esxios (hypervizor)==> access through vcenter==> create
virtual machine(vm2) ==>SuSE OS installation ==> application
physical server 3 ==>esxios (hypervizor)==> access through vcenter==> create
virtual machine(vm3) ==> Solaris OS installation ==> application
physical server 3 ==>esxios (hypervizor)==> access through vcenter==> create
virtual machine(vm4) ==> Windows OS installation ==> application
physical server 3 ==>esxios (hypervizor)==> access through vcenter==> create
virtual machine(vm5) ==> Windows OS installation ==>applciation
Cloud platform
the cloud platform almost equal to virtual platform.
vmware = vcenter to administrate the virtualization
cloud = web page to administrate the virtualization
===========================Default
Directories===========================================
Folders = Blue
Files = black
Who is the admin user in UNIX servers? Root
1. /boot: it contains operating system bootable files. Machines will not bootup
incase any file deleted from /boot, so /boot is a critical directory.
2. /root: it is a root user home directory or admin user home directory.
There are two types of users. Normal user can not enter into root user home
directory, but root can enter into any of normal user’s home directory.
Root: /root
Norma users: /home/prasad
/home/Siva
3. /home: It contains normal user’s home directories.
4. /etc: it contains system configuration (settings) files.
Eg: i want to change hostname. I can go to /etc/ and find out right file and
modify the hostname
5. /usr : /usr contains system user binary programs like commands
/usr/bin : common commands. These commands needed for all the users.
/usr/sbin: it contains only administrator commands or super user commands.
normal user can't use /usr/sbin commands.
Command is nothing but program.
9. /lib: libraries. Operating system related programs. is os will run without lib?
no
Ls /usr/bin
Ls command use the one of library from /lib.
===================================================================================
====
/
/root
File management
1. Cat
2. VI
3. Touch
1. Cat
Create file:
Cat ><filename>
Cat > file2
content1
content2
..................
Hold the ctrl key and press d to save and come out.
View the file content:
Cat <filename>
Cat file2
Print file content with line numbers
Cat -n <filename>
Cat -n file2
Append or overwrite content to existing file
Cat >><filename>
Cat >>file2
New content
Hold the ctrl key and press d to save and come out.
2. VI------virtual interface*********
Using VI we can creeate file, modify file content and many other features are
included.
Create file
VI <filename>
3 modes inside VI
1. Command mode (delete content, replace content, search content. eg:
dd is for delete 1 line, yy is for copy 1 line)
2. Insert mode (we can add content inside file)
3. Replacement mode (replace the file content)
I: is for swithfrom command mode to insert mode
Esc: is for swith from insert mode to command mode
: Senu is for print file content with line numbers
: Se nonu: is for invisible line numbers
Dd: is for delete cursor standing line
U: undo the latest changes
10dd: is for delete 10 lines from cursor standing line
yy: is for copy the line where cursor is standing
p : is for past the copied line below of cursor position
10yy : is for copy 10 lines from cursor standing position
capital P is for past the copied line above of cursor position
:w : save changes so far whaterver we made
:wq : is for save and comeout from file
:q: is for quit from the file without save the changes
cc : cut : is for cut the cursor standing line
10cc: is for cut 10 lines from cursor standing position
i want to past the cut line
press esc and press p past
Shift G
: %s/venu/ram/g
S substitute
Old/new/g
g global
3. Touch
Touch tfile1
Touch tfile2 tfile3 tfile4 tfile5
touch file{1..100}
disk usage
Du = disk usage
h= human readable format
s= size
REMOVE
rm
================
file : rm <filename>
rm -f <filename>
directory: rm -r <directory>
rm -rf <directory>
-r recorsively
folder with content should delete
-f forcefully . remove file or directory without my confirmation
Cp
======================
File: cp <filename><destination path>
Directories: cp -r <folder><destination path>
Cp -r /root/Downloads /var
Cd /var
Ls
MOVE
mv
============================
1. purpose: move file or directories from one place to another place
2. Rename
mkdir /db1
cd /
mv db1 db5
rename because same path
mv db5 /mnt
we moved db5 directory to /mnt
===========================09-Sep-2021==================
How to get server configuration data
RAM (memory)
******Free -m or free -g or free -k
k = kilo bytes. We will get memory informaiton in kilo bytes
m = mega bytes.
g= gbs
******Cat /proc/meminfo
CPU
Lscpu
******Cat /proc/cpuinfo
Disk
******Fdisk -l
******Lsblk
******Lsscsi
/dev/sda disk1
/dev/sdb disk2
/dev/sdc disk3
/dev/sdc1 partition number 1 in sdc disk
/dev/sdc2 2nd partition in sdc disk
Type = disk
sr0 = ROM nothing DVD
Part = partition
OS information
******Hostnamectl status
******Cat /etc/os-release
Host name or computer name
******Hostname
Uname -n
Change Hostname
Hostnamectl set-hostname batch25m5
Kernel version
What is kernel? Kernel is a one of the program in collection of
os programs.
Kernel is a core program of os
Kernel is a heart of os
*******Uname -r
Architecture of OS
Arch
Whoami
Shutdown -h now
Poweroff
Init 0
How to reboot the server
shutdown -r now
shutdown -r 5
shutdown -r 5 " rebooting server as per schedule"
reboot
init 6
============================================================
IMPORTEBT COMMANDS
less,more,head,tail,wc,grep,sed
|
|| = cmd1 || cmd2 : cmd 2 should execute incase cmd1 fails
eg: install software incase not installed
&& = cmd1 && cmd2 && cmd3 && cmd4: cmd2 will exuecte if cmd1 success. Cmd3 executes
if cmd2 success.
; = cmd1; cmd2;cmd3;comd4
executing commands parlel
hostname;date;arch
cmd1 output pass to pipe symbol and cmd 2 will execute based pipe symbal data
less more
more and less commands are for view file content page by page.
eg: there is lenghthy file want to read file page by page then we can less or
more commands to read
synx:
more <filename>
less <filename>
More filename
- space bar is for go to next page
enter key is for next line
b is for go to previous page
esc to comeout from the file or output
/word to search the word(string) in output
WC = word count
******WC -l filename
-l line numbers
WC -w filename
Words
WC -c filename
Chars
=======================================Grep=============================
Grep is for search string (word) from file or files in one depth of
directory.
-wicnv
Inode number:
****** What is inode number? Each and every file and directory will have one unique
number that unique number is nothing but inode number.
Kernel will assign one unique number for each and every file/directory.
***** How to identify inode number file or directory
Ls -i filename
Ls -i directory
Stat filename
Below information linked with inode number
Filename, size of the file, file creation date and time, owner of the file,
group of the file, permissions and links
ls -l
- l long list
-----------------------------------------------------------------------------
drwxr-xr-x. 2 root root 6 Sep 8 07:45 app1
lrwxrwxrwx. 1 root root 7 Sep 3 13:15 bin ->usr/bin
dr-xr-xr-x. 4 root root 4096 Sep 6 12:49 boot
drwxr-xr-x. 2 root root 6 Sep 8 07:46 db5
drwxr-xr-x. 20 root root 3300 Sep 15 13:29 dev
drwxr-xr-x. 140 root root 8192 Sep 14 13:38 etc
-rw-r--r--. 1 root root 495 Sep 15 13:18 f10
-rw-r--r--. 1 root root 18 Sep 8 07:32 f4
----------------------------------------------------------------------------
total 7 fields
Drwxr-xr-x
d= directory
l = linked file/directory
- = file
b = block file or raw device
Brw-rw----. 1 root disk 8, 0 Sep 15 13:29 sda
Sda is hard disk nothing block device
c= charecter files or device: these files are used by OS programs.
p= pipe file. System program file program1========program2
s = socket
***** What is l starting of file? Options like is long file, lenghty file linked
file
Which one is right? Linked
ls -l or ll
ls -lt
t= sort with latest time stamp
r= reverse the output
Ls -ltr
Disk Management
=============
Disk management
Creating partitions based on request
delete partition based on request
extend partition space. the current size is 100 GB , extend it to 200
GB
reduce space from existing partition. the current size is 200 GB ,
reduce it to 150 GB.
1. Normal method:
Scenario 1: creating partition
Scenario 2: deleting partition
8 bits = 1 byte
1024 bytes = 1 KB kilo bytes
1024 KB = 1 MB mega bytes
1024 MB = 1 GB Giga bytes
1024 GB = 1 TB Tera bytes
1024 TB = 1 PB peta bytes
1024 PB = 1 EB exa bytes
defaults= defaults,ro
partition should mount in read only mode along with default permissions
Journaling is nothing but data about data nothing but meta data.
How to identify what file system type is assigned to partition?
******blkid
Or
******blkid -o list
sectors
bits
bytes
kb,mb,gb,pb,eb
Default size of file is 4MB that mean kernel allocated 8 sectors to 1 file.
meta data maintaince data about data or so and so file occupied which are the
sectors.
incase any one sector is wrongly tagged to any other file xfs_repair will
arrange back to orginal file
we will repair the sectors using xfs_repair
Advantages of journaling:
Fast repair or fast recovery because there is meta data nothing but data
about data.
Like page numbers for book
---------------------------------------------------------how to delete
partition------------------
step 1 : unmount the mounted partition
umount /a1
umount /a2
step 2: remove entry in /etc/fstab
step 3 : enter in to disk and delete the partition
fdisk /dev/sdc
d
partition 2
w = save and come out
===========================User administration======================
Creating user
modifying user
deleting user
group
creating group
adding/removing users from group
modifying group
deleting group
Useradd tuser
Useradd appuser
Useradd dbuser
Passwd tuser
passwd appuser
passwd dbuser
authentication methods
1. Local user management
2. Centralized user management
Only root user will have access to perform following tasks disk management,
user management and software management
whoami
the above command is for identify which user is logged in
root = #
normal users = $
backend kernel is going to allocate one uid, group for the user, home directory for
the user, shell for the user.
==================================
prasad:x:1000:1000:prasad:/home/prasad:/bin/bash
siva:x:1001:1001::/home/siva:/bin/bash
prasanth:x:1002:1002::/home/prasanth:/bin/bash
testuser1:x:1003:1003::/home/testuser1:/bin/bash
tuser:x:1004:1004::/home/tuser:/bin/bash
tuser1:x:1005:1005::/home/tuser1:/bin/bash
ramu:x:1006:1006::/home/ramu:/bin/bash
babu:x:1007:1007::/home/babu:/bin/bash
raja:x:1008:1008::/home/raja:/bin/bash
appuser1:x:1009:1009::/home/appuser1:/bin/bash
=========================================
username: X: uid:gid:comment:homedirectory:shell
1 2 3 4 5 6
7
b25user1:x:1010:1010::/home/b25user1:/bin/bash
1 2 3 4 5 6 7
the fields are seperated with : we can find user information in /etc/passwd
here 7 fields will be
field 1 : username
field 2: mask password(redirect to /etc/shadow file for password)
field 3: user uid (unique id)
field 4 : user primary group id
field 5 : comment of user
field 6 : home directory of user
field 7 : shell of the user
b25user1:x:1010:0::/home/b25user1:/bin/bash
with specifications
useradd -u 2000 -g 0 -G prasad -d /opt/babu1 -m -c babu1 -s /bin/bash babu1
useradd -u 2001 -g 0 -G prasad -d /opt/babu2 -m -c babu2 -s /bin/bash babu2
without specifications
useradd babu1
u = uid
g = primary group id
G = secondary group id
d = home directory path
m = make home directory
c = comment
s = shell
Primary group: each and every user will have one primary group
Secondary group: user can be member into n number secondary groups
eg: babu user can be member into n number of groups(secondary group)
useradd
passwd
pending
usermod
userdel
groupadd
groupmod
groupdel
add users into group
delete users from group
useradd rajesh
useradd command will take inputs from /etc/default/useradd file.
whatever is missing in useradd command that data supplied by
/etc/default/useradd.
eg : useraddrajesh
The above command will take /etc/default/useradd help to specify home and
shells
going forward for up coming users home directory should be /opt? who we can do this
vi /etc/default/useradd
HOME=/opt
after this modification users home directory creates under /opt
Usermod
-u uid
-g pgid
-G sgid
-c comment
-d home directory
-m make
-s shell
usermod -u 4000 babu2
modifying uid to babu2
usermod -c newcomment babu2
how to change the home directory
usermod -d /opt/r1home -m r1
for r1 user new home directory is /opt/r1home
7 fields
how to create user?
useraddramu
useradd -u 3000 -G root -d /usr/ramu -m -c ramlinuxadmin -s /bin/shramu
how to set password for the user?
passwd ramu
1 2 3 4 5 6 7
*** ***which are the files will get updated once we create user?
1. /etc/passwd ===> user information
2. /etc/shadow ===> password information
3. /etc/group ===> group information
useradd raj
username is raj same time kernel will create group with same username
================================shadow
fields==========================================
raj:!!:18893:0:99999:7:::
18893 + 30
max password age is 30 days
18893 +30 = 18923
0:99999:7
0 = min age of password
99999 = are the max password age
2:30:7
n x w
min = 23rd sep 2021 set password for raj and the min age for password is 2 so that
means next 2 days we can't change password.
min 2 raj user can 't change password
max = password will not work after max max age . passoword is going to expair after
30 days from 23 sep 2021.
war = warning notification will start on 23rd days onwards because warning days we
set 7.
30 - 7 = 23 notification like passowrd is going to expair on 23 oct
2021 in 7 days password is going to expair
24 passowrd is going to expair in 6 days
25th day also password is going to expair in 5 days
26th day also password is going to expair in 4 days
PS = password set
LK = password is locked
raj1:!!:18893:3:90:4:::
chage -l raj1
even this command is for get user and password information
======================================Backup class============================
administrator in linux box = root
parent directory is /
/
/boot
/root
/etc
/var
/usr/bin
/lib
ctrl d
save come out
how to create file? cat > newfile1 ctrl d is
for save and comeout
how to view the file content using cat? cat newfile1
how to append data to existing file? cat >> newfile1
ctrl d is for save and comeout
=================25-Sep-2021======================================
Task 1 : Install vmware work station which i sent over the mail. License key is
available in what's up group
Task 2: open vmware work station and create virtaul machine
Task 3 : Install the operating system
file managment:
cat
vi
touch
using above 3 commands we are going to create file
/root
/boot
/etc
/lib
/var
who is the administrator in linux servers? root
vi file10
3 modes in vi
1. command mode
2. insert mode
3. Replacement mode
s substite
g globla
:wq is for save and comeout
:w is for save
:q comeout without save changes
:wq! save and comeout forcefully
touch
touch is for create empty file or files
directory or folder
mkdir testdir1
mkdir tdir1 tdir2 tdir3
mkdir td{1..30}
remove
rm filename
rm -f filename
rm -r directory
rm -rf directory
f = force
r = recursively
copy
files : cp /file1 /opt
dir : cp -r /testdir /opt
cp <source><destination>
move
mv filename /opt
mv dir /opt
/dev/sda disk
/dev/sda1 partition
2
3
.................. 64 partitions in single disk
wc : word count
wc -l filename print the line numbers of file
wc -w filename to count the words in file
wc -c filename char
head filename
by default head prints 10 lines.
| symbol
cmd1 | cmd2
head file1 | wc -l
| symbol can store first command output and pass the same output to next command as
a input
more and less commands are for print page content page by page
===================================================
how to create user
/etc/passwd fields
7
linga:x:3004:3005::/home/linga:/bin/bash
===================================27-Sep-
2021======================================
group administration
groupaddunix
how to modify groupname?
groupmod -n unixgrpunix
how to modify group id?
groupmod -g 1011 unixgrp
how to add single user into group
gpasswd -a raj1 unixgrp
how to add multiple users into group?
gpasswd -M raj1,prasadbabu,user1,user2 unixgrp
how to delete user from group?
gpasswd -d raj1 unixgrp
how to delete the group?
groupdelunixgrp
USER SKELITON
3 files will be copied to user home directory once after create new user.
.bash_logout
.bash_profile
.bashrc
.bash_history
.bash_profile = we can set the program which can execute while user is login.
.bashrc = we can set the program which can execute while user is login.
su - babu
echo $HISTSIZE
1000
vi .bash_profile
HISTSIZE=2000
save and comeout from .bash_profile
compile the file
source .bash_profile
echo $HISTSIZE
going forward babu profile can remember latest 500 commands
Variables
=====================
variable is nothing but array which can store program or value.
1. System variables
2. user defined variables
===============================Permissions=========================================
===
root
-rw-r--r--. 1 root root 2410 Sep 8 07:37 file3
drwxr-xr-x. 2 root root 6 Sep 8 07:45 tdir1
normal user
drwxrwxr-x. 2 ram1 ram1 6 Sep 29 12:52 ramdir1
-rw-rw-r--. 1 ram1 ram1 0 Sep 29 12:52 ramfile1
421421421
rwxrwxrwx
7 7 7
r=read=4
w=write=2
x=execution=1
7
rw- r-- r--
6 4 4
u g o
u= user(owner)
g=group
o=others
useradd -G linuxteam l1
creating l1 user and adding l1 into linuxteam group as secondary group
what is the primary group for l1?
l1
useradd -G linuxteam l2
useradd -G linuxteam l3
who are the linux team members? lid -g linuxteam or grep linuxteam
/etc/group
grep linuxteam /etc/group
linuxteam:x:3010:l1,l2,l3
is l3 user can modify /tmp/l2file? yes
new permissions
-rw-------. 1 l2 linuxteam 0 Sep 29 13:04 /tmp/l2file
is l3 user can modify /tmp/l2file? no
other than l2 none of the user has permissions
rw-------
6 0 0
7 5 5
every one can execute that program
7 5 0
only owner and group member has execution permissions
root
-rw-r--r--. 1 root root 2410 Sep 8 07:37 file3
drwxr-xr-x. 2 root root 6 Sep 8 07:45 tdir1
normal user
drwxrwxr-x. 2 ram1 ram1 6 Sep 29 12:52 ramdir1
-rw-rw-r--. 1 ram1 ram1 0 Sep 29 12:52 ramfile1
chmodo+rwx /tmp/l2file.sh
granting rwx(7) full permissions to other users
chmod o-rwx /tmp/l2file.sh
removing permissions to others
chmod g-rwx /tmp/l2file.sh
removing permissions to group members
chmodg+rx /tmp/l2file.sh
granting read and execution permissions to group members
on directory
if you want to apply permissions on parent directory and sub folders or files
then we have to use R (upper case R)
/tmp/test
chmod -R 770 /tmp/test
OWNER
only root is permited to change ownership on file or directory.
chown l1:linuxteam /tmp/l2file.sh
normal user:
777 666
002 002
==== ====
775 664
===================== /etc/profile
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
===========================================================
what is the root user uid? 0
normal users uid start from ? 1000
[ $UID -gt 199 ] as per this logic norma users comes under true condition
so 002 umask apply.
because normal users uid start from 1000 [$1000 -gt 199];
for root
[0 -gt 199];
0 is not greater than 199 so false . apply the else condition umask 022
0777
0 = no special permissions
1 = sticky bit
2 = set gid
4 = set uid
rwxrwxrwx
u g o
user group others
7 7 7
r=4
w=2
x=1
*** difference between chmod and chown?
chmod is for change permissions on file or directory but chown is for chage
ownership from one user to other user.
umask 0000
666
umask 0077
600
later one of user asking need permision on your file
or every asking grant read permissions only on one particular file
chmodo+r file1
============================================Sticky bit======================
Special permissions
1. Sticky bit
2. Set uid
3. Set gid
4. ACL
***** What is sticky bit? Sticky bit: everyone can use the directory but each other
can not modify or delete others files/directory.
==================================================================================
how to get the ip and connect through putty?
step 1: get the ethernet card name
ip a
eg: ens33
eno33445
step 2 : open below file using vi
vi /etc/sysconfig/network-scripts/ifcfg-ens33
ONBOOT=yes
make sure ONBOOT=yes is yes in ifcfg-ens33
step 3 : restart the network service
systemctl restart network
ip a
reffer 2: here we can see inet: 192.168.***.*** this is your ip address
ACL,setuid&setgid
==============
eg: there is a file, none of the user has any of the permissions.
only one person asking read only permissions.
u= user
g= group
-m = multiple
-x = excluding user from acl list
how to remove all the users from acl list?
setfacl -R -b /HRDATA
1. Soft link
2. Hard link
4. soft link file will not be accessible incase orginal file is removed 4.
still links will work incase orginal
file deleted
ln -s /etc/sysconfig/network-scripts/ /
==========================================Find==============================
grep : we can search string(word) in file or files.
find : is for search file or directory with multiple clues or options.
owner: -user
find / -type d -user prasad
searching directories which owned with prasad user
yyyymmddhhmin:sec filename
-a access time -m modify time -t time stamp
-mtime - Days
file or directory modification date and time
find /bkp -mtime +365 -mtime -1200
greater than +365 days modified files/directories and less than 1200
days
-mmin - min
find files which created or modified with 30 min
find /var -type f -mmin -30
find files which are created with in 1 hour
find /var -type f -mmin -60
2 hours
-mmin -120
====================================LVM============================
Logical volume manager
Volume = disk
Disk management:
1. Normal method (fdisk)
2. LVM (Logical volume manager)
3. RAID
/dev/sdf1 /db01
mount /dev/sdf1 /db01
Physical platform
virtual platform (vmware)
cloud platform(aws,azure,gcp)
LUN = Logical unit number nothing but virtual disk in storage box.
OS team responsibilities:
task 1 : Login to server and refresh the channels(2 channels) 2 hba cards 2
channels
/sys/class/scsi_host/host0 is nothing but hba card 1
/sys/class/scsi_host/host1 is nothing but hba card 2
- - -
C t l
c = channel
t = target
l = lun
Suppose there are 4 hba cards then how many hosts we have to refresh
/sys/class/scsi_host/host0
/sys/class/scsi_host/host1
/sys/class/scsi_host/host2
/sys/class/scsi_host/host3
step 1 : we will fill the storage request form with wwn and required
size
we will open ticket with storage team with storage request form.
step 2 : storage team will acknowledge ticket and create lun& map to
server
step 3 : once they attach or map lun to server we will refresh the hba
card channels using echo command.
now we can see disks at os level
echo " - - - " >> /sys/class/scsi_host/host0/scan
echo " - - -" >> /sys/class/scsi_host/host1/scan
step 4 : create common name for disks
eg : /dev/sdb ==/dev/mpath1
/dev/sdc=== /dev/mpath1
step 1: execute multipath -ll command and note down the lun logical
number
step 2 : update logical number with common name in /etc/multipath.conf
file
vi /etc/multipath.conf
multipaths {
multipath {
wwid360060e801532bc00000132bc00009080 -- new lun id
alias altboot0
}
}
multipath -r
to reload multipath configuration
multipath -F
to flush unused luns
we were having physical machines there i used to work with multipath command.
once after lun map to server then we used refresh the hba card channels and
create common name for lun(disks).
Step 1: Open case with vmware team to create new disk. While creating ticket
we have to mention only sever name and size of the disk.
Step 2: Vmware team creates new disk and confirm us
Step 3: We will find out new disk using lsblk or lsscsi command
Then convert that disk as a PV and use for lv
Scenario 3: How to get disk for cloud (micro soft azure) machine
step 1 : we will login to azure portal and search for that particular
server
step 2 : we will click on disks tab and attach new disk
step 3 : we will find out new disk using lsblk or lsscsi command
then convert that disk as a pv and use for lv
step 1 : we will open request with vmware team to attach disk with required
size. (VMWARE platform)
we will open request with storage team along with storage request
form in ticket (Physical platform)
we will login to azure portal and attach new disk to server.(Cloud
platform)
step 2 : we will refresh the channels once we get confirmation from vmware
or storage team.
echo " - - - " >> /sys/class/scsi_host/host0/scan
echo " - - - " >> /sys/class/scsi_host/host1/scan
step 3 : we will convert disk as pv using pvcreate command
pvcreate with disk path
pvcreate /dev/sdf
step 4 : create new vg with new pv using vgcreate command
eg: vgcreatevgnamepvname
vgcreateappvg /dev/sdf
step 5 : create lv with required size in vg. using lvcreate command
lvcreate -L means labelling size and required size 10G then -n name
for lv and vgname
lvcreate -L 10G -n applv01 appvg
step 6 : format lv with any of the file system type using mkfs.xfs and
absoulute path of lv
mkfs.xfs /dev/appvg/applv01
step 7 : Create directory or mount point and mount the lv to particular mount
point. using mount command we can mount lv
mkdir /application1
mount /dev/appvg/applv01 /application1
step 8 : add mount point details in /etc/fstab for permanent mount . entries
like
<devicename> <mountpath> <file sytem type><default
permissions><metadata backup>< file system checkup>
/dev/appvg/applv01 /application1 xfs defaults 1 2
done
once we get cofirmation from respective team that disk is attached then we
will refresh the channels to reflect disk at os level
step 2 : once disk is avaialble at os level then we will convert that disk
as pv and add pv into existing vg
eg : disk is sdh then
Pvcreate /dev/sdh
Add new pv into existing vg using vgextend command
Vgextendtvg /dev/sdh
step 3 : we have enough space in vg after adding new pv into vg so we can
extend lv space using lvextend command
Lvextend -L +10 G absolute paths of lv and -r
Lvextend -L +10G /dev/tvg/tlv01 -r
What is -r resize2fs
Earliear we used to execute 2 commands to extend lv space
Lvextend -L +10G /dev/tvg/tlv01
Ext3, 4 resize2fs /dev/tvg/tlv01 to reflect space to the
partition
xfs_growfs /dev/tvg/tlv01
1. Architecture of LVM
2. How to get disk for Physical machine, virtual machine and cloud virtual
machine
3. Create partition from scratch
4. Extend partition space in online
ext2
ext3
ext4 lv reduce can possible
xfs lv reduce can not possible
***** Scenario 3 : How to reduece partition space which is created in LVM method
==============lvreduce can possible in ext3,ext4. Not possible with xfs partition
step 1 : we will unmount the partition once we recieve approval for unmount
note : we will verify any body using partition, if no one is using then we will
unmount.
***** how to find out any body using partition or not?
fuser -v /app3
or
Lsof +D /app3
lsof +D /app3
lsof command will list out which are the processes are running in
/app3 directory.
Step 2: repair or adjust the file system sectors using e2fsck command
e2fsck -f /dev/appvg/applv03 -y
-f forcefully
-y= yes go ahead and repair incase there are bad or corrupted sectors.
Step 3: adjust the size using resize2fs command. Here we will define size how much
we want to keep for the partition.
eg : the current size of partition is 10 GB in that i want to take out 6 size
or keep size to 4 GB only then resize2fs /dev/appvg/applv03 4G
The current size is 10 GB that we want to reduce to 4 GB
resize2fs /dev/appvg/applv03 4G
step 1 : we will identify which are the lvs part of faulty disk using pvdisplay
command.
pvdisplay -m /dev/sde
step 2 : get new disk with equal size of faulty disk
we can verify are the lvs are moved from /dev/sde to /dev/sdi
pvdisplay -m /dev/sdi
here we can find the lvs
now /dev/sde is free none of the lvs are running so we can remove it from vg
and remove it from pv list
Step 5: remove faulty pv from vg and pv list
vgreduceappvg /dev/sde
pvremove /dev/sde
backup and archive directories are important to backup and restore the
vg level changes.
backup = backedup vg before one of the activity(lvremove,lvreduce,lvextend)
vgcfgbackup -f /tmp/appvg-bkp-19-10-2021.vg appvg
restore = restore the changes using latest backup vgcfgrestore -f /tmp/appvg-
bkp-19-10-2021.vg appvg
restoring
vgcfgrestore -f /tmp/appvg-bkp-19-10-2021.vg appvg
LV Snapshot
========================
lv snapshot will occupy only 6 % of actual lv. because snapshot will backup only
meta data of lv, so 6 % of lv size is enough to backup lv.
snaphot will keep grow based on changes in original lv.
disable/enable lv
lvchange -an /dev/vg/lvname
-an activate no = disable
lvchange -ay /dev/vg/lvname
-ay activate yes = enable
disable/enable vg
vgchange -an vgname
vgchange -ay vgname
disable/enable pv
pvchange -xn /dev/sde
pvchange -xy /dev/sde
refresh commands
pvscan
vgscan
lvscan
group 1 : linuxteam
user = prasad by default each and every user will have group
useradd -g linuxteam -G prasad babu
creating babu user and making primary group is linuxteam for babu and also he is
member into prasad group.
what is the primary group of babu? linuxteam
if babu creates file or directory ownership will be like
babu linuxteam filename
RAID
====================================================
Redundant = backup
redundant = High availability(HA)
eg: using raid we can create multiple disks as a array and in that any one of
disk fails also there will not be any impact.
RAID Levels
============
RAID 0
RAID 1
RAID 2
RAID 3
RAID 4
RAID 5
RAID 6
RAID 0 +1
RAID 1 + 0
RAID 0 = Stripping
the data will be devided and written in all the array disks.
RAID 1 : Mirroring
RAID 2 : Stripe with parity ( data transfer happens in Bits instead of blocks)
the dta will be devided and written in all the array disks and
parity(metadata) will store in dedicated disk.
suppose 1 GB data will be devided between 2 array disks
disk 1 = will have 512 MB
disk 2 = will have 512 MB
dis : data transfer happen in bits so performance will be too slow
requirement = 3 min disks
RAID 3 : Stripe with parity ( data transfer happens in Bytes instead of blocks)
the data will be devided and written in all the array disks and
parity(metadata) will store in dedicated disk.
suppose 1 GB data will be devided between 2 array disks
disk 1 = will have 512 MB
disk 2 = will have 512 MB
dis : data transfer happen in bytes so performance will be too slow
requirement = 3 min disks
RAID 4 : Stripe with parity ( data transfer happens in blocks)
the dta will be devided and written in all the array disks and
parity(metadata) will store in dedicated disk.
suppose 1 GB data will be devided between 2 array disks so performance will
be too good.
disk 1 = will have 512 MB
disk 2 = will have 512 MB
adv : full redundency and good performance.
requirement = 3 min disks
RAID 5 : Stripe with parity ( data transfer happens in blocks)
the dta will be devided and written in all the array disks and
parity(metadata) will store across all the disks.
parity will store arcoss all the array disks.
suppose 1 GB data will be devided between 2 array disks so performance will
be too good.
disk 1 = will have 512 MB
disk 2 = will have 512 MB
adv : full redundency and good performance.
requirement = 3 min disks
***** in raid 4 we were dedicating 1 disk for parity so we were not able to use
last disk for data store purpose that is fine how about in RAID 5?
in raid 5 we were able to store data across all the disk so can use full
capacity?
ans : no we can not use full capacity for data store purpose because algorithem
designed like 1 disk capacity should go for parity.
eg : 3 disks with 100 GB what is the data store capacity? 200 GB
3 *100 =300 but as per design or algorithem we can store only 200 GB
pre-requisites:
3 disks and converted as pv's
note: make sure 3 disks are with equal size(100 GB)
create single vg with 3 pv's
now what is the vg capacity? 300 GB
create lv with stripped raid level.
create pv
pvcreate /dev/sd{e,f,g}
create vg
vgcreateappvg /dev/sd{e,f,g}
create lv
lvcreate -L 14.9G -i 3 -I 128K -n tapp1 appvg
verify lvs with type
lvs --segment
types
linear = normal lv
stripped = raid 0
1024 * 1 M= 1GB
1024 * 1G = 1 TB
du -hs/testfile1gb
date && cp /testfile1gb /app1 && date
Thu Oct 21 13:21:44 IST 2021
Thu Oct 21 13:21:55 IST 2021
=========================================================================
mdadm with lvm
mdadm --create /dev/md5 --level 5 --raid-devices=3 /dev/sde /dev/sdf
/dev/sdg
vgcreateappvg/dev/md5
lvcreate -l 100%FREE -n applv001 appvg
=============================================================================
how to get the details of md partition?
mdadm --detail /dev/md5
install
un-install
upgrade
update
query(information)
to do above tasks there are 2 default methods
1. RPM (redhat)
2. YUM (redhat)
1.RPM(suse)
2.zypper(suse)
Vsftpd-3.0.2-28.el7.x86_64.rpm
i = install
v = verbose (100%)
h = print hash(#) symbols based on how much % installed
v & h are mandatory for install package? no v & h doen't required to install
which is mandatory option ? -i
QUERY options
============
rpm -qa
-q = query
a = all installed softwares/packages
***** how to install package without dependencies? we can include --nodeps in rpm -
ivh command
main pkg
dependencies
pkg1
pkg10
pkg11
pkg12
pkg2
pkg13
pkg14
dependencies for pkg14
pkg15
pkg16
pkg3
dependecies for pkg3
pkg17
sequence order
pkg17,pkg3,pkg16,pkg15,pkg14,pkg13,pkg2,pkg12,pkg11,pkg10,pkg1,main pkg
query:
rpm -qa
rpm -qdpkgname = documents of pkg
rpm -qi pkgname = information about pkg
rpm –ql pkgname = List out files inside pkg
rpm -qc pkgname = list out the configuration files
rpm –qf filepath
eg: rpm -qf /etc/fstab
qf will tell you so and so file created by which pkg
***** unfortunatly /usr/bin/chmod command has been deleted? how you can recover
that?
step1 : login to other machine and find out chmod command is generated by
which rpm
using rpm -qf /usr/bin/chmod
here i will come to know which rpm is generated chmod command so then i can come to
problematic machine and try to install the pkg which is generates chmod command.
with help of rpm -qf /usr/bin/chmod
identified pkg is coreutils is the pkg which generated chmod command
step 2 : login to machine where we have deleted chmod command and re-
install the coreutils pkg
rpm -ivh coreutils-8.22-21.el7.x86_64.rpm --force
***** how to know recently installed pkgs?
rpm -qa --last
upgrade is nothing overwritting the old pkg. after upgrade we can find only
latest.
recommended partitions?
/boot = 512 MB
/var = 3 GB
/tmp = depends on
swap = equal or double or thrise of RAM
/home = depends on
/ = Min 5 GB
rpm & yum both are in house tools to perform package management.
yum has more features compare with RPM
explanation:
[rhel75] and name these 2 lines specifies name of the repository.
baseurl= packages path
gpgcheck= authentication 0 no authentication for clients freely they can
access repository
gpgcheck=1
gpgkey=/etc/keys/kkk same key should be in client machine
enabled=0 is nothing disabling repository
enabled=1 is nothing enable repository
Step 2 : test the network connectivity from client machine to yum repo
system
ping <yumserverip>
ping 192.168.145.172
telnet 192.168.145.172 21
result should be connected
sometimes telnet command not found in that case
please install telnet package
telnet 192.168.145.172 21
Trying 192.168.145.172...
Connected to 192.168.145.172.
Escape character is '^]'.
220 (vsFTPd 3.0.2)
to comeout
ctrl key ]
quit
baseurl=file:///var/ftp/pub/rhel7.5
client baserul=ftp://192.168.145.172/pub/rhel7.5
RHEL 7.0 yum update
RHEL 7.1
RHEL 7.2
RHEL 7.3
RHEL 7.4
RHEL 7.5
RHEL 7.9
RHEL 7.10
RHEL 8.0
RHEL 8.1
Satellite server
Satellite:
it's a service which is providing by Redhat. using satellite easy perform
packagemanagement.
it's a centralized repository. all the clients can use satellite for packages.
satellite tool developed by redhat company.
redhat = satellite
suse = suma
in the dash borad we can see hosts. in hosts we can find our server which we
registered recently.
repositories will update in client machine automatically once after register
server with satellite.
yum clean all
yum repolist
no need to update any parameters in /etc/yum.repos.d/local.repo
L1 = <3
L2 = >3 <6
L3 = >6<9
SME(subject mater expert) = > 9 and < 15
Architect = > 15 Yeas of experience
3. How to unregister server with satellite server
subscription-manager unregister
or
login to satelite web portal
in browserver type
http://satelliteserverip
username:
password :
in dash borad we can see systems tab there we can select respective
server and remove
DASHBOARD ==> Hosts ==>servername==> unregister
Redhat:
in client machine patching procedure
make sure server is registered with satellite
yum update
yum install mariadb-server
suse:
in client machine patching procedure
make sure server is registered with suma manager
zypper update
zypper install mariadb-server
***** How to check is the server is registered with suma server or not
Login to suma server and search for server in systems list
or
SUSEConnect --status-text
environments:
1. production
2. DR
3. pre-prod
4. QA
5. Dev
for Accenture ADM is a one of project. for this may 15 members are supporting
with 24/7 support.
A Shift ( 6 to 3 PM)
B Shift (2 to 11 PM)
C shift (10 to 6 AM)
first code testing will start from ====> dev ====> QA ====> pre-prod ==> prod ===>
DR
os patching ====> dev ====> QA ====> pre-prod ==> prod ===> DR
TEAM
Unix team we come under unix team (redhat,suse,solaris,hpux,
aix)
Windows team
VMWARE team or Cloud team
application team
DB team
Backup team
network team
PM team (project management team)
what is the use of PM team? they are the co-ordinators for change implementation
PM role is
below teams has to involve to perform patching
1. Unix team
2. App team
3. DB team
4. backup team
co-ordination done by PM team person(change manager).
while starting
db team start the db
app team start the app
app team validate the application functionality
roll back incase app/db team saying something is not working as expected
reboot
step 5 : incase os version still not showing old version then downgrade the
redhat-release package
yum downgrade redhat-release pkg
=======================BOOTING
PROCEDURE=============================================
OS booting procedure
if server is booting up and giving login prompt then fine every one can acess
the server
incase server is not booting up. it's struckup in between? then who has to
troubleshoot ? OS administrator
post identified RAM issue then imediatly post program will give
continues beep sound.
post identified HARD disk issue then imediatly post program will give
error message on screen like disk not found.
booting will stop here itself incase post identified any critical
components faild.
BIOS
=====
1. POST
2. CMOS (complementary metal-oxide semiconductor)
3. BIOS
CMOS chip which will collect critical information before server goes down.
like date and time, RAM processes, processes whatever were running
before server goes down.
cmos will return the critical information back to RAM(main memory) whaterver
is collected before server goes down.
cmos will return the updated date and time, critical processes whatever
were running these kind of information will give it back to RAM.
BIOS:oncecmos pass critical information to RAM then BIOS will identify bootable
disks(hard disk, usb, CD ROM).
and look for MBR.
CD
USB
HDD
network
in bios if the first priority of boot device is CD then BIOS will try to find
out MBR inside that CD if OS not found then
link : once BIOS found the MBR data in first sector then pass control to MBR
incase os not found in cd,usb,hdd,network then finally BIOS will print error
message like os not found.
Stage 2 : MBR (Master boot recorder)
MBR stores in first sector of the bootable device like hard disk or CD.
MBR maintains the next stage information that is grub information.
mbr capacity is what ? 512 bytes or 1/2 kb
eg : 7.0
7.2
7.5
7.9
in grub screen we can see all 4 kernel information , here end user can select
which one want to boot up.
0 RHEL OS
1 windows OS
2 Solaris
grub2-set-default 1
then Windows OS is going boot in next boot up.
grub will verify default kernel set in /boot/grub2/grub.cfg and pass control to
particular kernel.
Stage 4: Kernel
/boot/ initramfs and initrd programs will co-ordinate and load the drivers and
modules
initrd is the program which will loads the drivers and modules with help of
initramfs.
once / file system is mounted in read only then automatically initramfs will
unmount.
RHEL 7 & 8, now kernel will pass control to next stage that targets or systemd
RHEL 5,6 , now kernel will pass control to runlevels
Runlevel 0 (shutdown)
Runlevel 1 (single user mode)
Runlevel 2 (command mode without nfs)
Runlevel 3 (command mode with nfs)
Runlevel 4 ( Research and development mode)
Runlevel 5 ( gui) graphical user interface
Runlevel 6 (reboot)
init 3
it go to runlevel 3
init 1
it go to runlevel 1(single user mode)
init 5
it go to gui mode
in systemd stage systemd program is going to look for default target and pass
control to default runlevel or target.
how to disable particular service which should not start during boot up.
systemctl disable vsftpd
how to enable particular service which should start during boot up?
systemctl enable vsftpd
let me explain about stage 1 BIOS full form of BIOS is Basic input output system.
this stage purly belongs to Hardware.
now control at MBR it is stage 2. MBR full form is Master boot recorder.
==> MBR stores in first sector of boot device.
==> the sector capacity is 512 bytes.
==> MBR maintaince the next stage information that is GRUB informaiton.
==> MBR pass control to next stage once it finds the valid GRUB.
Now control at GRUB it is stage 3. GRUB full form is Grand unified boot loader
==> GRUB maintaince the installed kernels information.
==> GRUB pass control to kernel which is mentioned as default in
/boot/grub2/grub.cfg
Now control at Kernel stage that is stage 4.
==> Kernel Loads the modules and drivers with help of initramfs and initrd
programs.
these initrd and initramfs files will be in /boot directory.
==>Initramfs is temporary / file system which contains library and
configuration files which will help to load drivers and modules.
==> then / file system will mount in read only mode once after load driver
and modules.
==> then executes the systemd program once after mount / file system in read
only mode.
now control at target stage. this is last stage here all the start up programs will
start parlelly and gives login pages.
===================================================================================
====
interview questions in booting procedure:
1. what is the first process of Linux machine
systemd in rhel 7 & 8
initd in rhel 5 & 6
2. what is the process id of systemd or initd
1
3. what is initramfs?
initramfs is a temparary / file system.which contains libraries and
configuration files.
===================================================================================
====
yum install graphical*
yum install x11*
======================Network======================================================
===
what is network?
creating connectivity between 2 components for data or voice transfer.
3 types of networks
=================
1. Intranet (LAN) creating network within building
2. Extranet (MAN) creating network with in CITY (branches)
3. Internet (WAN) public. Can connect to any other public network
Relieance
airtel
ISP(internet service provider) they will drag cable from one area to
another area
wifi or towers
router1 (EC) ==> router2 (silkboard) ==> router 3 ( agara) ==> router 4
(marathahalli) ==> router 5 (whitefield)
3. Internet
with help of ISP (internet service provider ) we can reach out to public
networks.
accessing what's up, accessing icici net banking, accessing facebook,
accessing youtube these websites are in public network.
Network components
===============================
1. Swtich
2. Router
3. Firewall
4. Load balancer
Home = address
System = IP address
Laptop = IP address
Server = ip address
System 1 =============> system 2
Ip ip
Then only system1 can connect to system2 through unique ip address
IP (internet protocol)
================
IPV4 (32 bit) 192.168.145.20
IPV6 (128 bits) 4010:DDA7:1000:1111:2A3B:5BBA:CDA4:1001
IANA (Internet assigned number authority) it's network community. Who is take
decissions of network?
IPV4
=======
IPClasses 1-255 private
pub
A Class 1 -126 = network 10
B Class 128 - 191 = network
C Class 192 - 223 = network
D Class 224 - 239 = Multicasting (live channels, like TV channels
or live streaming)
E Class 240 -255 = R & D (research and developement)
127 is reserved for loop back
127 are the common ip in each and every system or server or
mobile device.
Requirement: server 1 want to connect with server 2 through Ssh service then which
network component is going to involve?
Ethernet card at both systems
Server 1 ethernet card will send request to server 2 ehernet card.
***** What is use of loop back ip?
Services will communicate each other through loop back component within
system.
IPV4
=======
IPClasses 1-255 private public
A Class 1 -126 = network 10
1,2,3,4....9, 11, and 12......126
B Class 128 - 191 = network 172.16.0.0 to 172.31.0.0
128,129,130...171,173,174
C Class 192 - 223 = network
D Class 224 - 239 = Multicasting (live channels, like TV channels
or live streaming)
1-126 numbers are there in A Class in this starting 10 number is reserved for
private ip.
How 1 number can enough for big companies or big networks.
10. 1.1.1
00001010 00000001 00000001 00000001
10 . 1 . 1 . 1
8bits 8 bits 8 bits 8 bits
= 32 bits
10.1.1.1
Number is going to convert as binary.
10.1.1.1
10.1.1.2
10.1.1.3
10.1.1.4
10.1.1.5
10.1.1.255
10.1.2.1
10.1.2.2
10.1.2.3
10.1.2.4
10.1.2.255
10.1.3.1
10.1.3.2
1 *255*255*255 =
15 * 255*255 =
1*255*255 =
B class private ip
172.16.0.0 to 172.31.0.0
172.16.255*255
15 * 255*255 =
C Class private IP
192.168.*.*
1*255*255 =
172.16.1.1
172.16.1.2
00000001
1 =2*0= 1
0 = 2*1 = 0
0 = 2*2= 0
0 =2*2*2 = 0
0 =2*2*2*2 =0
0 =2*2*2*2*2 = 0
0 =2*2*2*2*2*2 =0
0 =2*2*2*2*2*2*2=0
00001010
0=2*0= 0
1=2*1= 2 <=====
0=2*2=0
1=2*2*2 = 8 <=====
0=2*2*2*2 =0
0=2*2*2*2*2 = 0
0=2*2*2*2*2*2 =0
0=2*2*2*2*2*2*2=0
2+8=10
1=2*0=1
1=2*1= 2
1=2*2=4
1=2*2*2=8
1=2*2*2*2=16
1=2*2*2*2*2=32
1=2*2*2*2*2*2=64
1=2*2*2*2*2*2*2=128 128+64+32+16+8+4+2+1= 255
255
A class = 255.0.0.0
B class = 255.255.0.0
C Class = 255.255.255.0
IP Netmask
192.168.1.2 255.255.255.0
10.1.2.4 255.0.0.0
IP Assign
=======
We can assign ip in 2 methods
1. Static (assigning ip address manual)
2. DHCP (dynamic host configuration protocol) there will be a one
server who will assign the ip address to other systems which are coming.
Step 1: open the ehernet card file and do the below changes
VI /etc/sysconfig/network-scripts/ifcfg-ens33
ip a
There should be ip
===================================================================================
===
1.Ping:
sync: ping <remote machine IP>
using ping we can test the network connectivity between one machine to
another machine.
using ping we can test the route between one machine to another
machine.
***** what protocol used by ping?
ICMP(internet control message protocol)
***** what is the port number of ICMP?7
2. Telnet
=======
sync: telnet <remote machine IP ><portnumber of service>
bus = ftp
train = ssh
ftp is the service . for each and every service has one reserved port number also
ftp = 20/21
telnet = 23
ssh = 22
nfs =2049
samba = 137,138,139
ntp = 123
http = 80
machine 1 = 192.168.43.10 we are in machine from here we want to test service
status in machine 2 (192.168.43.133) on ssh service(22)
telnet 192.168.43.133 22
3. Nmap
========
n map also is used for test service status in remote machine
sync: nmap<remote machine ip>
***** How to know which the ports are opened in remote machine or how to scan what
are the ports are allowed in remote machine
nmap 192.168.43.133
or
nmap 192.168.43.133 -p 22
4.NC(Net cat)
=================
nc is alternate command for telnet
we can prefer to use nc instead of telnet. many of the organizations will not
allow to use telnet but nc is allowed.
because network hackers can easyly reach remote machine via telnet not via nc so
which is recommended? nc
nc -uvz 192.168.43.133 22
5.TRACEROTE
==============
is used for test the route between one machine to another machine
sync : traceroute 192.168.43.133
server 1 ===> switch 1 ==> router1 ==> firewall ==> router2 ===> switch 2
===> server2
hub1 hub 2 hub 3 hub 4
hub 5 hub 6 hub 7
started here
traceroute can tell which component is not allowing packetet.
errors:
no route : might be firewall is blocking in the remote machine.
login to remote machine and stop the firewalld service
connection refused: might be service is not running in remote machine.
login to remote machine and start the service.
***** How many additional ip's can possible to assign sing ethernet card?
256
***** How to assign additional IP addresses to ethernet card?
BOOTPROTO=static
IPADDR0=192.168.43.10
IPADDR1=192.168.43.11
IPADDR2=192.168.43.12
PREFIX0=24
NETMASK=255.255.255.0
GATEWAY=192.168.43.1
192.168.43.0/24
===========================NIC Bonding=========================================
configuring HA(High availability) between ethernet cards that is nothing but NIC
bonding.
MODE0=RR(round robin)
both the ethernet cards will be in active
traffic will be passed to both the ethernet cards
Load will be devided between ehternet cards because both are active and ready
accept load(traffic)
MODE1= AB(Active & Backup)
at a time one ethernet card will be active and other card will be in
backup mode.
only one ethernet card will accept the load
bit slow performance compare to RR.
if second ethernet card file is not exist then copy data from first ethernet
card and do the changes like device name and ethernet card name and all.
step 3 : create new virtual ethernet card and configure the bonding
vi /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.43.100
NETMASK=255.255.255.0
GATEWAY=192.168.43.1
PREFIX=24
BONDING_OPTS="mode=1 miimon=100"
SERVISES
=============================FTP====================================
configuration file: it's a controller for your service. here we can define which
users are allowed through ftp and which are the users need to deny.
we can define service functionality inside configuration file.
Service = service(vsftpd) should allow clients or not. service is running client
can connect. if service not running then clients(remote machines) can not connect.
Daemon = he is a background worker for service.
daemon is a background process for service. he is actual worker.
About FTP:
1. FTP is a very fast,stable and efficient service to transfer files over the
intranet and internet
2. FTP can support both that is LAN(intranet) and WAN(Internet).
3. FTP service can support only file transfer not directories.
4.FTP service transfer data in binary format(010101) .
very easy to covert binary format to text. easily we can see what data is
traveling.
even root and root user password can be extracted.
FTP serverside:
1. install vsftpd
2. start the vsftpd service (systemctl start vsftpd&&systemctl enable vsftpd)
3. disable firewall service(systemctl stop firewalld&&systemctl disable
firewalld)
4. disable selinux
vi /etc/selinux/config
SELINUX=enforece
to
SELINUX=permissive
setenforce 0
5. create user in server .these credentials are using by clients
useradd b25user
passwd b25user
ls = remote command
!ls = local command
pwd = remote command
!pwd = local
cd =remote
lcd = local
get = download file from remote to local
put = upload file from local to remote
mget = download multiple files from remote to local
mput = upload files from local to remote
active : client will decide the the data port at server end
20 is fixed port number for transfer data.
client sends data port to server what port he already opened for data.
who decided data port ? client now server will connect 20 ===> 55000
which is decided by client. 55000 port is decided by whom?
client
passive: server will decide the data port for client.
now client has to accept data port which is opened by ftp server
===============SSH======================================
ssh=secure shell
ssh is used for transfer data in secure manner.
=======================================================
advantages:
1. security: data will travel in very secure manner. becuaseseperate tunnel
is creating and transfer data inside tunnel that to in encryption format.
in ftp: data travel in binary format . it's very easy to hack and
extract
2. we can transfer files and directories
in ftp: using ftp we can transfer only files
3. even administration can possible through ssh service.
all commands will work through ssh
how to connect from one machine to another linux machine using ssh?
sshusername@ipaddressofothermachine
or
ssh -l username ipaddressofothermachine
ssh [email protected]
ssh -l babu 192.168.43.100
vi /etc/ssh/sshd_config
DenyUsers oracle prasad babu
step 2: Restart the ssh service to reflect changes
systemctl restart sshd
usually we will disable application and database users through ssh service.
eg: oracle is the common user which will be used by full database team.
suppose 10 members are in db team then 10 members required oracle
user password so here oracle is common user like root.
we have to disable common users through ssh service.
server 1 : 192.168.43.133(babu)
server 2 : 192.168.43.100(babu)
requirment: 133 machne babu user want to connect with 100(babu) user without asking
password each and every time.
133 machine want to connect to 100
133 has to trust 100 and 133 has to share his public key with with 100.
ssh-keygen
step 2 : copy public key and put it in remote machine
ssh 192.168.43.100
su - babu
mkdir .ssh
chmod 700 .ssh
cd .ssh
vi authorized_keys
past copied public key here
chmod 600 authorized_keys
done
now we can try to connect from 133 machine to 100 machine as a babu user
ssh [email protected]
or
alternative method to configure password less between 2 machine
ssh-keygen
step 2 : push the public key to remote machine
ssh-copy-id -i /home/babu/.ssh/id_rsa.pub [email protected]
HWADDR=00:0C:29:E2:BC:B2
TYPE=Ethernet
BOOTPROTO=dhcp
NAME=ens33
DEVICE=ens33
ONBOOT=yes
===================NFS===========================================================
Network file system
using NFS we can put(export) file system(disk) in network and client can
access the nfs file system based on requirment.
can possible to apply ACL(access control list) on NFS file system.
NFS is nothing but centralized network file system.(same reflection to all
the clients)
FTP = transfer files(connect and get or put files)
ssh = transfer files/directories(connect and transfer files/directories)
NFS = we can mount network file system in client machines. they can feel as it is a
local file system.
client machine
/data = xfs file system
/ndata = nfs file system
cp /data/file1 /ndata
copying file from local to nfs file system.
server side:
step 1 : make sure nfs-utils pkg is installed
step 2 : export the directory which we decided
mkdir /ndata vi /etc/exports
/ndata *(rw,sync)
or
granting access to particular server
/ndata 192.168.43.11(rw,sync)
client side:
========
step 1: make sure nfs-utils pkg is installed
step 2 : test the connectivity between client to nfs server on 2049 port
number
ping 192.168.43.100
telnet 192.168.43.100 2049 or nc -vz 192.168.43.100 2049
================================================================
vi /etc/exports
<file system> <systemlevelaccess>(permissions,syncorasync)
/ndata *(rw,sync)
/mdata 192.168.43.10(ro,sync)
/mdata 192.168.43.11(rw,async)
/tdata *(rw,sync,no_root_squash)
sync,async,root_squash,no_root_squash
root_squash&no_root_squash
=====================================
nothing is mentioned either root_squash or no_root_squash then default is
root_squash.
/ndata *(rw,sync,no_root_squash)
/ndata *(rw,sync,root_squash)
***** how to get nfs server version?
nfsstat -s | grep -i "server nfs"
from rhel 7 onswardnfsversion 4 is introduced
NFS V3
NFS V4 (rhel 7 & RHEL 8 ) default version is nfs V4
***** difference between soft mount and hard mount in nfs file system at client
side.
soft mount: in case nfs server is down or not reachable to client machine then
client will try to reach server machine 2 times with 10 min interval, after 2*10=20
after 20 min client will not at all try to reach nfs server for nfs
file system.again manually linux administrator has to mount.
hard mount : in case nfs server is down or not reachable to client machine then
client will keep try to reach until nfs server respond back to client.
no expairy, client continuesly try to check nfs server for nfs file
system.
AUTOFS
mount the nfs file system in client machine as soon as client start using it.
Benif of autofs: we can reduce burden to nfs server. nfs server performance will
improve.
we can save the network bandwidth between nfs client to nfs server machine.
pkg : autofs
service : autofs
daemon : autofsd
config file : /etc/sysconfig/autofs or /etc/autofs.conf
cd /mdata
now nfs file system should mount
***** df -h command output is getting struck. what is the problem and how you can
rectify it.
1.problem may with nfs file systems which are mounted in client machine.
2. client could not able to access nfs file system so df -h will get hange.
problem 1 : may nfs server is down. we can check server status in vcenter if server
is down then we can poweron
problem 2 : may nfs-server serivce down. we can login to nfs server and start nfs-
server service manually. systemctl start nfs-server &&systemctl enable nfs-server
problem 3 : there is not connectivity on 2049 between client machine to nfs server.
from client machine do telnet 192.168.43.100 2049 if not able to
connect then firewall is blocking.
we can ask network team to allow 2049 port between nfs client machine to nfs
server.
even at os lever we have to disable firewalld service
systemctl stop firewalld&&systemctl disable firewalld
problem 4 : may wrong entries in /etc/exports file
even in this situatuionnfs-server service will not start or 2049 port will
not come in listen status
correct
vi /etc/exports
/ndata *(rw,sync)
wrong
/mdata * (rw,sync)
no space required between * and (
wrong
/mdatafoler itself not created in machine. then how nfs server can export.
nfs server is restarted but couln't able to allow one of the client machine
to access the nfs file system. then file system will convert into stale.
at a time 10 client machines are requesting mount point but nfs server
responded only for 8 systems then remaining 2 systems will be in stale.
solution: unmount the nfs file system in client machine & remount it.
====================SAMBA=============================
samba will support cross platforms.like windows to linux as well linux to windows.
cd /root
vi .c
username=b25user
password=test123
chmod 600 .c
now credentials are hidden and only root has access on .c file
mount -t cifs //192.168.43.87/pshare /pshare -o credentials=/root/.c
smbpasswd -d puser
disable the puser from samba list
how to enable user? smbpasswd -e puser
how to delete user from samba list? smbpasswd -x puser
using samba password only we can access linux share from windows
my computer ==> right click ==> add a network location ==> \\192.168.43.100\
sharewindows
***** what is the port number samba? 136,137,138 and 445 at windows side
==============SELINUX,FIREWALLD &TCP/UDP======================================
FIREWALL:
firewall is a security component at network level.
physical firewall : It protects the full network . our server will be under
network. so our server is protected under firewall.
OS level firewall:
redhat = firewalld
window = firewall
using firewall we can write our own rules like which are the source
server are allowed as well we can deny some servers.
physical firewall = will be under network team control. network team will write
rules to allow or deny traffic
OS firewall = OS administrator will write rules to allow or deny traffic.
======================SELINUX==============================================
secured enhanded Linux
se policies
firewall is there to filter packet before we enter system. then what is the
use selinux? se linux will protect inside data.
firewall is outside watch man for system or network
selinux is inside watch man for your critical data.
firewall = secure your network
selinux = protect your data inside server
setenforce 0
0 =permissive
setenforce 1
1= enforcing
sestatus
==============DNS==================================================================
===
DNS=Domain Name system
prasad.edu
prasad.gov not allowed
pre-requisites:
1. assign the static IP to DNS server where we are configuring DNS.
$TTL 86400
@ IN SOA masterserver.b25.xyz. root.b25.xyz. (
2021120701 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
@ IN NS masterserver.b25.xyz.
@ IN A 192.168.43.100
master IN A 192.168.43.100
=============================================
step 3 : configure the main configuration file
/etc/named.conf
options
{
directory "/var/named"; // "Working" directory
dump-file "data/cache_dump.db";
statistics-file "data/named_stats.txt";
memstatistics-file "data/named_mem_stats.txt";
};
zone "b25.xyz" IN {
type master;
allow-query {any; };
file "fwdb25.xyz";
};
===============================================
Step 4 : verify syntax errors in config file and forward lookupzone file
named-checkconf /etc/named.conf
named-checkzone b25.xyz /var/named/fwdb25.xyz
DNS records:
1. SOA (start of authority) f & r
2. NS (name server) dns server entry f & r
3. MX ( mail xchange server entries) f & r
4. A ( address record for IPV4) name to IP F
5. AAAA ( address record for IPV6) name to IP F
6.PTR ( pointer) ip to name R
7.CNAME = cononical name or alias name F
facebook.b25.xyz IN A 192.168.43.120
fb.b25.xyz IN CNAME facebook.b25.xyz
f.b25.xyz IN CNAME facebook.b25.xyz
***** TTL?
time to live
the newly updated records will publish after ttl timeout.
facebook.b25.xyz IN A 192.168.43.20
the above entry will pubish to all after 1 hour ( 9:05) because what TTL? 1
hour
My TTL is 1 d
TTL 1 d
if i add entry now when it will reflect to public or publish
tomorrow same time it will reflect
2021120801 ; serial
1 h ; refresh
30 m ; retry
2 d ; expire
86400 ; minimum
master DNS server = fails or shutdown then slave dns will serve the requests
Slave dns server
vi /etc/resolv.conf
search b25.xyz
nameserver masterdnsserver
nameserver slavednsserver
c shortname
c.b25.xyz. is fully qualified domain name
masterserver is short name
masterserver.b25.xyz. is fully qualified domain name
nslookupclientmachine
================NTP ========================================
NTP = Network time protocol
what is the unique future of NTP service is supplying date and time to remaining
servers.
adv: same date and time across all servers.
to
# Hosts on local network are less restricted.
restrict 192.168.43.0 mask 255.255.255.0 nomodifynotrap
====================================================================
less restricted nothing allowing 192.168.43.* network for time sync
server 127.127.1.0
fudge 127.127.1.0 stratum 10
================================================
ntp client integration
chronyc tracking
***** recieved alert for ntp there is more offset value. how you handle this
inciden
offset more is nothing but delay between ntp client machine to ntp server.
solution : sync
==============================HTTP=============================================
cd /etc/httpd/conf.d
vi mysites.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.site1.b25.xyz
DocumentRoot /var/www/html/site1
</VirtualHost>
step 4 : restart httpd
step 5 : add entry in dns server
vi /var/named/fwdb25.xyz
www.site1 IN A 192.168.43.133
cd /etc/httpd/conf.d
vi mysites.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.site2.b25.xyz
DocumentRoot /var/www/html/site2
</VirtualHost>
step 3 : restart httpd
step 4 : add entry in dns server
vi /var/named/fwdb25.xyz
www.site2 IN A 192.168.43.133
=============================================
step 1 : keep code in /var/www/html location
mkdir -p /var/www/html/site3
copy the web content to /var/www/html/site3
step 2: configure the web page
cd /etc/httpd/conf.d
vi mysites.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.site3.b25.xyz
DocumentRoot /var/www/html/site3
</VirtualHost>
step 3 : restart httpd
step 4 : add entry in dns server
vi /var/named/fwdb25.xyz
www.site3 IN A 192.168.43.133
cd /etc/httpd/conf.d
vi mysites.conf
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName www.site4.b25.xyz
DocumentRoot /var/www/html/site4
</VirtualHost>
step 3 : restart httpd
step 4 : add entry in dnsserver
vi /var/named/fwdb25.xyz
www.site4 IN A 192.168.43.133
httpd logs:
cd /var/log/httpd
1. access_log ===> it contains which user accessed website what time
that details
2. error_log ===> error logs about web page
===================================================================================
====
SUDO
/sbin or /usr/sbin
On these commands normal user will not have permissions. Using sudo we can grant
permissions on super user commands.
Sync:
Suppose i changed hostname like master then useradd command will not work because
the conditition is
in this there are 10 users. as per above line granting 3 commands access to
10 users.
visudo
or
vi /etc/sudoers
because visudo can do syntax verfication and it will not allow you to come
out until you correct the syntax
let normal user switch to root or granting user to switch to root user
========================RSYNC==============================
Using rsync we can copy data from local to remote machine like SCP as we well we
can copy data within machine.
Local to remote
Local to local
ssh:
scp -r /test [email protected]:/tmp/
rsync
rsync -arvz /test [email protected]:/tmp
Advantages:
1. sync only incremental data can possible in rsync
in destination already 1 GB DATA is there
now again we are pushing 1.5 GB same data then only 0.5 data will push
because already 1 GB same.
before copy data to destination rsync does the comparision and copy
only differencial data.
Unzip varlogbkp-10-dec-2021.zip
Gzip : gunzip
zip : source and destination both will exist = zip is backup keeping one
more copy in different location
gzip : only destination will exist after compress
===================JOB Schedulers=============================================
1. AT
2. CRON
AT & Cron
services:
At : atd (systemctl status atd)
cron : crond(systemctl status crond)
at 9 AM 25 dec 2021
> shutdown -r now
ctrl + d
for save job and come out
at now + 1 hour
> touch /atfile
>ctrl + d to save and come out
how to list out scheduled jobs
at -l
atrm<jobid>
=============================================
* * * * * TASK
1 2 3 4 5 6
Min Hours daysinmonth monthsinyear days inweek
00-59 0-23 1-31
1-12 0-6
crontab -e
01 06 * * * task1
***** you will recieve ticket for granting crontab access to normal user.
login to respective server and add user name inside /etc/cron.allow
root can delete any body jobs and list out also.
crontab -u prasad -l
crontab -u prasad -e
***** crontab -e is not working then how you can modify the cron jobs
cd /var/spool/cron
individual files for individual users
from we can open file using vi and modify
vi prasad
how to remove prasad user jobs
cd /var/spool/cron
rm -rf prasad
===========Housekeeping alerts==================================================
in /var what kind of data will be there? logs or history about tasks.
du -ks filename
size display in killo bytes
deleted older than 3 months logs but still /var partition usage is
greater than 90 %. then compress the logs
Action 2 : compress the unwanted data from /var/log
du -hs *
we can see which file is consuming more space then we can take call and
compress the file uzinggzip command
there is unwanted file , the file name is message.20210301
gzip message.20210301
or
find /var/log -mtime +2 -exec gzip {} \;
du = disk usage - we will use it for check current size of file or directory
( du -hs *, du -hs filename)
gzip = gunzip - we will use it for compress the bigger file
rm = remove - to remove any unwanted file/directory
find = find is used for find out older than 3 months log/data and delete or
move from one place to another place
find /var/log -mtime +90 -exec rm -rf {} \;
find /var/log -type f -mtime +90 -exec gzip {} \;
we will get ticket in our linux queue. we will acknowledge the ticket and
work on ticket.
/
/var ===>seperate partition
/tmp ===>seperate partition
/app1 ===> application partition
/db ===>dbpartition
/lib part of /
/usr is part of /
/root is part of /
/etc is part of /
/usr/share occupies 3 GB
action 1 : we will remove in case any unwated data kept by any normal user.
action 2 : compress the importent data
action 3: extend the / partition space
***** how to know when this file is copied or created? who is the owner? what is
the size of that file ?
when this file is copied or created?
ls -ld /tfilebyprasad
or
stat /tfilebyprasad
who is the owner? ls -ld/tfilebyprasad or stat /tfilebyprasad
what is the size of that file?
du -hs /tfilebyprasad
Hi Prasad,
=========================
/applications
/db
OS
==============
/
/boot
/var
/tmp
alert 3 : /boot partition is full : cleanup the old kernel data from /boot
partition. not possible to extend the /boot partition becuase created as standar
partition.
/boot wont support LVM.
eg : kernel 1 : 3.10.0.256
kernel 2 : 3:10.0.520
initramfs-3.10.0.256.x86.img
initramfs-3.10.0.520.x86.img
initrd-3.10.0.256.x86.img
initrd-3.10.0.520.x86.img
initramfs-3.10.0-123.el7.x86_64.img
initramfs-3.10.0-123.el7.x86_64kdump.img
initramfs-3.10.0-862.el7.x86_64.img
initramfs-3.10.0-862.el7.x86_64kdump.img
initramfs-3.10.0-110.el7.x86_64.img
initramfs-3.10.0-110.el7.x86_64kdump.img
110
123
862
which is latest kernel? 862 something goes wrong with 862 then we can revert with
123 so 110 is unimportant.
/ lvm
/boot standard
/var lvm
/tmplvm
=====================SWAP============================
creating swap:
step 4:mount -a
swapon -a
free -m
swapon -a
-a = all swaps
removing swap:
step 1 :swithch off the swap
swapoff /dev/rhel/swap1
step 2 : remove swap1 entries from /etc/fstab
step 3 : delete the lv
lvremove /dev/rhel/swap1
***** some tasks/processes are struck in swap. how we can move from swap to RAM
forcefully.
switch the swap then automatically all the processes are there in swap will
move to RAM
swapoff /swap3
or
swapoff /dev/rhel/swap2
swap usage is 2 GB and free RAM is 1 GB then we can not move 2 GB processes
from swap to RAM because there is no enough space in RAM.
so first we have to verify available space in RAM then only we can switch off the
swap.
====================Server Build================================
platforms
1. Physical platform ( console)
2. Virtual platform ( vcenter/vsphear)
3. Cloud platform
HP : ILO
DELL = IDRAC
VMWARE:
how to deploy servers in vmware environment
requestor will open change with our team, in change there will build sheet.
we will login to the ticketing tool and acknowledge the change. also download
the build sheet.
login to vcenter and click on templates there templates will be there we will right
click on right template and deploy
RHEL7.2_App_Ready_Template
RHEL7.5_App_Ready_Template
RHEL7.9_App_Ready_Template
RHEL7.2_db_Ready_Template
RHEL7.5_db_Ready_Template
RHEL7.9_db_Ready_Template
RHEL8.2_App_Ready_Template
RHEL8.5_App_Ready_Template
RHEL8.2_db_Ready_Template
RHEL8.5_db_Ready_Template
create vm ==> Install redhatos ==> login to machine ==> install db related
packages and create db users ===> verify is db is working ==> request for
approval to convert as template ==> approval team will verify ==>
approve ==> right click on machine and create template
Task 1 : deploy server in vcenter ( download the build sheet and login to
vcenter and deploy the server as per build sheet)
Task 2 : completing the post build activities
once after server deploy then we can access server through putty and
complete the post build activites
========CMDB/inventory management
tool===================================================
cmdb
manageengine
hpsl(hp servers list)
one of important data for future that is downtime contact email id.
to : [email protected]
cc : your team DL email address
Hi team,
===================================================================================
=====
Server decommision
in ticketing tool we will open task for vmware team for backup.
step 2 : power off the server for 7 Days
shutdown -h now
step 3 : power on the server after 7 days and delete the machine in vcenter
vmware administrator will delete the vm
even we can delete the machine incase we have access.
BIOS
MBR
GRUB ===> kernel1 ===>rescue.target(repair mode)
kernel 2 ===>rescue.target(repair mode)
blacklist usb-storage
step 2 : enable the block list
modprobeusb-storage
in /etc/security/pwquality.conf
minlen = 9
dcredit = 1
ucredit = -2
lcredit = -1
PAM:
(pluggable authentication module)
it is a extra module to apply any user,account,password related
policies.
cd /etc/pam.d
password-auth
system-auth
5. password should lock out incase user try with wrong password multiple times
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required pam_env.so
auth required pam_faildelay.so delay=2000000
auth required pam_tally2.so deny=3 unlock_time=1800
# auth sufficient pam_fprintd.so
auth sufficient pam_unix.so nulloktry_first_pass
auth requisite pam_succeed_if.so uid>= 1000 quiet_success
auth required pam_deny.so
=================================================================
***** how to identify wrong password attempts?
pam_tally2 -u username
***** how to clear wrong password attempts?
pam_tally2 -u username -r
===========================================================================
Perfomance Fine-tunning
===================
TOP
SAR
IOSTAT
LOAD AVERAGE:
Average load on CPU or CPU's
1 = CPU
2 = CPU's
3 = CPU's
cpu %
2835 test 20 0 1156580 1.0g 0 D 84.0 56.2
0:38.39 dd if=/dev/zer+ ===> Test uesr dd process is executing that is the reason
we can see 85 cpu % is occupied
2834 prasad 20 0 1156580 446824 28 D 1.5 24.0 0:08.83 dd
if=/dev/zer+
top + n + 5
M
Stopped = paused jobs (ctrl +z) is for stop the running process
how to list out stopped jobs
jobs
***** how to send job to background run? command &
dd if=/dev/zero of=/dev/null bs=1G count=200 &
how to stop the job which is running state? kill -SIGSTOP JOBID kill
-SIGSTOP %2
=====================================================================
[test@masterserver ~]$ jobs
[1]+ Stopped dd if=/dev/zero of=/dev/null bs=1G count=200
[2]- Running dd if=/dev/zero of=/dev/null bs=1G count=200 &
[test@masterserver ~]$ kill -SIGSTOP %2
how to start or resume the job which is in stopped state? kill -SIGCONT JOBID
====================================================================
ZOMBIE:
========
process is dead but they are in process table
end user starts the process (NFSD) and end user kills the process.
systemctl start nfsd
starting nfsd process along with some child nfsprocesses.
40223 ppid (parent process id)
40224 (pid) child process id for 40223
40225 (pid) child process id for 40223
40226 (pid) child process id for 40223
when end user triggers stop the nfs service(40223) parent will give signal to
childs. like end user is asking to kill(stop) your self.
child processes has to kill them self and confirm back to parent. incase any
child killing is taking time by that time parent left from process table without
taking his dead child process that child dead process is nothing but
zombie.
40223 parent(ppid)
40224 he killed him self and responded back to 40223 within time like i
killed myself
40225 he killed him self and responded back to 40223 within time like i
killed myself
40226 he killed him self and responded back to 40223 with little bit late
by that time parent left the process table . now 40226 is zombie.
40226 is dead and doen't have parent to take him(clean up the process table).
40226 process will not consume memory(RAM) but it exist in the process
table.
ps -aux | grep Z
ps = process table
a=all
u = all users processes
x= execution
ORPHAN
=======
zombie orphan
dead Alive
no memory consumtion yes it consume the cpu and memory
we can not kill the zombie we can kill becuase it is running state
because it is alread
dead
===%Cpu(s): 0.3 us, 0.3 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0
st===================
us =
0.3 % cpu is used by user processes
sy =
0.3 % cpu is used by system processes
ni =
0.0 % cpu is used by ni(nice processes) or priority processes
id =
99.3 % cpu is idle(free)
100 - 99.3 = 0.7 is used . not even 1 % is used
server performance is too good becuasecpu is used only 0.7 %.
wa = 0.0 % cpu is used by waiting processes
us= user processes are consuming 99 % then what you can take further action.
in top we can see which user processes are consuming more cpu then send out
mail to them like
we noticed your processes are consuming more cpu is this expected?
prasad responded back those are expected processes we can't kill those. then
next action from admin is extend the CPU's.
***** noticed sy processes are consuming more cpu % like 60 % or greater than 20 %.
how we can mitigate this issue or problem.
solution 1: reboot the server and notice the cpu usage by SY. still same usage then
solution 2 : perform patching. may be bugs are there so perform OS patching ( yum
update) zypper update . still no use still cpu usage is high then?
solution 3 : open case with redhat or suse based on os vendor and explain the
problem.
redhatos = os vendor is redhat
suseos = os vendor novel or suse
HP uxos = os vendor is HP
=================================================================
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
3116 prasad 20 0 1156580 1.0g 200 R 24.3 56.2 0:00.77 dd
27 root 20 0 0 0 0 S 2.2 0.0 0:00.83
kswapd0
1 root 20 0 128220 1992 336 S 0.3 0.1 0:03.74 systemd
1227 root 20 0 222716 2000 1772 S 0.3 0.1 0:00.51
rsyslogd
2903 prasad 20 0 116756 1816 92 S 0.3 0.1 0:00.08 bash
3115 root 20 0 162076 1828 1040 R 0.3 0.1 0:00.19 top
pid = process id
user = owner of process or process triggered by which user
dd command is triggered by prasad , process id is 3116
systemd is triggered by root, process id is 1
PR = priority processes
NI = nice processes
20 is default priority
-20 high priority
***** one of process is consuming 150 % of cpu what action you will take?
1 cpu = 100 %
2 cpus = 200 %
4 cpus = 400 %
8 cpus = 800 %
task 1 : verify how many cpus are configured for virtual machine
top + 1 to know the cpu's list
or
lscpu
task 2 : noticed 2 cpus are there then actually usage of cpu's are 75 % only
becuase my cpus capacity is 200 %. nothing to worry.
1 cpu then one of process reached 100% then yes it's critical.
suppose 1 cpu and one of the process is consuming 100 % for last 15 min then what
you will do?
action: identify who is the owner of process
top we can owner of the process at left side
pid username pr nivirt res
Hi Team,
noticed your process is consuming 100 % cpu for last 15 min. please cross
verify and confirm us is this expected usage.
servername : xyzserver
screenshot of that top output
replied back to us
Hi Prasad,
Hi DB Team,
we can increase the cpus. right now 1 cpu is there if you get approval we can
increase that cpu capacity to 2 CPU'S.
===================================================================================
===
***** recieved High CPU usage alert from one of the server?
ticketing tool
24/7
24 hours in 7 days some one will available for support
A shift - 6 AM - 3 PM
B shift - 2 PM - 11 PM
C shift - 10 PM- 7 AM
top + P
Action 4 : noticed DB / App processes are consuming more cpu % then send mail
and transfer ticket to their queue.
send mail
transfer ticket to respective team queue
Hi Team,
oracle = db
tomcat = app
***** recieved High memory(RAM) usage alert from one of the server?
ticketing tool
Action 1 : we have to acknowledge the ticket as soon as ticket araives into our
queue.
open ===> in-progress ==> pending for something ==> resolve ===>
close
ack means changing status from open to in-progress
top + M
Action 4 : noticed DB / App processes are consuming more memory % then send
mail and transfer ticket to their queue.
send mail
transfer ticket to respective team queue
Hi Team,
oracle = db
tomcat = app
build team
patching team
kill pid
pkillprocessname
forcefully
kill -9 pid
pkill -9 processname
***** how to identify is the process is running or not?
SAR
system activity report
top
SAR
Hi DB person,
every 10 min data will be collected and stored in /var/log/sa/sa22( we can find
cpu,memory,disk,swap,.....)
per day data . cumulative data also collected per day and created as day file
/var/log/sa/sa21 inside this file we can find every 10 min data
/var/log/sa/sa20
/var/log/sa/sa19
sarmodule/programs/libraries
sa1 (every 10 min) sa1 will execute every 10 min and collect data with
help of sadc and push data to respective day file(sa21)
sa2 (every day once at 11:53 PM) sa2 will execute at 23:53(11:53 PM) and
collect cumulative data per day and update data in respective day file
sadc ( system activity data collector)
disk performance:
df -h will not give disk performance it gives only disk usage
total size and what is the usage and how much is free
sar -d -p 1 5
here we have to analyze
AWAIT (average waiting) 100 >> 200 after some sec >> 400 that
means disk is not able handle all tps(transactions per sec)
waiting period is increasing so we can thing about
disk replacement with latest technology
or
Hardware
OS(Linux OS,Windows,AIX)
infrastructure as a service
visa company:
visa company will write aggrement with Accenture for infra support.
ITIL :
pre-defined procedures are there . we can costomize that procedures
change management
incident management
problem management
record the recently faced issues. analyze the issue, write the root cause for
issue.
US project
A or india shift - 6 AM to 3 PM 1 L1 emp,1 L2 emp , 1 SME(oncall)
B or UK shift - 2 PM to 11 PM 1 L1 emp,1 L2 emp
C or US shift - 10 PM to 7 AM 2 L1 emp,2 L2 emp,1 sme
shift hand over : shift owner has to give shift hand over to next shift team with
in that 1 hour buffer time.
2 methods:
1. meeting with current shift team and next shift team
2. mail
incident management:
catogories: ack resolve
P1 15 m 4 hours ( p1 is nothing but bussiness impact)
P2 15 m 8 hours
P3 30 m 1 day
P4 30 m 1 week
1. Change Management:
fellow the process to change any thing in infrastructure.
1. OS patching is a change
2. Increase the CPU's is a change
3. extend/reduce lv space is a change
4. delete one user from server is a change
5. export and mount nfs file system is a change
6. decommission the server is a change
7. Replace any hardware part for server is a change
8. updating kernel parameters is a change
9. power off all server on dec 31 and power on server on 1 Jan
===> RFC ===> prepare CR ===> TAB Meeting ===> CAB meeting ===> go/no go
call ==> change implementation ===> roll back in case change fails
day1 day2 day3 day4 day5 day6
change manager (OS patching is the change, linux administrator has to inform
change manager we are planning patchong on so and server)
incident manager
problem manager
/db partition is full now which team is responsible for /dbpartiton? DB team
dbteam will open ticket with Linux team please increase the /db partition space.
now who is the requestor? DB Team
RFC = DB team
os patching = RFC = Linux team
increase the swap , it is a db server = RFC = dB team
===> RFC ===> prepare CR(join in meeting and prepare cep) ===> TAB Meeting
===> CAB meeting ===> go/no go call ==> change implementation ===> roll back in
case change fails
day1 day2 day3 day4 day5
day6
monday tue wen thu friday
sunday
change is OS patching:
here Linux team has to create CR in ticketing tool
CR number is : CH125468
CR Tasks : Task1 : CH125468-1 task 1 assigned to
vmare team to create snapshot preor to change implementation
start time : 0:00
end time : 0:30
servers list
CR Task 2 : CH125468-2 : stop and start the DB
stop time : 2:00 - 3:00
start time :5:00 - 5:30
CR Task 3 : CH125468-3 : Stop and start the
application
stop time : 1:00 - 2:00
start time : 5:30 - 6:00
Incident management
================
1. server is hang
2. High cpu utilization
3. High memory utilization
4. Users not able to access application
5. server is powered off
6. application not running
7. disk full due to this applicaton not running
===============P1 =================
deleted one of the gcc package from production server. after that application
not running. now end users not able to access application.
It's a P1 or not? P1
P1 RCA is mandatory
===================================P1 close==============================
L1 - 0-3 years
L2 - 3 - 6 Years
L3 - 6 - 9 Years experience
L4 - SME = >9 to 15 Years
Architect = >15
vendor(os vendor)
linux team got P1 issue at 7 am same time linux team opened case with redhat
for same issue.
SLA 4 even redhat SLA 4
Problem management
================
where we don't have permanent fix for the incident that is nothing problem.
when we don't permanent fix for indent the incident will repeat or not.
that is problem.
every monday server is getting hand. but we don't have root cause
every friday at 11 PM server is rebooting, but we don't have root cause
we will take vendor support to fix the problem. we will open case with redhat/suse
and work on the problem.
Ticketing tools:
SNOW ( Service now)
SM( service manager)
remidy
zabix
==============================================================================
1) What is Linux?
Linux is a UNIX based operating system. Linus Torvalds first introduced it. It is
an open source operating system that was designed to provide free and a low-cost
operating system for the computer users.
5) What is LILO?
LILO is a boot loader for Linux. It is used to load the Linux operating system into
the main memory to begin its operations.
9) Define shell
It is an interpreter in Linux.
11) Name the Linux which is specially designed by the Sun Microsystems.
Solaris is the Linux of Sun Microsystems.
13) If you have saved a file in Linux. Later you wish to rename that file, what
command is designed for it?
The 'mv' command is used to rename a file.
16) If the programmer wishes to execute an instruction at the specified time. Which
command is used?
The 'at' command is used for the same.
CentOS
Ubuntu
Redhat
Debian
Fedora
19) What is Swap Space?
Swap space is used to specify a space which is used by Linux to hold some
concurrent running program temporarily. It is used when RAM does not have enough
space to hold all programs that are executing.
25) Which popular office suite is available free for both Microsoft and Linux?
Open Office Suite is available free for both Microsoft and Linux. You can install
it on both of them.
26) Suppose your company is recently switched from Microsoft to Linux and you have
some MS Word document to save and work in Linux, what will you do?
Install Open Office Suite on Linux. It facilitates you to work with Microsoft
documents.
32) Which partition stores the system configuration files in Linux system?
/stc partition.
Read: User can read the file and list the directory.
Write: User can write new files in the directory .
Execute: User can access and run the file in a directory.
39) What are the modes used in VI editor?
There are 3 types of modes in vi Editor: