❌

Reading view

There are new articles available, click to refresh the page.

Installation of Linux Mint 22.1 Cinnamon Edition

Linux Mint 22.1 Cinnamon Edition iso
download link
https://mirrors.cicku.me/linuxmint/iso/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso
Installation of Linux Mint 22.1 Cinnamon Edition

make the iso file to a usb installer
then in bios settings make usb as first boot order
insert the pendirve automatically it detects the Linux Mint OS
and this screen will appear

select β€œstart linux mint” then hit enter
we got the linux mint home screen

now double click the β€œinstall linux mint” icon
in the welcome screen choose β€œEnglish” and continue

select keyboard layout to English (US) and continue

Next we got the multimedia codecs wizard leave as it is and
hit continue

next we got the installation type wizard
select β€œsomething else ” and continue

in the next wizard click β€œNew Partition Table”

we got the β€œcreate new empty partition table on this device ?” wizard
click continue

then select the free space and click β€œ+”

we got the create partition wizard
give the size for root partition (Maximum size 85%)
use as β€œExt4 journaling file system”
Mount point : /
then click β€œOK”

then again select the free space and click β€œ+” sign

give the size for swap (twice the size of RAM usually)
select Use as: swap area
then click β€œOK”

again select the free space and click β€œ+” sign
give the size for EFI partition 1GB
select Use as: EFI system partition
and click β€œOK”

again select the free space and click β€œ+” sign
give the size 100 MB for
use as : β€œReserved BIOS boot area” then click OK

then click Install continue

the give the time zone as kolkata

then click continue and in the next wizard
give username , computer name , password
either choose login automatically or require password

then click β€œcontinue”
the installation process tookΒ  a while
when the installation complete
it will ask to remove the installation medium and press ENTER

the system reboots and Linux Mint cinnamon home page will be displayed

πŸ™‚

Python – user input

$ vim user_input.py
roll_num = int(input("Enter your roll no.:"))
message = "Hello user your roll number is " + str(roll_num)
print(message)
:x

or

$ vim user_input.py
roll_num = int(input("Enter your roll no.:"))
print("Hello user your roll number is " + str(roll_num))
:x 

$ python user_input.py


Python print statement

syntax:
print(object(s), sep=separator, end=end, file=file, flush=flush)

$ print("Hello, Python!")
$ print('Hello, World!')
$ print("Hello","Dhana")

$ vim print.py
x = ("python", "php", "c", "c++")
print(x)
:x
$ python print.py

Terraform code for AWS Postgresql RDS

create directory postgres and navigate
$ mkdir postgres && cd postgres
create main.tf file
$ vim main.tf

provider "aws" {
}
resource "aws_security_group" "rds_sg" {
name = "rds_sg"
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}

resource "aws_db_instance" "myinstance" {
engine = "postgres"
identifier = "myrdsinstance"
allocated_storage = 20
engine_version = "14"
instance_class = "db.t3.micro"
username = "myrdsuser"
password = "myrdspassword"
parameter_group_name = "default.postgres14"
vpc_security_group_ids = ["${aws_security_group.rds_sg.id}"]
skip_final_snapshot = true
publicly_accessible = true
}

output "rds_endpoint" {
value = "${aws_db_instance.myinstance.endpoint}"
}

save and exit
$ terraform init
$ terraform plan
$ terraform apply -auto-approve
Install postgres client in local machine
$ sudo apt install -y postgresql-client
To access AWS postgresql RDS instance
$ psql -h <end_point_URL> –p=5432 –username=myrdsuser –password –dbname=mydb
To destroy postgresql RDS instance
$ terraform destroy -auto-approve

Terraform code for AWS MySQL RDS

create directory mysql and navigate
$ mkdir mysql && cd mysql
create main.tf
$ vim main.tf

provider "aws" {
}
resource "aws_security_group" "rds_sg" {
name = "rds_sg"
ingress {
from_port = 3306
to_port = 3306
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}

resource "aws_db_instance" "myinstance" {
engine = "mysql"
identifier = "myrdsinstance"
allocated_storage = 20
engine_version = "5.7"
instance_class = "db.t2.micro"
username = "myrdsuser"
password = "myrdspassword"
parameter_group_name = "default.mysql5.7"
vpc_security_group_ids = ["${aws_security_group.rds_sg.id}"]
skip_final_snapshot = true
publicly_accessible = true
}

output "rds_endpoint" {
value = "${aws_db_instance.myinstance.endpoint}"
}

save and exit
$ terraform init
$ terraform plan
$ terraform apply -auto-approve
install mysql client in local host
$ sudo apt install mysql-client
To access the mysql
$ mysql -h <end_point_URL> -P 3306 -u <username> -p
To destroy the mysql RDS instance
$ terraform destroy -auto-approve

code for s3 bucket creation and public access

provider "aws" {
region = "ap-south-1"
}

resource "aws_s3_bucket" "example" {
bucket = "example-my"
}

resource "aws_s3_bucket_ownership_controls" "ownership" {
bucket = aws_s3_bucket.example.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_public_access_block" "pb" {
bucket = aws_s3_bucket.example.id

block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}

resource "aws_s3_bucket_acl" "acl" {
depends_on = [aws_s3_bucket_ownership_controls.ownership]
bucket = aws_s3_bucket.example.id
acl = "private"
}

S3 bucket creation and object storage

create directory s3-demo and navigate
$ mkdir s3-demo && cd s3-demo
create a demo file sample.txt and contents
$ echo β€œthis is sample object to store in demo-bucket” > sample.txt
create main.tf file
$ vim main.tf

provider "aws" {
region = "ap-south-1"
}

resource "aws_s3_bucket" "example" {
bucket = "mydemo-bucket1"
}

resource "aws_s3_object" "object" {
bucket = aws_s3_bucket.example.bucket
key = "sample.txt"
source = "./sample.txt"
}

save and exit
$ terraform init
$ terraform plan
$ terraform apply -auto-approve

create S3 bucket using terraform

create directory s3 and navigate to the directory
$ mkdir s3 && cd s3
create main.tf file
$ vim main.tf

provider "aws" {
region = "ap-south-1"
}

resource "aws_s3_bucket" "my_bucket" {
bucket = "mydemo-bucket"
}

save and exit
$ terraform init
$ terraform plan
$ terraform apply -auto-approve
To destroy the bucket
$ terraform destroy -auto-approve

How to configure AWS CLI and configure in ubuntu

Install AWS CLI
$ sudo apt install awscli -y
To check for the version
$ aws –version
To configure AWS account crdentials
copy the access and secret key from AWS account security credentials
$ aws configure
AWS Access Key ID [None]: *****************Β 
AWS Secret Access Key [None]: ******************
Default region name [None]: ap-south-1
Default output format [None]: json or table or text

How to create AWS EC2 instance using Terraform

create directory ec2 and navigate to the directory
$ mkdir ec2 && cd ec2
create main.tf file
$ vim main.tf

provider "aws" {
region = "ap-south-1"
}

resource "aws_instance" "app_server" {
ami = "ami-03f4878755434977f"
instance_type = "t2.nano"
subnet_id = "subnet-0ccba3b8cfd0645e2"
key_name = "awskey"
associate_public_ip_address = "true"
tags = {
Name = "demo-server"
}
}

output "public_ip" {
description = "public ip of the instance"
value = aws_instance.app_server.public_ip
}

save and exit
initialize the terraform
$ terraform init
$ terraform plan
$ terraform apply -auto-approve
it will create the AWS EC2 instance with output the public ip of the instance

To destroy the instance
$ terraform destroy -auto-approve

How to install Terraform in Ubuntu

Method1: Package manager
$ wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg –dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
$ echo β€œdeb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main” | sudo tee /etc/apt/sources.list.d/hashicorp.list
$ sudo apt update && sudo apt install terraform
$ terraform version
To get help options
$ terraform -h

Method2: Binary download
download the binary from wget https://developer.hashicorp.com/terraform/downloads
$ wget https://releases.hashicorp.com/terraform/1.6.6/terraform_1.6.6_linux_amd64.zip

extract using unzip
$ unzip terraform_1.6.6_linux_amd64.zip
$ mv terraform /usr/local/bin/
$ terraform version
$ terraform -h

To remove terraform binary method
$ sudo rm -f /usr/local/bin/terraform

To remove terraform package manager method
$ sudo apt remove terraform --purge

How to install AWS EKS Cluster

Β 

step1: create EC2 instance

step2:
Create an IAM Role and attach it to EC2 instance 
IAM 
EC2 
VPC 
CloudFormation 
Administrative access

In the EC2 instance install kubectl and eksctl
step3: install kubectl
$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin
$ kubectl version --client

step4: install eksctl
$ curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
$ sudo mv /tmp/eksctl /usr/local/bin
$ eksctl version

step5: install aws-iam-authenticator
$ curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.6.14/aws-iam-authenticator_0.6.14_linux_amd64
$ chmod +x ./aws-iam-authenticator
$ mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$HOME/bin:$PATH
$ echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
step6:
create clusters and nodes
$ eksctl create cluster --name dhana-cluster --region ap-south-1 --node-type t2.small

step7:
Validate your cluster using by creating by checking nodes and by creating a pod
$ kubectl get nodes
$ kubectl run pod tomcat --image=tomcatΒ 
$ kubectl run pod nginx --image=nginx

To delete the cluster dhana-cluster
$ eksctl delete cluster dhana-cluster --region ap-south-1

AWS CLI for AWS RDS PgSQL

To create postgres DB
$ aws rds create-db-instance --db-instance-identifier demo-postgresql --db-instance-class db.t3.micro --engine postgres --master-username postgres --master-user-password passcode123 --allocated-storage 20

To describe and get the endpoint url
$ aws rds describe-db-instances --db-instance-identifier demo-postgresql | grep Address

To access the remote postgresql
$ psql --host=<endpoint_url> --port=5432 --username=postgres
--dbname=postgres --password

To delete the db instance without final snapshot and automated backups
$ aws rds delete-db-instance --db-instance-identifier demo-postgresql
--skip-final-snapshot --delete-automated-backups

AWS CLI for AWS RDS MySQL

To create a mysql db
$ aws rds create-db-instance --db-instance-identifier demo-mysql --db-instance-class db.t3.micro --engine mysql --master-username admin --master-user-password passcode123 --allocated-storage 20

To describe and get the endpoint url
$ aws rds describe-db-instances --db-instance-identifier demo-mysql | grep Address

To access the remote mysql DB
$ mysql -h <endpoint_url> -P 3306 -u admin -p

To delete the db instance without final snapshot and automated backups
$ aws rds delete-db-instance --db-instance-identifier demo-mysql --skip-final-snapshot --delete-automated-backups

How to modify AWS EBS volume size and use in linux

choose the EBS volume and click modify
give the desired size to extend the volume
in Linux terminal umount the volume
$ sudo umount /dataΒ  (where the ebs volume is mounted)
$ sudo e2fsck -f /dev/xvdf
$ sudo resize2fs /dev/xvdf

mount the volume again
$ sudo mount -a
$ df -Th

tmux

To start a new session
# tmux new -s zha

To login to a tmux session
# tmux a -t zha
or
# tmux attach-session -t zha

# tmux kill-session -t zha
or
# tmux kill-session -t 1

# tmux detach
# tmux attach

❌