Friday, December 13, 2019

Print a large PDF poster onto multiple smaller sheets of paper at home

How to print a PDF poster with large pages onto multiple smaller sheets of paper at home?

If you like to print a large poster pdf file, you can use professional software such as photoshop or Corel but Acrobat Reader also has a feature to print single page file into multiple pages and join them together.

1. Open your pdf file in Adobe Reader.

2. Click on File -> Print

3. On the print dialog box, there is an option called Poster under Page Sizing & Handling, click on it.

4. Under Poster, the page will be break down into small pages.

5. You can print a highlight part page or all the pages. Click on print to print all parts of the page.

6. If can print just one part of your poster by just zooming and resizing the windows just to make sure you want to print is right.

7. Click on More Options and click on Current View to print a single portion of the file.

Thursday, June 13, 2019

kubectl auto completion of commands

If you want kubectl to behave like a base shell - tab completion of the command (press the tab twice), add following lines on user's .profile/.bash_profile

$ echo  "source <(kubectl completion bash)" >> ~/.bashrc

Sunday, June 9, 2019

RHEL7 - Creating Partitions Larger Than 2TB in Linux

Creating Partitions Larger Than 2TB in Linux

If you have requirement to create a partition under linux system, you have to be careful.

There are are two ype of partition available on x64 based systems.

MBR - Master Boot record
GPT - GUID Partition Table
MBR does not support 2TB partition.

Convert DOS/MBR disk to GPT disk

# parted /dev/mapper/ORAu01

(parted) rm 1
Is this a GPT partition table? Yes/No? yes

(parted) mklabel GPT
(parted) print

Number Start End Size File system Name Flags

(parted) mkpart primary 0.00TB 6.05TB
(parted) print

(parted) quit

# fdisk -l /dev/mapper/ORAASM
# pvcreate /dev/mapper/ORAASMp1
# vgcreate VG1 /dev/mapper/ORAASMp1
# lvcreate -n ORAlv1 -l 100%FREE VG21
# mkfs.ext4 /dev/VG1/ORAlv1

Add entry to fstab
# vi /etc/fstab
/dev/VG1/ORAlv1 /data ext4 defaults 1 2

Create mount point and mount it.
# mkdir /data; mount -a; df -h /data

Note the error alert by mkpart on parted command output.

Tuesday, May 28, 2019

RHEL8 - Web Console Cockpit Interface

RHEL8 - Web console cockpit interface

Very hand tool and faster as well to manage your system.

1. Install cockpit
# yum search cockpit
review the output

# yum install cockpit

2. firewall-cmd --list-all

enable port 9090

3. Login to your local system, you will get message if cockpit is enable.
# ssh user@localhost
Activate the web console with: systemctl enable --now cockpit.socket

The error shows that cockpit web interface is not enable.
Enable it,
# systemctl enable cockpit.scoket

Logout and login back, you will get the message with URL of the webconsole. Copy and paste on the browser.

Enter username/PW and also click enable previledge access..

Browse different memus from left pane.

System - check mem, cpu
logs - system logs
storage, play around,
you can expand root fs and other filesystems.

networking - firewall, network bonding, interface/IP

accounts - create account, change pw, add ssh

Services - lists all system services, ssh - > check log for ssh, start/stop/disable/enable service.

Applications - any other plugins
Giagnostic report - sos report
kernel dump - enable or disable
selinux - on or off, review the errors
software updates - upto date
subscription - current or unregister?
terminal - you can open terminal on the web browser.

you can switch to mobile interface as well.


Monday, May 13, 2019

RHEL7 - Server is on grub menu

Issue: NOC called about not responding one of the linux server.

What I found: When login through console, server on grub menu.

1. List all disk, disk partition on your system using ls command
grub > ls
(hd0) (hd0,msdos1) hd0,msdos2) ........ so on

Now, you have to find the correct partition

grub > ls (hd0)
error: no such partition.
keep listing, until you find the right filesystem type. You need to know what type of filesystem are you using at your work place. it can be ext or xfs.

grub> ls (hd0,msdos1)
filesystem is ext*
all other partition are xfs, only os is on ext4

lets list the content from it
grub> ls (hd0,msdos1)/
you should be able to see grub2

so this is the right partition. If you didn't find it, keep listing the content of each disk, you will find one.

grub> set boot=(hd0,msdos1)
grub> set prefix=(hd0,msdos1/grub2
grub> insmod normal
grub> normal

system boots and you will be on grub menu. select the right kernel and boot  your system.

If it fails, repeat the same step and select the older kernel, you should be good to go...

Thursday, May 9, 2019

Winows: Install Chocolaty on win 10

Choco is a command line software installation tool on windows like yum on linux.

Installing Chocolatey

Here is the installation document,

Install with cmd.exe
Run the following command:   (copy command text)

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Inp

click on copy command
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(''))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Open your cmd prompt as a administrator.
- search for cmd and right click and run as administrator
- Right click and click on paste, it will take a while to install.

Choco is successfully installed

2. Lets Install some software. Lets try VLC (video player) using choco. (You can google for other software, if you need more info)
- At te prompt just type choco install vlc
  > choco install vlc
 > choco uninstall vlc
You can install using powershell
- Open your powershell as admin
- ,just type choco install vlc

This will install your software automatically

Installing other soft wares on your windows machine
> choco git install -y
> choco putty install -y

when you install git, git-bash is installed by default.
- using git-bash, you can run some basic linux commands.
- You can ssh to remote host using git-bash

Friday, May 3, 2019

AWS - Creating IAM user to Login to AWS management console

Creating IAM user to Login to AWS management console

1. Logint o AWS Management Console
2. Click on IAM under Security, Identity & Compliance
3. Click on Users on left pane
4. Click on Add User and specify the username
5. Specify the Access type:

You can have two type of access
a. Programmatic Access
b. AWS Management Console access

a. Programmatic Access
- You get whole lot of access with this type of access
- You can use CLI and other tools.
- When you create this type of account, make sure to save access ID and secret access key.
- As a normal user, select AWS console access

b. AWS Management Console access
- This is easy type of access
- This is only for web based, GUI based, click click level access.
- First time users, select this type of access.

6. Select AWS Management Console Access
7. Select Custom password and type your password on sonsole password option.
     Note the option - Require password reset.
8. Click Next to continue
9. On your new page, click on Create group
10. Under group name box, type the name of the group (say: webgrp) and attach a policy.
11. To attach a policy, there is search box but for us, we will be using AdninistratorAccess policy. Select it
12. Click on create group. Click next: Tags to tag
13. Click next: Review
14. inally click on create user
15. You will see a sucess windows. You will also see a link to login. Copy the link and go to browser and login with user name and password.
16. You should be able to login and access AWS console with full access.


Identity Access Management
- Centralized Access to AWS Account
- Shared Access to AWS Account
- Granular Permissions
- Identity Federation (AD, FB, Google, Linkedin)

Users, Groups, Role, Policy
- IAM Does not have region

Billing Alarm
- Your Account
- Billing dashboard

RHEL7 - Recover /boot partition on CentOS 7

How to recover /boot partition on CentOS 7?
 [ RHEL7 = CentOS]
If some reason /boot partition is not available, system is not able to boot.
Perform the following tasks below to recover your system.

1. Boot your system using CentOS iso image. You can burn it on DVD/USB and boot off it. Read hardware specific guide on how to mount ISO image and boot the IS.

2. Up on reboot, you will see three options on whic one of them is "Troublessoting". Select it and press enter to continue.

3. Select the option "Rescue a CentOS system" and press enter and enter again to continue

4. Specify Option 1 and press enter to continue..

5. Now, you are on rescue mode. Now, chroot to sysimage to troubleshoot
# chroot /mnt/sysimage

6. Now, you have to install three packages to troubleshoot
a. kernel
b. grub
c. logos

7. Go to package lcation and install them
# cd /mnt/Packages
# ls -l | egrep "kernel-|grub2-|logos"
# rpm -ivh --force groub-...... groub2-2...... centos-logos-.....

for redhat use redhat-logos

8. Install grub on your boot disk. Here is a tricky part. Find your boot device. Most of the case it is /dev/sda.
if you have multi disk
# grub2-install /dev/sda

if thats not the right disk tryp cfdisk command
# cfdisk /dev/sda ..sdb

9. Now, finally, generate grub.cfg file
# grub2-mkconfig -o /boot/grub2/grub.cfg

Exit twice to reboot the server.

system should be coming up fine..

if not, contact your best friend, which is google, or bing

Unix/Linux - sudo - superuser do, an example

sudo - superuser do
- This tool is used to delegate the admin task to particular user or group.
- Basically it allows you to run command being other user (speciially root) to execute some command.

Config file: /etc/sudoers
Log file: /var/log/messages
Editing tool: visudo  ( do not use vi, use visudo it will check the syntax and saves you from making mistakes)

Lets go real,

Now, lets create some users on your systems:

jay, ravi, sam and rita

Grant the following permission to these users.

1. User Jay and Ravi are new system admin and they needed full access to the system
2. sam is a database admin and need to mount and umount /APPLECFS filesystem. su to oinstall, gridmon, oradev user
3. Rita is a helpdesk technician but she should be able to create user

Now, to grant them access, edit the sudoers file

 # visudo

# Give full access to jay and ravi user which is like "root    ALL=(ALL)       ALL",

ravi ALL=(ALL) ALL

# if you want them to run command without specifying password, you can do like
# user_name ALL=(ALL) NOPASSWD: ALL

# or you can put these users together by specifying user alias
# User_Alias ADMINS = jay, ravi, devi, dan
#    or

User_Alias DBAS = bill, mary, sam
DBAS ALL:NOPASSWD: /usr/sbin/mount /APPLCFS, /usr/sbin/umount /APPLCFS, /usr/bin/su - oradev, /usr/bin/su - oinstall, /usr/bin/su - gridmon

# Granting rita user create access
User_Alias HELPDESK nani, kavi, rita
Cmnd_Alias HELP_CMDS = /usr/sbin/useradd, /usr/bin/passwd

User can login to the system with their user name and password, and run the command as

$ useradd nita
$ passwd nita
$ sudo useradd nita
$ sudo passwd nita

run all commands and find the differences.

RHEL - Record ssh session data of your system

Record your ssh session data

There are many ways to record your session data, here we are going to discuss couple of them.

1. Using Putty
- Open your putty, go to Session
- Expand Session and click on Logging
- on the file name section, click on browse and specify the location you want to save and click ok
- Filename putty.log is selected by default. You can change it if you like.
- Now, append the following before the log so that your file looks like this -     putty_&Y-&M-&D-T-H.log
- And click on check box Always append to the end of it.

2. Using script command
- After you login to your server, just type script command, it will generate typescript file by default on wherever you type it from.
$ script
Script started, file is typescript.
- All the command and output the command generates will be recorded on the file.

Specifying filename
- If you like to named the file you want, simply specify the file after the command
$ script cmd_list_`date "+%m-%d-%y_%H-%M-%S`.log

3. Recording session of a remote host on log server
- Login to your log server and connect to your remote server.
$ ssh sam@ | tee -a /opt/logs/120_session.log

you can keep typing your commands on your remote host 120 and all the output will be recorded on your source server.

To verify,
- open a duplicate session of your log server (the source server)
- Use cat or tail command to see the log info
$ tail -f /opt/logs/120_session.log

Monday, April 8, 2019

AWS:- Launch a new OS (Windows and Linux) instance on EC2 and login to the server

AWS:- Launch a new OS  instance on EC2

1. Login to your AWS account
=>Go to Service  => Go to  Compute and click on  EC2

2. You are on Ec2 Dashboard => Click on Launch Instance under create instance

3. OS Selection - AMI - You have to create one windows and one linux based system.
    - Select one of the 'free tier eligible' Amazon Machine Image (AMI) and click Next
    - Here, you can select different kind of operating systems. I select Windows 2008 R2 Base
    - Why Win 2008 R2? -> Its small in size and takes less CPU/Mem and disk space.
    - On Linux based systems, select any free tier account.

4. Choose an Instance Type  ( Resource - CPU/Mem ) and click next
    select a free tier eligible t2.micro which gives you 1 GB RAM, 1 CPU free.

5. On Configure Instance Details page you will define no. of host, and network related info such as VPC, subnet.
    just leave everything default and click on Add storage

6. On Add Storage page, root disk comes with 30GB for windoes. For now just leave default and click on Add Tags

7. On Add Tags page, click on 'click to add Name tage and fill the following information
   Name WinVM/LinuxVM
   Owner Samrat
   Purpose Learning
   Type Dev Server

8. Next click on Configure Security Group
  - Here you can leave default and click on Review and Launch.
  - here AWS creates new security Group and Windows  RDP ( port 3389 ) is added, on linux based systems ssh (22) is added.
  - Simply click on Review and Launch

9. On Review Instance Launch page, click on Launch to launch an instance.

10. Now, you will be prompted to create a new key or use the existing key pair.
    - We will create a new key pair. Select create a new key pair from drop down box.
    - Type the name of the keypair on 'Key pair name' box and lcik on 'Download Key Pair' button to download the key to your PC.
Download key ( *.pem )

PEM or Privacy Enhanced Mail is a Base64 encoded DER certificate. PEM certificates are frequently used for web servers as they can easily be translated into readable data using a simple text editor. Generally when a PEM encoded file is opened in a text editor, it contains very distinct headers and footers
Amazon EC2 uses public–key cryptography to encrypt and decrypt login information. Public–key cryptography uses a public key to encrypt a piece of data, such as a password, then the recipient uses the private key to decrypt the data. The public and private keys are known as a key pair.

11. Click on launch.
    - Wait for about 3-4 minutes, your instance is ready.

12. Now, You are on EC2 Dashboard
     - Click on Check box next the the Instance (WinVM) you want to login.
     -  Click on Connect
     - A 'Connect to your instance menu pops up.
     - Click on 'Download Remote Desktop File'
     - And click on 'Get Password' and click on 'Choose File'
     - Select the pem file you downloaded and click on 'Decrept Password' to decrept the code.
     - Now, Copy the following information
Public DNS:
User name: Administrator
Password : Ut5zUUAGUNF

On Linux Based VM,
     - Click on Check box next the the Instance (LinuxVM) you want to login.
     -  Click on Connect
     - A 'Connect to your instance menu pops up.
     - Here, you will get login info
         ssh -i "mykeyfile.pem"

How to connect to the server from your PC?

A. Connecting to Windows Systems.
1. You can simply click on RDP file you downloaded and enter your username/password

2. Open Remote Desktop and connect using the Public DNS address.
     - It will prompt you for username/passwd. After that you will be login into your machine.
       Run => mstsc

How do you change the root (Administrator) password
=> Click on start => Administrative Tools => Computer Management.
=> Click on Local Users and Computer => Click on Users
=> R. Click on Administrator and click on set password to change


Press WinKey + R ( start + Run => Type lusrmgr.msc on the box and press enter
   - You will be on Local users and Groups (Local)
   - and  change Administrator password

2. Connecting Windows Instance from Linux based systems.
    - I will be testing on Redhat/Centos version 7 (Works on RHEL6 as well). My windows system info is below,
Public DNS:
User name: Administrator
Password : Ut5zUUAGUNF

    - Perform the following tasks on your Linux session
# yum install  *freerdp*
# xfreerdp  -u  administrator  <IP/DNS_name>
# xfreerdp  -u  administrator

For older version of RHEL 5, ubuntu, use rdesktop

# yum  install rdesktop           -> RHEL/Centos
# apt-get   install  rdesktop     -> Ubuntu
- to connect
# rdesktop  -u  administrator  <IP/DNS_name> 

B. Connecting from your PC to Linux based Systems.

a. Connecting PC to Linux server using putty
1.  Go to site and download putty.exe, puttygen.exe (32 bit) [Download portable version]
     - Store both file on one folder

2. Convert .pem file to .ppk file format using puttygen file.
     - Since putty.exe cann't read key*.pem format, we have to convert it.
     - Open puttygen application and click on Load buttom.
    - Load the .pem file you downloaded from aws site.
    - Click on Save private Key as mykeyfile.ppk.

3. Open your putty now.
Here is login address provided by AWS
ssh -i "mykeyfile.pem"

   - Under Session  Look for hostname (or IP address)
   - Type IP or DNS_name with port 22
      (In my case: )
   - Go to Connection  => ssh => click on auth
   - Click on browse and select the key your saved. In my case - mykeyfile.ppk
   - It will prompt you for user, just type ec2-user, you should be able to login without any password.
   - Type sudo su - to become a root user. $ sudo su -

b. Connecting PC to Linux server using putty
   -  Go to google and search for MobaXterm_Portable. Download on your desktop and open the application.
     - Copy the downloaded key to your drive. I kept it under e:\downloads\awskeys

 ➤ cd e:/
 ➤ cd dowloads
 ➤ cd awskeys/
 ➤ ls

    -  Now, login to your Amazon OS instance. You wil be login without prompting for password.
 ➤ ssh -i "mynewvm.pem"

3. Connecting  from linux systems to your linux server.
Note: Download winscp.exe program
1. Upload the .pem key you downloaded into your server and perform the following tasks.
# mkdir /opt/awskeys
# chmod 777 /opt/awskeys

Now move the key into /opt/awskeys
# ls - List the files/folders
# pwd - see what path you are in.
# chmod  400  mykeyfile.pem
# ssh -i  17aug2017org.pem  ec2-user@<PUB_IP/DNS_name>
$ whoami
To switch to  root user
$ sudo su -
# whoami

[root@sam ~]#  ssh -i "mykeyfile.pem"
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is fc:06:3a:fa:c2:e8:a4:10:5c:04:70:04:72:0f:96:cb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (ECDSA) to the list of known hosts.

Last login: Tue Apr  9 00:00:41 2019 from
[ec2-user@ip-172-31-21-36 ~]$
[ec2-user@ip-172-31-21-36 ~]$ w
 00:28:55 up 46 min,  2 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
ec2-user pts/0    pool-108-45-108- 00:00   19:51   0.02s  0.19s sshd: ec2-user [priv]
ec2-user pts/1    pool-108-45-108- 00:28    5.00s  0.01s  0.01s w
[ec2-user@ip-172-31-21-36 ~]$ sudo su -
Last login: Tue Apr  9 00:04:50 UTC 2019 on pts/0
[root@ip-172-31-21-36 ~]# whoami
[root@ip-172-31-21-36 ~]# logout
[ec2-user@ip-172-31-21-36 ~]$ whoami
[ec2-user@ip-172-31-21-36 ~]$

Tuesday, April 2, 2019

AWS:- Create a snapshot of a volume

AWS:- Create a snapshot of a volume

1. Login to Amazon Management Console
2. EC2 => Snapshots in the navigation pane
3. Choose Create Snapshot.
4. Select the volume you want to create a snapshot for.
5. Add tags to your snapshot if you like.
6. Choose Create Snapshot.

Using command line to create a snapshot

=> First go to the volume and get the volume IP of the colume you want to take snapshot.
Volume ID = vol-1234567890abcdef0

aws ec2 create-snapshot --volume-id vol-1234567890abcdef0 --description "This is my root volume snapshot"

Source: Amazon

Monday, April 1, 2019

AWS:- Ansible Installation and Deployment on AWS servers

Ansible Installation and Deployment on AWS servers

1. Launch 3 EC2 instances on Oregan region as follows.
EC2 => Launch Instance => 3 machines { Redhat or Amazon ssd }
=> Security group [ http anywhere ]
=> Create new key pair and download to your wondows download folder.
=> Review and launch.

a. Get the private assress of your VM
Hostname Private IP Public IP

2. Now, we have 3 machines are ready. Rename the servers as ansible, web1 and web2
   a. User MobaX to connect to your LinuxVM.
        Open three MobaX tab to connect to three servers
➤ /drives/e/Downloads
ansible->    ssh -i "mykeyfile.pem"
webvm1->  ssh -i "mykeyfile.pem"
webvm2->   ssh -i "mykeyfile.pem"

   b. Setup all machines to connect directly as root or set up as password less authentication for root user.
- First login as normal user
- su to root  $ sudo su -
# mv /root/.ssh/authorized_keys  /opt
# vi /etc/ssh/sshd_config
  38 PermitRootLogin yes
            65 PasswordAuthentication yes
- Restart sshd demon.
# systemctl restart sshd/service httpd restart
- Chnage root password
# passwd root
- Verify direct root login with new password
➤ ssh
➤ ssh
➤ ssh
# ssh -q webvm1/webvm2

3. Since we don't have dns server set up. Add server entry to hostfile on your ansible server.
# vi /etc/hosts ansible webvm1 webvm2
- Try to ping webvm1 and webvm2 from ansible server. It will fail
- Go to security Group of ansible server. Incoming -> add rule for icmp ipv4 -> anywhere
- Now, it should ping.

[root@ip-172-31-31-175 ~]# ping webvm1
64 bytes from webvm1 ( icmp_seq=2 ttl=255 time=0.494 ms

[root@ip-172-31-31-175 ~]# ping webvm2
64 bytes from webvm2 ( icmp_seq=1 ttl=255 time=0.795 ms

4. On ansible server, install ansible
- First setup/enable epel repo on RHEL7 by changing from 0 to 1
- epel.repo file is already there. If not follow the instruction below.
# cd /tmp; wget
# yum install ./epel-release-latest-*.noarch.rpm
# vi /etc/yum.repos.d/epel.repo
# yum update
# yum clean all; yum repolist
# yum  install ansible
- Now, ansible installation is completed.

5. Now, log out as ec3-user and log back in as a root user using MobaX.

6. Create/setup an inventory file [ This file is a core file of ansible]
- At the buttom of the page, ass this entry.
- You can categorize/ group server based on type, function
# vi /etc/ansible/hosts
webvm1 or IP
webvm2 or IP

7. Now, lets run some ansible commands
[root@ip-172-31-31-175 ~]# ansible mywebvm -m ping -u root -k
SSH password:
webvm2 | SUCCESS => {
    "changed": false,
    "ping": "pong"
webvm1 | SUCCESS => {
    "changed": false,
    "ping": "pong"

The command below lists all hardware related info of mywebvm servers.
[root@ip-172-31-31-175 ~]# ansible mywebvm -m setup -u root -k

8. Lets configure web server using ansible.

a. Install httpd service on all the servers [ all means all the servers, not on specific group]
   - Pay attention to group/all.
[root@ip-172-31-31-175 ~]# ansible all -u root -m yum -a "name=httpd state=latest" -k

  - Now start the service on all the machines now. [ I specified group name now]
[root@ip-172-31-31-175 ~]# ansible mywebvm -u root -m service -a "name=httpd state=restarted" -k
SSH password:
webvm2 | SUCCESS => {
    "changed": true,
    "name": "httpd",
    "state": "started"
webvm1 | SUCCESS => {
    "changed": true,
    "name": "httpd",
    "state": "started"

- Now get the public IP address of webvm1 and webvm2 and paste on your browser.
In our case, here is the info

- You should see default page.

- Lets go ahead and create/update our default page.
  - on your ansible server create an index page.
[root@ip-172-31-31-175 ~]# cat /root/index.html
  <title>Welcome to My AWS Page </title>
<body bgcolor=black>
        <font color=yellow><h1> <marquee> Samrat on the web </marquee></h1></font>
- Lets push this file to default doc root page.
[root@ip-172-31-31-175 ~]# ansible mywebvm -m copy -a 'src=/root/index.html dest=/var/www/html' -k
webvm1 | SUCCESS => {
webvm2 | SUCCESS => {

- Go to the browser and paste the public IP again and verify the update.
- Again change the index file and push the update. You will see the change.

To get help,
# ansible-doc -l

This way, you can deploy lots of config update to hundreds of servers.

Learm docket/kubernets, git/jenkins, ansible/puppet/chef,Vagrant/cloud

8. Shutdown your AWS VM using command line
Make sure you set up your PC/linux to use command line (aws-cmd)

Stop EC2 Instnace
aws ec2 stop-instances --instance-id <INSTANCE-ID> --output json
aws ec2 wait instance-stopped --instance-ids <INSTNACE-ID>

Start EC2 Instnace
aws ec2 start-instances --instance-id <INSTNACE-ID> --output jso

Terminate EC2 Instances
aws ec2 terminate-instances --instance-ids <INSTNACE-ID> --output jso


Wednesday, March 27, 2019

AWS:- How to Create and Login to AWS OS Instance

How to Create and Login to Aws OS Instance

1. Click on Services   =>> Click on EC2 under compute
2. Click on Launch Instance
3. Click on Free Tier Only on the left hand side which only displays the OS instances
4. Select the Amazon Machine Image (AMI) you like.
5. Under Instance Type, select the t2.micro free tier eligible one. [ Redhat ]
6. Click configure Instance details
7. Under Configure Instance Details, leave as it is a click on Add storage from bottom right corner.
8. Do not add any storage, click on Next: Add Tags
9. On Add Tags page, look at the middle of the page, you will see Click to add a Name tag
10. On this key value pair section just type value as lxvm1 and click next
11. ssh is already enabled click on Review and Launch.
 12. Click on Launch, you will be prompting to select/create key pair.
13. Select create anew key pair and type the name of the key and save the key to your desktop
14. Click on launch and wait for another 4 minutes, server will be ready.

Login to AWS OS instancce.

1. Once you create an instance, click on the check box before the instance name.
2. Click on connect
3. You will get a link to connect,
ssh -i "mynewvm.pem"

4. Go to google and searcg for MobaXterm_Portable. Download on your desktop and open the application.
5. Copy the downloaded key to your drive. I kept it under e:\downloads\awskeys

 ➤ cd e:/
 ➤ cd dowloads
 ➤ cd awskeys/
 ➤ ls

6. Now, login to your Amazon OS instance. You wil be login without prompting for password.
 ➤ ssh -i "mynewvm.pem"

ec2-user@ip-172-31-25-98:~> sudo su -
ip-172-31-25-98:~ #

You will have 750 hrs free for new account, Once instance is created and lab part is completed, terminate it. Do not use delete, there will be charge on storage even instance is down.

To Terminate,
=> Go to Services  -==> EC2 Instances  ==> Select the instance you want to terminate.
==>  Go to Action  ==> Instance state  =>> Terminate.

It will warn you about termination, click on Yes Terminate.

You are good to go.

Friday, March 22, 2019

AWS: - Create S3 Bucket and upload file from PC

Create S3 Bucket and upload file from PC
1.    Login to AWS management console and click on Amazon S3.

2.    Click on Create Bucket
3.    Here, the name should be unique FNS-compliant name which must be unique across all existing bucket names in Amazon S3.

Fields are
Bucket Name: YYYYMMDDBucketname
Region: US East
Click next

4.    Under configure option tag your Bucket.

Here, you can click on create or Click next. I click next for more options.

5.    Click next and review the setting. If it looks good, click on create bucket

6.    Now, click on Bucket Name (do not click on check box)

7.    Click on upload to upload file to the bucket

8.    Click on Add files

9.    Select the file you want to upload.

10.                       File is successfully uploaded.
11.                       Now, Click on the file you just uploaded.
12.                       Click on Properties and review different options like versioning, server access logging, static website hosting, encryption and more. And click on Permission tab and go all the way bottom and click on Everyone. Everyone pops up and click on Read Object and click on save.

13.                       I got permission deny error.
14.                       Now go back to yor bucket and click on check box and click on Edit public access and remove all check boxes. Once its done go back to the promperies of the image and grant access to everyone.

15.                       Now, error is gone.  Go back to the bucket, and click on Image. On overview page you will see object URL, just copy it and paste on web browser, you should be able to see it.

16.                       If you want to delete the image, click on check box of the image, go to action and click on delete.

Cheers !!! You successfully created a S3 bucket and uploaded a file.

AWS:- Login to AWS

Login to AWS
1.    Go to
2.    Enter your account information
3.    You are logged in to AWS Management Console
4.    Click on Services on top right corner.

5.    Once you click on services, you will see many available services.

6.    By default, you can see the services based on category. If you like to change to list alphabetically, you can click on A-Z on right side corner.

And you will see like this,
7.    Click on different services to know and understand more.
There are lots of whitepapers, free trainings available @aws. Simply enroll and enjoy !!!

AWS:- Creating account on AWS

Creating account on AWS

1.    Go to

2.    Click on Sign in to the console

3.    Click on Create a new AWS account

4.    Fill Out the basic info on the page presented. The basic account includes 12 months of free tier access (750 hrs).

5.    Click on continue. Select personal for your personal use.

6.    Fill out the information and click on Create account and continue. Payment information page displays. Fill credit/David card info and click on Secure Submit.

7.    Your account is created successfully.

Saturday, March 2, 2019

RHEL7 - Create a simple web page

The script will create simple web page.
[root@server2 ~]# cat
# Specify the parameters

if [ $# -eq 0 ]
        echo "Please enter your domain name followed by script as command line parameter"

echo "<virtualhost $myip:$port>" > /etc/httpd/conf.d/$domain_name.conf
echo "servername $domain_name" >> /etc/httpd/conf.d/$domain_name.conf
echo "documentroot /var/www/html/$domain_name" >> /etc/httpd/conf.d/$domain_name.conf
echo "directoryindex index.html" >> /etc/httpd/conf.d/$domain_name.conf
echo "</virtualhost>" >> /etc/httpd/conf.d/$domain_name.conf

#mkdir /var/www/html/$domain_name
if [ ! -d "$domain_root" ]
        mkdir ${domain_root}

#echo "Welcome to $domain_name" >/var/www/html/$domain_name/index.html
echo "Welcome to $domain_name" > ${domain_root}/index.html

echo "Now, checking httpd systax"
httpd -t
if [ $? -eq 0 ]
        systemctl restart httpd
        echo "Your website $domain_name  is configured successfully"
        echo $myip $domain_name >> /etc/hosts
        echo "Please check the config file for error"

# firewall-cmd --list-all | grep http
# if [ $? -ne 0 ]
# then
#       firewall-cmd --permanent --add-service=http
#       firewall-cmd --reload

# nothing needed for else statement

[root@server2 ~]#

Saturday, January 26, 2019

Python - Buy 8 items and calculate the total

Buy 8 items and out of 8, 6 of them are taxable items. 2 are not. If total crosses $100, give 5% discount. Calculate the total.

print("Welcome to ABC store")
print("Please select the items from list below")
print("Items        Rate/per item($)")
print("-----        ----------------")
print("Apples          2 ")
print("Bananas         1")
print("Potatoes        3")
print("Medical1        5")
print("Medical2        4")
print("Item1           10")
print("Item2           8")


print("Please enter the quentity of the items you want to buy.")
apple = int(input('Quantity of apples: '))
banana = int(input('Quantity of banana: '))
potatoes = int(input('Quantity of potatoes: '))
medicine1 = int(input('Quantity of Medicine1: '))
medicine2 = int(input('Quantity of Medicine2: '))
item1 = int(input('Quantity of item1: '))
item2 = int(input('Quantity of item2: '))


print("Apple Bill is $", apple_total)
print("Banana Bill is $", banana_total)
print("Potato Bill is $", potatoes_total)
print("Medicine1 Bill is $", medicine1_total)
print("Medicine2 Bill is $", medicine2_total)
print("Item1 Bill is $", item1_total)
print("Item2 Bill is $", item2_total)

print("Taxable item total is $",taxed_item_total)
print("total tax is $",total_tax_bill)

print("Taxable total Bill is $", total_taxable_item)
print("Non-taxable item Bill is $",nontax_total)
print("The total of all item is $", total_all)

if total_all >=100:
    print("Your total Bill is $", grandtotal)
    print("You saved $",discount," today")
    print("Total Bill is $",total_all)

print("You have purchased total of",total_items,"items")
print("Thank you for shopping ABC store")

=================== Resumt ====================

Welcome to ABC store
Please select the items from list below

Items        Rate/per item($)
-----        ----------------
Apples          2 
Bananas         1
Potatoes        3
Medical1        5
Medical2        4
Item1           10
Item2           8

Please enter the quentity of the items you want to buy.
Quantity of apples: 2
Quantity of banana: 6
Quantity of potatoes: 7
Quantity of Medicine1: 3
Quantity of Medicine2: 8
Quantity of item1: 9
Quantity of item2: 2

Apple Bill is $ 4
Banana Bill is $ 6
Potato Bill is $ 21
Medicine1 Bill is $ 15
Medicine2 Bill is $ 32
Item1 Bill is $ 90
Item2 Bill is $ 16

Taxable item total is $ 137
total tax is $ 6.8500000000000005

Taxable total Bill is $ 143.85
Non-taxable item Bill is $ 47
The total of all item is $ 190.85
Your total Bill is $ 181.3075
You saved $ 9.5425  today

You have purchased total of 37 items
Thank you for shopping ABC store

Friday, January 25, 2019

Python - Installing Python Practicing tools Eclipse, PyCharm

There are so many IDE tools available. On of the best on Windows machines are followings
1. Eclipse
2. PyCharm


1. Eclipse
Installing Eclipse IDE on Windows 10 for python3

Prerequisite task
a. Make sure you installed Python 3 on your system
b. Make sure you have enough disk space on your system.

a. Download Eclipse:
Go to official Eclipse website and download the software and download latest Eclipse IDE for Windows.

I downloaded Eclipse IDE 2018‑12

b. Install the software
- Double Click on downloaded file and choose: Eclipse IDE for C/C++ Developer
- Select the directory C:\Eclipse2 as your installation directory.
- Just click accept and install it.

A. Installation of the PyDev plug-in for Eclipse

- Open your Eclipse
- Go to help -> Install New Software
- Type the URL in the Work with:  field
- And click on Add
- You have two options.
a. PyDev
2. PyDev Mylyn Integration
- Select the first one. 1. PyDev
- Click next/yes.OK/ Trust certificate and complete the installation.

B. Configuring PyDev
- On your Eclipse software, click on Windows and click on preferences
- From the lift side listings, Double click on PyDev and Double click on Interpreters
- Click on Python Interpreter and click on New
Interpreter Name: Python3
Interpreter Executable: C:\Python3\python3.exe (or Python Installed Location)

- Click OK. Verify and select the PATH and click ok.

Writing First Python Program on Eclipse

First Change the Perspective
- Click on Windows on your Eclipse
- Click on  Perspective  and point to open Perspective and Other
- Click on PyDev
- Now, Eclipse will restart

Once Eclipse is restarted,
- Click on File  and point to New and click on PyDev Project
- Type the name of the Project Name (Python-Practice)
- Click Finish
- Now, Right Click on Project Name => New => File
- Type the file Name as and click finish.
- Type the following lines

# Hello World on Python
print (“Hello, World !!!")

Now, Save the file and execute the program.

- To complete, type
- Ctrl+S to save the file
- Ctrl+B to Build the program
- Ctrl+F11 to execute the program

Review the output
You can add more lines to learn more.

2. There is another great tool called PyCharm, simply download and practice.

- Simply down and install it. So simple. Download the edu version which comes with example.
Superb tool !!!

3. Other tool to practice Python is to use the online verson of

Once of the great tool available online.

Python - Installation on Linux and Windows 10

A. Installing on Linux
a. To install python on Linux, you have to use software installation tool such as yum for redhat
# yum search python
# yum install python

By default, python is install on most operating systems. You may already have version 2.x installed.

After the installation, you must set PATH for version 3.

A. Installing Python3 in Windows

1. Download python3 from the web

As of now, the latest version is - Python 3.7.2 - 2018-12-24
I downloaded,

2. Installation process
a. Create a directory Python3 under the C drive.
b. Double click the python installer and choose customize.
c. Chose installation directory as C:\Python3 and click on Install
d. Accept the default options and continue until inish.

B. Setting up the Environment Variable (Windows 10)

a. Right Click on My Computer or This PC
b. Click on Properties; and then click on on Advanced System Settingsor
c. Click on Advanced and then on Environment Variables at the bottom.
d. On your Environment Variable windows, look under system variables.
e. Search the variable Path and once found, double click to edit
f. Click on New and type c:\Python3 and click ok.
g. Once you click ok, you will see something like this.
C:\Program Files (x86)\iCLS Client\;......;C:\Python3

C. Writing your python code
a. Create a directory under Documents [ C:\Users\devi\Documents\Python-Practice ]
b. Right Click on the directory and click on Text Document
c. Rename the file as
d. Open the file and type
    print("Hello, World !!!")
e. Save the file.
f. Press Windows Button and R at the same time, a pop up windows shows up
g. Type cmd and click OK.
h. You will see dos windows. Go to your code location
   cd C:\Users\Devi Neopane\Documents\Python-Practice
h. Now at the prompt, type, python

You should see the output.

If you don't get the correct output, you have to review your PATH.

Friday, January 11, 2019

Python - Learn by example - Variable assignment

# Defining variables
# Block of code is called shout
def myvar1():
    a=10; b=30; c=a+b; d=a+b+c; print(d)
    print("The Sun of", a, b, "and", c, "is:", d)


Python - Learn by example - Variables and Function

# define variables

print ("x = ", x)
print ("y =", y)


a='Hello '
b='World !!!'

c=a + b
print("To put together a + b, we get:- ", c)

# Assigning numerical values

print("The value stored on memory location is", id(a))
print("The Sum of", x, "and", y, "is", z)
print("The sub of x and y is", z1)
print ("The multiplicaiton of", x, "and", y, "is", z2)
print ("The division of x and y is", z3)

# Using function

def mymath1():
    # define variables
    print("The Sum of", x, "and", y, "is", z)
    print("The sub of x and y is", z1)
    print ("The multiplicaiton of", x, "and", y, "is", z2)
    print ("The division of x and y is", z3)

# calling the function

# Input from user, accepts a input value from user
a=input('Please enter a value: ')

print("User input is",a )

# Use function to accept value from user input
def domath():
    a=input('Please enter a number you like: ')
    b=input('Please enter a second value: ')
    print("Output is as a string ")
    print("The sum of", a, "and", a, "is: ", c)

# Here you will get out put like below
# Please enter a number you like: 5
# Please enter a second value: 2
# The sum of 5 and 5 is:  52
# The reason is it treats these value as string so
# the program put both value together.
# if you want to perform mathematical operation, do the following,
def domymath():
    a=int(input("Please enter a number: "))
    b=int(input("Please enter another number "))

    print("Output as numerical value")
    print("The sum of", a, "and", b, "is: ", c)


# ========================================
# Playing with string

a=input('Please enter a string you like: ')
print ("You entered: ", a)
# Use function to accept value from user input as string
def dostring():
    a=input('Please enter a string you like: ')
    b=input('Please enter a second value: ')
    print("Output is as a string")
    print("The sum of", a, "and", a, "is: ", c)

# Here we will use decimal value for mathematical operation.
def domyfloat():
    # enable 2 lines below and test it. it will throw error if you pass
    # letter because letters are treated as string...
    # a=int(input("Please enter a string: "))
    # b=int(input("Please enter another non-number: "))
    # so you have to change integer to fload to change number to string.
    a=float(input("Please enter a folating value here: "))
    b=float(input("Please enter another floating value link 3.2: "))

    print("Output as floating point value")
    print("The sum of", a, "and", b, "is: ", c)


Phthon - Learn by Example - Hello World

# My python program
# # sign is comment

print ('Hello, World !!!')
print ("I am learning Python")


print ('I like it')
# The line below is comment
''' Multi line comment'''
''' How is everything
I am sort of liking it
and this
is really
cool '''
print ('Learning Python is cool')

Monday, January 7, 2019

RHEL - Extending /boot Partition from 200M to 500M on CentOS / RHEL

Extending /boot Partition from 200M to 500M on CentOS / RHEL

Some dev env, you will have multiple kernel instances and takes up lots of space.
Here is the step to extend /boot partition on your system.

We will be using LVM to create /boot partition.
Or you can use a physical partition as well if possible.

1. Check the available space on your Volume Group
# vgs; lvs

2. Create a logical volume
# lvcreate -n boot -L 500M root-boot
# lvcreate -n boot -L 500M /dev/root-boot/boot

3. Create filesystem and add entry to fstab and mount it.
# lvscan
# mkfs.xfs /dev/root-boot/boot
# vi /etc/fstab
/dev/root-boot/boot /boot1 xfs defaults 0 0

# mount -a

4. copy all files from /boot to /boot1
# cp -rp /boot/* /boot1

5. Comment out old entry for /boot and change mount point for new device to /boot.
# /dev/sda1 /boot xfs default 0 0
/dev/root-boot/boot /boot xfs defaults 0 0

6. Reboot your machine and verify your system is up and running..
# reboot