0% found this document useful (0 votes)
30 views99 pages

DevOps Bootcamp Course Resource (1) - 1-99

The document provides an overview of Linux basics, including command line interface, file and directory management, package management, and service management. It includes examples of basic commands, user account management, downloading files, and managing services using systemctl. Additionally, it offers links to DevOps pre-requisite courses available on KodeKloud.

Uploaded by

Mrfake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views99 pages

DevOps Bootcamp Course Resource (1) - 1-99

The document provides an overview of Linux basics, including command line interface, file and directory management, package management, and service management. It includes examples of basic commands, user account management, downloading files, and managing services using systemctl. Additionally, it offers links to DevOps pre-requisite courses available on KodeKloud.

Uploaded by

Mrfake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 99

Learn more about DevOps and Cloud courses with KodeKloud: https://kode.

wiki/3N3A4kt

© Copyright K odeK l oud


Why Linux?

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
2
https://insights.stackoverflow.com/survey/2019
Why Linux?

2013 - Docker was born


2016– Docker for Windows was born

https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html

Kubernetes Documentation
© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Linux Basics

• Linux CLI
• VI Editor
• Package Management
• Service Management

Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg


© Copyright K odeK l oud *Allowed multiple selections
Linux Basics Course www.kodekloud.com

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
just enough

LINUX

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Shell Types
echo $SHELL Broune Shell (Sh Shell)
/bin/bash

C Shell (csh or tcsh)

Z Shell (zsh)

Bourne again Shell (bash)

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Basic Commands
echo Hi
Print to screen
Hi

ls
List files & folders
File.txt my_dir1 file2.conf

cd my_dir1 Change directory

pwd
Present Working Directory
/home/my_dir1

mkdir new_directory Make Directory

cd new_directory; mkdir www; pwd Multiple commands


/home/my_dir1/new_directory
© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Commands - Directories
/tmp/asia/india/bangalore
mkdir /tmp/asia
mkdir /tmp/asia/india
mkdir /tmp/asia/india/bangalore Make Directory Hierarchy

mkdir –p /tmp/asia/india/bangalore

rm –r /tmp/my_dir1 Remove Directory

cp –r my_dir1 /tmp/my_dir1 Copy Directory

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Commands - Files
touch new_file.txt
Create a new file (no contents)
Hi

cat > new_file.txt


Add contents to file
This is some sample contents
CTLR + D

cat new_file.txt
View contents of file
This is some sample contents

cp new_file.txt copy_file.txt Copy File

mv new_file.txt sample_file.txt Move (Rename) File

rm new_file.txt Remove (Delete) File


© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Labs
• NOTE: These labs should NOT have the user require to use sudo
• Have a file and folder tree structure created. Ask MCQ questions (only based on the
previous slides) to users, such as
• Identify number of files and directories in a path
• What is a file not present in a directory
• Navigate to some directory(don’t specify the full path) and ask user to find the present working
directory
• Ask user to perform operations
• Create empty file
• Create file with some content
• Create directory
• Create directory hierarchy
• Copy file to a different place (Stage a file with some data)
• Copy directory
• Remove file
• Remove directory and all contents
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just a bit more

LINUX

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
User Accounts
whoami
matthew
matthew

id
uid=1001(matthew) gid=1001(matthew) groups=1001(matthew)

su aparna
Password:

ssh [email protected]

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
14
User Accounts
ls /root
ls: cannot open directory /root: Permission denied
matthew root
sudo ls /root SUDO
anaconda-ks.cfg initial-setup-ks.cfg /etc/sudoers

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
15
Download Files
curl http://www.some-site.com/some-file.txt -O
some-file.txt

wget http://www.some-site.com/some-file.txt -O some-file.txt


some-file.txt

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check OS Version
ls /etc/*release*
/etc/centos-release /etc/os-release /etc/system-release
/etc/centos-release-upstream /etc/redhat-release /etc/system-release-cpe

cat /etc/*release*
CentOS Linux release 7.7.1908 (Core)
Derived from Red Hat Enterprise Linux 7.7 (Source)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
• Wget
• Curl
• Cat /etc/*release*

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
18
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
Package Managers

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
RPM (Red Hat Package Manager)
rpm –i telnet.rpm Install Package

rpm –e telnet.rpm Uninstall Package

rpm –q telnet.rpm Query Package

?
?
? RPM
? telnet.rpm
ansible
© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
YUM
yum install ansible Install Package

/etc/yum.repos.d

PyYAML
YUM

python RPM
ansible
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

sshpass
YUM Repos
yum repolist
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10097
extras/7/x86_64 CentOS-7 - Extras 341
mongodb-org-4.2/7 MongoDB Repository 25
mysql-connectors-community/x86_64 MySQL Connectors Community 141
mysql-tools-community/x86_64 MySQL Tools Community 105
mysql80-community/x86_64 MySQL 8.0 Community Server 161
updates/7/x86_64 CentOS-7 - Updates 1787

ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Media.repo mysql-community.repo
CentOS-CR.repo CentOS-Sources.repo mysql-community-source.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
CentOS-fasttrack.repo mongodb-org-4.2.repo

cat /etc/yum.repos.d/CentOS-Base.repo
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
YUM
yum list ansible
Installed Packages
ansible.noarch 2.9.6-1.el7 @epel

yum remove ansible

yum --showduplicates list ansible


Available Packages
ansible.noarch 2.4.2.0-2.el7 extras
ansible.noarch 2.9.6-1.el7 epel

yum install ansible-2.4.2.0

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Labs

• View installed packages


• Identify versions of installed packages
• Install specific packages using yum
• Install specific packages using yum with specific versions
• Remove packages

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright K odeK l oud


Services

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Services
service httpd start Start HTTPD service
Or
systemctl start httpd Start HTTPD service

systemctl stop httpd Stop HTTPD service

systemctl status httpd Check HTTPD service Status

Configure HTTPD to start at


systemctl enable httpd startup

Configure HTTPD to not start at


systemctl disable httpd startup
© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Services
/usr/bin/python3 /opt/code/my_app.py systemctl start my_app
* Serving Flask app "my_app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment. systemctl stop my_app
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

/etc/systemd/system
curl http://localhost:5000
Hello, World!

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Services
/etc/systemd/system
/usr/bin/python3 /opt/code/my_app.py
/usr/bin/python3 /opt/code/my_app.py my_app.service
* Serving Flask app "my_app" (lazy loading)
* Environment: production [Service]
WARNING: This is a development server. Do not use it in a production deployment. ExecStart=
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

systemctl daemon-reload
curl http://localhost:5000
Hello, World!
systemctl start my_app

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Services
/etc/systemd/system
systemctl status my_app my_app.service
● my_app.service
Loaded: loaded (/etc/systemd/system/my_app.service; static; vendor preset: disabled) [Service]
Active: active (running) since Tue 2020-04-07 09:01:39 UTC; 2s ago ExecStart= /usr/bin/python3 /opt/code/my_app.py
Main PID: 5038 (python3)
CGroup: /system.slice/my_app.service
└─5038 /usr/bin/python3 /tmp/app/my_app.py

Apr 07 09:01:39 systemd[1]: Started my_app.service.


Apr 07 09:01:39 python3[5038]: * Serving Flask app "my_app" (lazy loading) systemctl daemon-reload
Apr 07 09:01:39 python3[5038]: * Environment: production
Apr 07 09:01:39 python3[5038]: WARNING: This is a development server. Do not use it in a produ...ent.
Apr 07 09:01:39 python3[5038]: Use a production WSGI server instead.
Apr 07 09:01:39 python3[5038]: * Debug mode: off systemctl start my_app
Apr 07 09:01:39 python3[5038]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Hint: Some lines were ellipsized, use -l to show in full.
systemctl stop my_app

curl http://localhost:5000
Hello, World!
© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Services
/etc/systemd/system
systemctl status my_app my_app.service
● my_app.service
Loaded: loaded (/etc/systemd/system/my_app.service; static; vendor preset: disabled) [Service]
Active: active (running) since Tue 2020-04-07 09:01:39 UTC; 2s ago ExecStart= /usr/bin/python3 /opt/code/my_app.py
Main PID: 5038 (python3)
CGroup: /system.slice/my_app.service
└─5038 /usr/bin/python3 /tmp/app/my_app.py

Apr 07 09:01:39 systemd[1]: Started my_app.service. [Install]


Apr 07 09:01:39 python3[5038]: * Serving Flask app "my_app" (lazy loading) WantedBy=multi-user.target
Apr 07 09:01:39 python3[5038]: * Environment: production
Apr 07 09:01:39 python3[5038]: WARNING: This is a development server. Do not use it in a produ...ent.
Apr 07 09:01:39 python3[5038]: Use a production WSGI server instead.
Apr 07 09:01:39 python3[5038]: * Debug mode: off
Apr 07 09:01:39 python3[5038]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) systemctl daemon-reload
Hint: Some lines were ellipsized, use -l to show in full.

systemctl start my_app

systemctl stop my_app


curl http://localhost:5000
Hello, World!
© Copyright K odeK l oud systemctl enable my_app
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Services
/etc/systemd/system
systemctl status my_app my_app.service
● my_app.service
Loaded: loaded (/etc/systemd/system/my_app.service; static; vendor preset: disabled) [Unit]
Active: active (running) since Tue 2020-04-07 09:01:39 UTC; 2s ago Description=My python web application
Main PID: 5038 (python3)
CGroup: /system.slice/my_app.service
└─5038 /usr/bin/python3 /tmp/app/my_app.py
[Service]
Apr 07 09:01:39 systemd[1]: Started my_app.service.
ExecStart= /usr/bin/python3 /opt/code/my_app.py
Apr 07 09:01:39 python3[5038]: * Serving Flask app "my_app" (lazy loading) ExecStartPre=/opt/code/configure_db.sh
Apr 07 09:01:39 python3[5038]: * Environment: production
Apr 07 09:01:39 python3[5038]: WARNING: This is a development server. Do not use it in a produ...ent. ExecStartPost=/opt/code/email_status.sh
Apr 07 09:01:39 python3[5038]: Use a production WSGI server instead.
Apr 07 09:01:39 python3[5038]: * Debug mode: off
Apr 07 09:01:39 python3[5038]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) [Install]
Hint: Some lines were ellipsized, use -l to show in full.
WantedBy=multi-user.target

curl http://localhost:5000 systemctl daemon-reload


Hello, World!
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
systemctl start my_app
Services
/etc/systemd/system
systemctl status my_app my_app.service
● my_app.service
Loaded: loaded (/etc/systemd/system/my_app.service; static; vendor preset: disabled) [Unit]
Active: active (running) since Tue 2020-04-07 09:01:39 UTC; 2s ago Description=My python web application
Main PID: 5038 (python3)
CGroup: /system.slice/my_app.service
└─5038 /usr/bin/python3 /tmp/app/my_app.py
[Service]
Apr 07 09:01:39 systemd[1]: Started my_app.service.
ExecStart= /usr/bin/python3 /opt/code/my_app.py
Apr 07 09:01:39 python3[5038]: * Serving Flask app "my_app" (lazy loading) ExecStartPre=/opt/code/configure_db.sh
Apr 07 09:01:39 python3[5038]: * Environment: production
Apr 07 09:01:39 python3[5038]: WARNING: This is a development server. Do not use it in a produ...ent. ExecStartPost=/opt/code/email_status.sh
Apr 07 09:01:39 python3[5038]: Use a production WSGI server instead.
Apr 07 09:01:39 python3[5038]: * Debug mode: off
Restart=always
Apr 07 09:01:39 python3[5038]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Hint: Some lines were ellipsized, use -l to show in full.
[Install]
WantedBy=multi-user.target

curl http://localhost:5000 systemctl daemon-reload


Hello, World!
© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
systemctl start my_app
Service Unit File - Docker
/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

[Install]
WantedBy=multi-user.target
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
Networking Basics

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Networking Pre-Requisite
• Switching
• Routing
• Default Gateway
• DNS Configuration on Linux

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Switching ??

A eth0 eth0 B

192.168.1.0

192.168.1.10 192.168.1.11

ip link ip link
eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
fq_codel state UP mode DEFAULT group default qlen 1000 fq_codel state UP mode DEFAULT group default qlen 1000

ip addr add 192.168.1.10/24 dev eth0 ip addr add 192.168.1.11/24 dev eth0

ping 192.168.1.11
© Copyright KodeKloud
Reply from 192.168.1.11: bytes=32 time=4ms TTL=117
Reply from 192.168.1.11: bytes=32 time=4ms TTL=117
Routing ??

A eth0 eth0 B C eth0 eth0 D


192.168.1.0 192.168.2.0

192.168.1.10 192.168.1.11 192.168.2.10 192.168.2.11

192.168.1.1 192.168.2.1

© Copyright K odeK l oud


Gateway

A eth0 eth0 B C eth0 eth0 D


192.168.1.0 192.168.2.0

192.168.1.10 192.168.1.11 192.168.2.10 192.168.2.11

192.168.1.1 192.168.2.1

route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface

ip route add 192.168.2.0/24 via 192.168.1.1


route
Kernel IP routing table
Destination
© Copyright KodeKloud Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 192.168.1.1 255.255.255.0 UG 0 0 0 eth0
Gateway

A eth0 eth0 B C eth0 eth0 D


192.168.1.0 192.168.2.0

192.168.1.10 192.168.1.11 192.168.2.10 192.168.2.11

192.168.1.1 192.168.2.1

ip route add 192.168.1.0/24 via 192.168.2.1


route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 192.168.2.1 255.255.255.0 UG 0 0 0 eth0
© Copyright KodeKloud
Default Gateway INTERNET

172.217.194.0
INTERNET

216.134.45.0
INTERNET

16.44.53.0

A eth0 eth0 B C eth0 eth0 D


192.168.1.0 192.168.2.0

192.168.1.10 192.168.1.11 192.168.2.10 192.168.2.11

192.168.1.1 192.168.2.1

ip route add 192.168.1.0/24 via 192.168.2.1

ip
iproute
routeadd
add172.217.194.0/24 via 192.168.2.1
default via 192.168.2.1

route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 192.168.2.1 255.255.255.0 UG 0 0 0 eth0
© Copyright KodeKloud
172.217.194.0
0.0.0.0 192.168.2.1
192.168.2.1 255.255.255.0
255.255.255.0 UG
UG 0
0 0
0 0
0 eth0
eth0
default
192.168.2.0 192.168.2.1
0.0.0.0 255.255.255.0
255.255.255.0 UG
UG 0
0 0
0 0
0 eth0
eth0
Default Gateway INTERNET

172.217.194.0
INTERNET

216.134.45.0
INTERNET

16.44.53.0

A eth0 eth0 B C eth0 eth0 D


192.168.1.0 192.168.2.0

192.168.1.10 192.168.1.11 192.168.2.10 192.168.2.11

192.168.2.1
192.168.1.1

192.168.2.2

ip route add 192.168.1.0/24 via 192.168.2.2

route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0
default 192.168.2.1
192.168.2.1 255.255.255.0
255.255.255.0 UG 0 0 0 eth0
© Copyright K odeK l oud 192.168.1.0 192.168.2.2 255.255.255.0 UG 0 0 0 eth0
??

A eth0 192.168.1.0 eth0 B eth1


192.168.2.0
eth0 C

192.168.1.5
192.168.1.6 192.168.2.6 192.168.2.5

ping 192.168.2.5
Connect: Network is unreachable

ip route add 192.168.2.0/24 via 192.168.1.6 ip route add 192.168.1.0/24 via 192.168.2.6

ping 192.168.2.5
© Copyright K odeK l oud
A eth0 192.168.1.0 eth0 B eth1
192.168.2.0
eth0 C

192.168.1.5
192.168.1.6 192.168.2.6 192.168.2.5

cat /proc/sys/net/ipv4/ip_forward
0

/etc/sysctl.conf
.6 echo 1 > /proc/sys/net/ipv4/ip_forward …
net.ipv4.ip_forward = 1
1 …
ping 192.168.2.5
Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
© Copyright KodeKloud
Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
Take Aways
ip link

ip addr

ip addr add 192.168.1.10/24 dev eth0

ip route route

ip route add 192.168.1.0/24 via 192.168.2.1

cat /proc/sys/net/ipv4/ip_forward
1

© Copyright KodeKloud
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just enough

Introduction
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
About Java

• Free Version Date


13 2019
• Open-source 12 2019
• Huge Community 11 2018
10 2018
9 2017
8 2014
7 2011
6 2006
5 2004

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Install Java

wget https://download.java.net....
openjdk-13.0.2_linux-x64_bin.tar.gz

tar –xvf openjdk-13.0.2_linux-x64_bin.tar.gz


/opt/jdk-13/bin/java -version Version Name
13 13
jdk-13.0.2/bin/java -version 12 12
openjdk version "13.0.2" 2020-01-14 11 11
OpenJDK Runtime Environment (build 13.0.2+8) 10 10
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode,
sharing) 9 9
8 1.8
java -version 7 1.7
openjdk version "1.8.0_242" 6 1.6
OpenJDK Runtime Environment (build 1.8.0_242-b08) 5 1.5
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
https://jdk.java.net/13/
Java Development Kit (JDK)

Develop Build Run

jdb javac JRE

javadoc jar (Java Runtime Environment)

java

ls jdk-13.0.2/bin
jaotc javadoc jdeprscan jinfo jps jstatd rmiregistry
jar javap jdeps jjs jrunscript keytool serialver
jarsigner jcmd jfr jlink jshell pack200 unpack200
java jconsole jhsdb jmap jstack rmic
javac
© Copyright jdb
KodeKloud jimage. jmod jstat rmid Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Before v9

Java Development Kit (JDK)


JRE
Develop Build Run
(Java Runtime Environment)
jdb javac
javadoc jar
java

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
After v9

Java Development Kit (JDK)


Develop Build Run

jdb javac JRE


javadoc jar
(Java Runtime Environment)
java

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just enough

Build
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Compile
MyClass.java

1. Develop Source Code public class MyClass {


public static void main(String[] args) {
System.out.println("Hello World");
}
}

2. Compile javac MyClass.java


MyClass.class

3. Run java MyClass


Hello World

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Compile
MyClass.java Machine Code
public class MyClass { 01101000 10111100 10000001
public static void main(String[] args) { 01100100 01011100 00010111
System.out.println("Hello World"); 00001010 00001110 11111010
}
10110001 01101000 10111100
} Compiler
10000001 01100100 01011100
00010111 00001010 00001110
11111010 10110001 10110001

Human Readable Machine Readable


Source Code Machine Code

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Java Virtual Machine

MyClass.class Machine Code


MyClass.java
public class MyClass {
0: iconst_2 01101000 10111100 10000001
public static void main(String[] args) { 1: istore_1 01100100 01011100 00010111
System.out.println("Hello World");
}
2: iload_1 00001010 00001110 11111010
} 3: sipush 1000 10110001 01101000 10111100
Compiler 6: if_icmpge 44 10000001 01100100 01011100
9: iconst_2 00010111 00001010 00001110
10: istore_2 11111010 10110001 10110001
11: iload_2
12: iload_1 JVM
13: if_icmpge 31

Human Readable Intermediary Machine Readable


Source Code Byte Code Machine Code

javac MyClass.java java MyClass


© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
MyClass.class Hello World
Package
MyClass.class

Dependency 1 Service1.class

Dependency 2 Service2.class
Dependency 3
Utility.class

Tools.class
Java Archive
(JAR)

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Package
META-INF/MANIFEST.MF
MyClass.class

Dependency 1 Service1.class Manifest-Version: 1.0


Created-By: 1.8.0_242 (Private Build)
Dependency 2 Service2.class Main-Class: MyClass

Dependency 3
Utility.class

Tools.class
Image 1
Java Archive Web Archive
Image 2 HTML 1 (JAR) (WAR)
HTML 2

jar cf MyApp.jar MyClass.class Service1.class Service2.class ...


MyApp.jar

java -jar MyApp.jar


© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Hello World
Document

javadoc –d doc MyClass.java

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Build Process

Develop Compile Package Document

javac MyClass.java

jar cf MyClass.jar ..

javadoc MyClass.java
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Build Process

© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Build Tools

• Maven # Build Steps


• Gradle
• ANT 1.Compile

2.Package

3.Document

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
ant compile jar
ANT
BUILD SUCCESSFUL build.xml
Total time: 2 seconds
<?xml version="1.0"?>
<project name="Ant" default="main" basedir=".">
<!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile">
javac MyClass.java <javac srcdir="/app/src" destdir="/app/build">
</javac>
</target>
<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc packagenames="src" sourcepath="/app/src" destdir="/app/docs">
<!-- Define which files / directory should get included, we include all -->
<fileset dir="/app/src">
javadoc MyClass.java <include name="**" />
</fileset>
</javadoc>
</target>
<!--Creates the deployable jar file -->
<target name="jar" depends="compile">
<jar basedir="/app/build" destfile="/app/dist/MyClass.jar" >
<manifest>
jar cf MyClass.jar .. <attribute name="Main-Class" value="MyClass" />
</manifest>
</jar>
</target>
<target name="main" depends="compile, jar, docs">
<description>Main target</description>
© Copyright KodeKloud </target>
Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg

</project>
Maven

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
https://github.com/shopizer-ecommerce/shopizer
Gradle

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
https://github.com/arun-gupta/docker-java-sample
Summary

• Java
• Java Runtime Environment
• Java Development Kit
• Compiling a Java application
• Packaging a given application to JARs
• What are Build Tools?

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just enough

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
JavaScript

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
https://enonic.com/blog/websites-past-and-present
NodeJS

• Free Node.js 13.x


• Open source
• Cross Platform Compatible Node.js 12.x
Node.js 11.x
Node.js 10.x
Node.js 9.x
Node.js 8.x
Node.js 7.x
Node.js 6.x
Node.js 5.x
Node.js 4.x
Node.js 0.12.x
© Copyright KodeKloud Node.js 0.10.x
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Install NodeJS

curl -sL https://rpm.nodesource.com/setup_13.x | bash -

yum install nodejs


© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
NodeJS Commands
node -v
V13.10.1

node add.js add.js


Addition : 15 // Returns addition of two numbers
let add = function (a, b) {
return a+b;
};

const a = 10, b = 5;

console.log("Addition : "+ add(a,b));

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just enough

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Node Package Manager (NPM)

• Files
• Web Servers
• Databases
• Security
• Many More

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
https://www.npmjs.com/
NPM Commands
npm -v
6.13.7

npm search file


NAME | DESCRIPTION | AUTHOR | DATE
file | Higher level path… | =aconbere | 2014-02-21
File | HTML5 FileAPI… | =coolaj86 =narf | 2014-10-24
dotenv | Loads environment… | =~jcblw… | 2019-10-16
fs-extra | fs-extra contains… | =jprichardson… | 2019-06-28
file-loader | A file loader… | =d3viant0ne… | 2020-02-19

npm install file node_modules


+ [email protected]
added 1 package from 1 contributor and audited 1 package in 1.072s file
found 0 vulnerabilities LICENSE
README.md
package.json
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
lib
package.json
NPM Commands
{
"author": {
"name": "Anders Conbere",
"email": "[email protected]"
},
"bundleDependencies": false,
"devDependencies": {
"mocha": "1.9.x"
},
"directories": {
"lib": "lib"
},
"homepage": "https://github.com/aconbere/node-file-utils#readme",
"license": "MIT",
"main": "./lib/file",
"name": "file",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/aconbere/node-file-utils.git" node_modules
},
"tags": [
"file",
file
"path", LICENSE
"fs",
"walk"
], README.md
"version": "0.2.2"
} package.json
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
lib
NPM Commands
npm install file
+ [email protected]
added 1 package from 1 contributor and audited 1 package in 1.072s
found 0 vulnerabilities

app.js my_application
var file = require("file");
node_modules
file.mkdirs("/tmp/dir1") file
LICENSE
README.md
node -e "console.log(module.paths)"
package.json
[ '/app/node_modules', '/node_modules' ]
lib
npm install file -g app.js
© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Common Modules

Built-In Modules External Modules


fs To handle filesystem express Fast, unopinionated, minimalist web
http To host an HTTP server framework
os To work with the Operating System react To create user interfaces
events To handle events debug To debug applications
tls To implement TLS and SSL async To work with asynchronous JS
url To Parse URL Strings lodash To work with arrays, objects, strings etc

ls /usr/lib/node_modules/npm/node_modules/ ls /usr/lib/node_modules/

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
package.json
Application Dependencies
{
"name": "example-contentful-theExampleApp-js",
"version": "0.0.0",
"private": true,
"dependencies": {
"body-parser": "^1.18.2",
"contentful": "^6.0.0",
"cookie-parser": "~1.4.3",
"dotenv": "^5.0.0",
"execa": "^0.9.0",
"express": "^4.16.2",
"helmet": "^3.11.0",
"lodash": "^4.17.5",
"marked": "^0.3.16",
"morgan": "^1.9.1",
"pug": "~2.0.0-beta6"
}
}
© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just enough

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Python

• Free
• Open source
• Cross Platform Compatible

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Download

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
https://www.python.org/downloads/
Versions

• Python2 – (2000 – 2010)


• Python3 – (2008 to Present)

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Install
yum install python2 yum install python36

python2 python3
Python 2.7.16 (default, Nov 17 2019, 00:07:27) Python 3.6.8 (default, Nov 21 2019, 19:31:34)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux2 [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" Type "help", "copyright", "credits" or "license"
for more information. for more information.
>>> exit() >>> exit()

python2 -V python3 -V
Python 2.7.16 Python 3.6.8

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Python Commands

python2 main.py main.py

Hello World
def print_message():
print("Hello World")

if __name__ == '__main__':
print_message()

© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud
just enough

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Python Package Manager (pip)
python2 -V python3 -V
Python 2.7.16 Python 3.6.8

pip2 -V pip3 -V
pip 9.0.3 from /usr/lib/python2.7/site-packages pip 9.0.3 from /usr/lib/python3.6/site-packages
(python 2.7) (python 3.6)

pip -V
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)

pip install flask

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Python Package Manager (pip)
pip install flask

usr
lib
python2.7
site-packages
Python3.6
site-packages
lib64
python2.7
site-packages
Flask-1.1.1.dist-info
python3.6
© Copyright K odeK l oud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

site-packages
Python Package Manager (pip)
pip install flask

pip show flask


Name: Flask usr
Version: 1.1.1 main.py
Summary: A simple framework for building complex lib
web applications.
from flask import Flask, request
Home-page: https://palletsprojects.com/p/flask/ python2.7
Author: Armin Ronacher app = Flask(__name__)
site-packages
Author-email: [email protected]
License: BSD-3-Clause Python3.6
Location: /usr/lib64/python2.7/site-packages @app.route('/')
Requires: Werkzeug, click, Jinja2, itsdangerous def hello(): site-packages
return 'Hello,
lib64 World'
python2 -c "import sys; print(sys.path)"
python2.7
'/usr/lib/python27.zip', '/usr/lib64/python2.7',
'/usr/lib64/python2.7/plat-linux2', site-packages
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old', Flask-1.1.1.dist-info
'/usr/lib64/python2.7/lib-dynload', python3.6
© Copyright KodeKloud
'/usr/lib64/python2.7/site-packages', Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

'/usr/lib/python2.7/site-packages' site-packages
Requirements
requirements.txt
pip install flask
Flask
Flask==0.10.1
pip install jinja2
Jinja2
Jinja2==2.7.3
pip install markupsafe
MarkupSafe
MarkupSafe==0.23

pip install Werkzeug Werkzeug


Werkzeug==0.9.6

pip install requests requests


requests==2.3.0

pip install gunicorn gunicorn


gunicorn==18.0

pip install flask jinja2 markupsafe pip install –r requirements.txt

© Copyright KodeKloud Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Upgrade/Uninstall Package

pip install flask --upgrade


Installing collected packages: click, flask
Attempting uninstall: flask
Found existing installation: Flask 0.10.1
Uninstalling Flask-0.10.1:
Successfully uninstalled Flask-0.10.1
Successfully installed click-7.1.1 flask-1.1.1

pip uninstall flask


Found existing installation: Flask 1.1.1
Uninstalling Flask-1.1.1:
Would remove:
/home/vagrant/.local/bin/flask
/home/vagrant/.local/lib/python3.5/site-
packages/Flask-1.1.1.dist-info/*
/home/vagrant/.local/lib/python3.5/site-
packages/flask/*
Proceed (y/n)? y
© Copyright Successfully
K odeK l oud uninstalled Flask-1.1.1 Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg
Other Package Managers

• easy_install easy_install install app

</>

app.py setuptools app.egg

• wheels pip install app.whl

</>

app.py setuptools app.whl


© Copyright KodeKloud Check out our full course on DevOps Pre-R equisites: https://kode.wiki/43z8frg
Check out our full course on DevOps Pre-Requisites: https://kode.wiki/43z8frg

© Copyright KodeKloud

You might also like