You are on page 1of 21

INVIS4 Notes

23.11.2022
—-----------

1million = 10Lakhs 1Billion = 100Crores

Redundancy - a Safety before a failure (like Backup, duplicacy / cloning)

A server is a computer that provides resources or services to other computers over a network.

Popular RDBMS DB Server : Oracle, MySQL, PostgreSQL, MSSQL, MariaDB


Amazon : Aurora DB Server

S4
Mail Servers : Exchange Server from Microsoft, Zimbra, Postfix

SDLC:
Plan – What is the problem and what resources do you need to solve it?
• Analyze – What do you want from a solution?
• Design – How will you built what you want?
• Develop – Build what you have designed.
• Test – Did you get what you want?
• Implement – Start to use what you built.
• Maintain – Improve what you built.
VI
The SDLC is repeated over the lifetime of an application. It’s used to create, update, fix, and maintain
the application.

Cloud computing is the on-demand delivery of compute power, database, storage, applications, and
other IT resources. These resources are delivered through a cloud services platform via the internet,
with pay-as-you-go pricing
iN
24.11.2022

1. With infrastructure as a service (IaaS), you manage the server, which can be physical or virtual,
and the operating system (Microsoft Windows or Linux). In general, the data center provider
has no access to your server.
2. With platform as a service (PaaS), someone else manages the underlying hardware and
operating systems. In this way, you can run applications without managing underlying
infrastructure (for example, patching, updates, maintenance, hardware, and operating
systems). PaaS also provides a framework for developers that they can build on to create
customized applications.
3. With software as a service (SaaS), you manage your files while the service provider manages
all data centers, servers, networks, storage, maintenance, and patching. You handle only the
software and how you want to use it. You are provided with a complete product that the service

S4
provider runs and manages. Facebook and Dropbox are examples of SaaS. You manage your
Facebook contacts and Dropbox files, and the service providers manage the systems
Public cloud: Here, the resources and services provided by third-party service providers are
available to customers via the Internet.
Private cloud: In a private cloud, the resources and services are managed in-house or by third
parties, exclusively for a particular organization.
Hybrid cloud: It is a combination of both public and private cloud types. The decision whether to
run the services on public or private depends on some parameters such as the sensitivity of the
data and applications, industry certifications and required standards, etc.

Public cloud: Here, the resources and services provided by third-party service providers are available to
VI
customers via the Internet.
Private cloud: In a private cloud, the resources and services are managed in-house or by third parties,
exclusively for a particular organization.
Hybrid cloud: It is a combination of both public and private cloud types. The decision whether to run the
services on public or private depends on some parameters such as the sensitivity of the data and
applications, industry certifications and required standards, etc.

1. How does cloud computing benefit you?


Cloud computing gives you access to servers, storage, databases, and a broad set of application services
iN
over the internet. Cloud storage is a great example of cloud computing. Cloud storage gives you the option
to free up memory (space) on your computer or mobile device. Imagine that your mobile device runs out of
memory when you want to download and save a new song, photo, or video.

2. If you have a business, how can cloud computing benefit your business?
Cloud computing or cloud services providers (like AWS) provides rapid access to flexible and low-cost IT
resources. With cloud computing, you don’t need to make large upfront investments in hardware. As a business
owner, you do not need to purchase a physical location, servers, storage, or databases.

3. Why are so many companies interested in moving to the cloud? Next, you explore why so many companies
are moving to the cloud

The key takeaways from this lesson are the six advantages of cloud computing:
• Trade capital expense for variable expense
• Benefit from massive economies of scale
• Reduce guessing about capacity
• Increase speed and agility
• Stop spending money on running and maintaining data centers
• Go global in minute

25.11.2022

SAN - Storage Area Network


NAS - Network attached Storage

Intranet or LAN or Private Network- The communication within your network / within your
organization (ONly 1 Network) - Security High, Trusted Network

S4
Internet or Public Network - communication between networks (many / Multiple / millions of network)
- Untrusted, Security Low

• ACL (ACLs)
• Amazon Elastic Block Store (Amazon EBS)
• Amazon Elastic File Store (Amazon EFS)
• Amazon Machine Image (AMI)
• Amazon Relational Database Service (Amazon RDS)
• Amazon Simple Storage Service (Amazon S3)
• AWS Identity and Access Management (IAM)
VI
• Direct-attached storage (DAS)
• Network access control lists (network ACLs)
• Network-attached storage (NAS)
• Relational database management system (RDBMS)
• Storage area network (SAN
iN

Accessing AWS Resources / Services


1. AWS Management Console
2. CLI - Command Line Interface
3. SDK - Software Development Kit (Visual Studio / Eclipse
4. API - Application Programming Interface (Eg: SQL Workbench)
Documentation : https://docs.aws.amazon.com/

28.11.2022

Storage
S3 - SSS - Simple Storage Service
EBS - Elastic Block Store

S4
EFS - Elastic File System
Glacier - Archival data

Compute
EC2 - ECC - Elastic Compute Cloud
Lambda - Serverless compute Service - Used for Background Program Executions (SAAS)
Beanstalk - A Platform for running your application (PAAS)

Database
RDS - Relational Database Services
DynamoDb - NoSQL database tables
VI
Elasticache - To speed up The DB services

Networking & Content Delivery


VPC - Virtual Private Cloud
Route53 - Web/Domain Hosting

Security
IAM - Identity and Access Management
iN

Region Specific Service - EC2, Lambda,


Global Service - Route53, IAM, S3

29.11.2022
S4
VI
Vulnerability - Weakness in the code, application or software.. Results to Attacks

Malicious - any code / software which causes harm to the System.


iN
S4
VI
Storage Types: 2 types - 1. Block Storage 2. Object Storage

1. Block storage eg: EBS & EFS


2. Object Class storage - S3
iN
Storage - Data speed is measured in IOPS (Input Output Operations per second)

S3 Standard 100GB - 2.3 Usd


S3 IA - 1.25USD
S3 Deep Glacier - 0.10 USD

30.11.2022

EC2

S4
Public IP : 54.71.149.242 54.149.142.2

VI
iN
01.12.2022

Linux Introduction. GNU

Kernel is the core of OS

Linux OS is case sensitive


Linux OS is called as Multi user, Multi Processing & Multi Tasking OS

S4
VI
iN
Public IP : 35.93.128.66
AZ : US East-2a
Keyname : vockey

In Security Group : Port 22 (SSH) Needs to be opened (Pl. verify)

Download Ppk keys (Public private Keys) from Details page

Login Name : ec2-user

~ - In linux is home directory

02.12.2022
[ec2-user@ip-10-0-10-116 ~]$ whoami
ec2-user
[ec2-user@ip-10-0-10-116 ~]$ hostname -s
ip-10-0-10-116
[ec2-user@ip-10-0-10-116 ~]$ hostname
ip-10-0-10-116.us-west-2.compute.internal
[ec2-user@ip-10-0-10-116 ~]$ uptime -p
up 6 minutes
[ec2-user@ip-10-0-10-116 ~]$ uptime
04:50:47 up 6 min, 1 user, load average: 0.00, 0.03, 0.00
[ec2-user@ip-10-0-10-116 ~]$

S4
Directory Management

Make Directory - mkdir


Change Directory - cd cd .. (shall go back to your parent directory)
Remove Directory - rmdir

For files
VI
Copy - cp
Move - mv
Remove rm
iN

Tape Archive - tar

tar -csvpzf
-c - create archive file
-v - Verify / Verbose
-p - preserve Permissions
-z - use zip compression
-f - File display (Status)

-t - list the contents of archive


-x - extract the files from archive
-j - use bzip2 compression

05.12.2022 Pipes and Filters

1. Less - displays file page by page

S4
2. More - displays file page by page
3. Head - displays top 10 lines
4. Tail - displays bottom 10 lines
5. Cut - cut the fields with delimiter
6. Sort - sorts ascending / descending file contents
7. Grep - filters specific word or content in a file or search
8. Tr - Translate
9. Awk - filters specific column
10. Sed - streaming editor
11. Wc - word count
VI
> redirection
$ ls -al >file1
$ cat file1 { Displays the contents of file1}
>>redirection means append the contents of file
$ ls -al >>file1
$ cat file1 |less 1st method
$ less file1 #2nd method displays file1 page by page (q -quit , p - previous)
$ more file1 Displays contents of file in page format (q - Quit)
iN
$ head file1 # displays top 10 lines of file1
$ tail file1 # displays bottom 10 lines of file1

$ head -n 15 file1 # displays top 15 lines (-n = number of lines)


$ tail -n 5 file1 # displays bottom 5 lines (-n number of lines)
For demonstration of cut command I am using this file
~$ cp /etc/passwd . (pl. Ensure .(dot) after passwd)
$ cut -f1 -d: passwd (-f = field, -d = delimiter) - Displays first field in passwd file
$ cut -f1 -d: passwd >file2 (the output of cut field 1 is redirected to file2)
To create contents into a file
$ cat > file3 (Creates contents from the screen and press ^C to exit )
this is a a test file

twinkle twinkle little star


how i wonder what you are
^C

To append contents to a file


$ cat >>file3 (appends to file3)
up above the world so high
like a diamond in the sky

end of file

bye
^C
$ cat file3>>file4

S4
$ cat file3>>file4
$ cat file3>>file4
$ cat file3>>file4
Translate - tr
$ cat file4 | tr ‘a-z’ ‘A-Z’ (replaces all small characters with Upper characters
$ cat file4 | tr ‘a’ ‘A’ (replaces small a character with Capital A )
Sort Filter - arranging in order
$ cat passwd |sort # displays contents in alphabetical order
$ cat passwd |sort -r # displays contents in reverse order
Wc Filter - Word count
[ec2-user@ip-172-31-15-186 ~]$ wc file4
VI
48 124 596 file4 # 48 lines, 124 words & 596 Characters / bytes)
Grep filter
$ cat file4 |grep star # displays all lines in file4 which contans word star
Sed filter
$ cat flle4 |sed ‘s/little/big/g’ # displays output replacing little with big from file4 on
to the screen
(s - Search, g - global)
$ cat file4|sed ‘1,10s/little/big/g’ # displays output replacing from line 1 to 10
iN
with big instead of little in file4
AWK Filter
$ ll |awk ‘{print$9,$1,$3}’ # AWK filters ll output and displays
only field 9, 1 & 3 of total 9 fields)
total
file1 ec2-user -rw-rw-r--
file2 ec2-user -rw-rw-r--
file3 ec2-user -rw-rw-r--
file4 ec2-user -rw-rw-r--
file5 ec2-user -rw-rw-r--
passwd ec2-user -rw-r--r--

$ cat file4 |grep star |wc |awk '{print$1}' >output


iN
VI
S4
06.12.2022 Process

Task activity
1. System (OS) Process
2. Application Process
3. User defined Process
Every Process has an ID (identification number) which is unique
Daemons - Additional support for the process to run

● Process is identified by PID - Process ID


● Every Process has PPID - Parent Process ID
● Every Process has task initiation time and date

S4
A Process status can be running, sleeping. Stopped, stale, zombie
$ tty # displays terminal ID eg: /dev/pts/0
$ ps # Process status within your terminal (basic information)
$ ps -ef # f = full listing e= extended information
$ sleep 5 # Keeps the terminal windows in passive mode

A task can be initiated in either foreground or background


To create a job in background
$ sleep 1000 & # Runs the job in Background mode (& keeps job in background)

$ jobs # To list all background jobs running within your terminal


VI
$ fg 2 # brings job id 2 to foreground mode

A Process can be killed or terminated with kill command


Types of kill - 9 force kill SIGKILL
1 HUP
15 terminate cleanly SIGTERM
To terminate or kill a process (note down the pid)
$ kill -9 <pid> # you have the owner of the job or Administrator
iN

How to change priority of Jobs / process

Priority bar (Nice)


(-20
………………………………………………………0…………………………………………………………….+19)
Highest Medium
Lowest

$ ps -efl # list long format with additional; -l option (Displays even nice Priority)

To create a job with nice priority


$ nice -n +5 sleep 1000 & # Creates sleep task in background with +5 priority
To renice the existing process
$ renice -n +10 <pid> # reprioritize the task with new priority +10 defined.
Pl. note : As a user you can only decrease the priority but not to increase priority (You need administrative
Privileges to do so)
$ sudo renice -n -10 <pid> # reprioritize the task with root privileges & new priority +10
defined.

To measure performance and top process the tool we use is top


$ top # To list all top process in a System

top - 06:11:06 up 1:43, 2 users, load average: 0.00, 0.00, 0.00


Tasks: 99 total, 1 running, 56 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 988916 total, 285348 free, 93228 used, 610340 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 748884 avail Mem

S4
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
32761 ec2-user 20 0 168836 4296 3784 R 0.3 0.4 0:00.05 top
1 root 20 0 123504 5416 3880 S 0.0 0.5 0:02.08 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00
kworker/0:0H-ev
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.15
kworker/0:1H-ev
VI
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00
rcu_tasks_rude_
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00
rcu_tasks_trace
12 root 20 0 0 0 0 S 0.0 0.0 0:00.08 ksoftirqd/0
13 root 20 0 0 0 0 I 0.0 0.0 0:00.11 rcu_sched
14 root rt 0 0 0 0 S 0.0 0.0 0:00.03 migration/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
iN
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
19 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
20 root 20 0 0 0 0 I 0.0 0.0 0:00.07
kworker/u30:1-f
Filesystem

ext2, ext3, ext4, xfs


The following folders are available in every linux operating system.
Kernel along with modules is the core of OS
The root directory in linux is denoted by / (reverse slash)

bin - Binary files (all command executable files)


dev - device files
home - All user related home folder data file are stored in /home
lib, lib64 - System and application Libraries
media - all media like CD / DVD ROM, SDCard, Smart drive, are mounted
opt - additional applications, (Eg: Oracle etc.,)
root - Home folder for root / super user or su

S4
sbin - super binary files (root executable files)
sys
usr - application related files
boot - system bootable like kernel, modules, & Bootloader files
etc - System configuration files
local
mnt - external like Network mount is used for mnt
proc - processor file system
run, srv
tmp - temporary file system for users to utilize (like exchange files)
VI
var - various other directories like log files, crashdumps, ftp etc.,
iN
07.12.2022 - File Permissions, Find
File / Directory Permissions

In Linux we have only 3 types of basic permissions which can be assigned


r-read, w - write, x-execute
In Linux we also have 3 categories of users
1. Owner, User (who had created the file)
2. Group (group which belongs to )
3. Others (Rest all are considered as others)

How to understand Permissions?


rwx rwx rwx

S4
Owner Group Others
-rw-rw-r--
12345678910

1 - Type of File (d - directory, - normal file, l - link file, c - character device file, b - block device file, s -
socket files)
2-10 - file permissions

- rw- rw- r-- 664


MSB / LSB - Most / Least significant bit 421 (r-4, w-2, x-1)
- rw- rw- r--
VI
42 42 4 664
-rwx r-x r–- 754
421 4 1 4 754
-rw-rw-r– 664
rwxrwxr— 774

665 rw-rw-r-x
744 rwxr– r–
444
iN
644 rw-r– r—
775 rwxrwxr-x
$ chmod <permission value> <directory name>
drwxrwxr-x 775 002 (not set)
drw-r–r— 644 133
$ chmod 775 file1 (Example to set file1 with permission 775)
Umask - Usermask (the unset values needs to defined
$ umask 022 (The default permissions for directory is set to 755)

chgrp - Change group of file / directory


chown - to change ownership of file / directory
Find:

STDIN : Standard Input - KBD <


STDOUT : Standard Output - TRM >
STDERR : Standard Errors - TRM 2>
Output = STDOUT +STDERR

In Linux we have a Null device (/dev/null)

TAsk: to search a file called passwd


Find command syntax is divided into 4 parts

$ find <search path> <search Criteria> <action>


1 2 3 4

S4
Command search path criteria print, cp , mv

$ find / -name passwd -print


$ find / -name passwd -print 2>/dev/null
/etc/passwd
/etc/pam.d/passwd
/usr/bin/passwd

$ find / -size +50M -print 2>/dev/null


/proc/kcore
/var/cache/yum/x86_64/2/amzn2-core/gen/primary_db.sqlite
VI
/var/cache/yum/x86_64/2/amzn2-core/primary.sqlite.gz

$ find / -size +50M -exec ls -l {} \; 2>/dev/null


-r-------- 1 root root 140737477890048 Dec 7 04:32 /proc/kcore
-rw-r--r-- 1 root root 234237952 Dec 5 23:32
/var/cache/yum/x86_64/2/amzn2-core/gen/primary_db.sqlite
-rw-r--r-- 1 root root 70386104 Dec 5 23:32
/var/cache/yum/x86_64/2/amzn2-core/primary.sqlite.gz
iN
$ find / -perm 777 -exec ls -l {} \; 2>/dev/null
lrwxrwxrwx 1 root root 44 Nov 12 01:08
/opt/aws/bin/cfn-send-cmd-result ->
../apitools/cfn-init/bin/cfn-send-cmd-result
lrwxrwxrwx 1 root root 35 Nov 12 01:08 /opt/aws/bin/cfn-signal ->
../apitools/cfn-init/bin/cfn-signal
lrwxrwxrwx 1 root root 17 Nov 12 01:08 /opt/aws/apitools/cfn-init
-> ./cfn-init-2.0-10

$ find / -user ec2-user -exec ls -ld {} \; 2>/dev/null


-rw------- 1 ec2-user ec2-user 656 Dec 7 05:16
/home/ec2-user/.viminfo
-rw-rw-r-- 1 ec2-user ec2-user 0 Dec 7 05:18 /home/ec2-user/file2
drw-r--r-- 2 ec2-user ec2-user 6 Dec 7 05:18 /home/ec2-user/vis4
$ find /home -mtime -1 -exec ls -ld {} \; 2>/dev/null
drwxr-xr-x 3 root root 22 Dec 7 04:32 /home
drwx------ 6 ec2-user ec2-user 151 Dec 7 05:25 /home/ec2-user
drwx------ 2 ec2-user ec2-user 29 Dec 7 04:32 /home/ec2-user/.ssh

$ find /home -mtime -1 ! -user ec2-user -exec ls -ld {} \;


2>/dev/null
drwxr-xr-x 3 root root 22 Dec 7 04:32 /home

S4
VI
iN
08.12.2022 VI Editor / Shell Scripting -1 / Bash

VI Editor - Visual Interactive / ViM - Vi Improved

3 Modes of Operation
1. Command mode (Default)
2. Editor Mode
3. Global Command Mode

1. Important Command Mode commands (^ - Esc - to come from editor mode to


command mode)
a - append
A - append end of line

S4
x - delete character
o - insert a blank new line
u - undo , undelete
r - replace character
cw - change word
i - insert
nyy - yank line (copy line) (n - number of lines)
p - paste / place
dd - delete line
G - Ground (bottom of document)
1G - Top of document
/<string> - Search string (n - next)
VI
Global command mode command (^: - Editor mode to Global Command Mode)

w - write / save
q - Quit / exit
wq - Write / quit
x - wq - save exit
q! - Force quit without saving
se nu - number bar in the left margin
iN

se nonu - disable number bar


%s/<find>/replace>/g - Search & replace
Basic Shell Scripting - Part 1

Basic Shell Scripting


$ cat script1
# This is my first shell script - Anand K
clear #hello this is clear screen
echo " Welcome to shell Scripting"

To execute script1
$ sh script1
Welcome to shell Scripting
[ec2-user@ip-172-31-4-218 ~]$

S4
$ cat script2
# This is Shell script - Batch Script

clear
echo " Hello and welcome to Linux - Shell Scripting "
echo " "
echo " "
echo " Today's date and time is $(date) and my username is $(whoami) "
echo " "
echo " My terminal is $(tty) and this month calendar is $(cal) "
echo " "
VI
echo " "
echo " "
cat greeting

$ cat greeting

########################################################################
iN
###

H A P P Y L E A R N I N G

########################################################################
###

[ec2-user@ip-172-31-4-218 ~]$

Bash $ env $ set


Shell Parameter=Value
(CAPS)
.bash_logout (logout Script of shell)
.bashrc (Startup script for shell)
.bash_profile (To set any variable for shell during operation)

System user Login Script


$ vi .bashrc # append at end of file
# User specific aliases and functions
sh script2

Relogin and see the change

For Logout Script

S4
$ cat .bash_logout
# ~/.bash_logout
echo " Bye Bye ....."
sleep 5

Logout to see the change..


VI
iN

You might also like