Tuesday, September 21, 2021

Download web presentation (multiple files) using wget

In my case, the page started with 1, 2, 3, ..... to 350.  I can download a page one at a time. A lazy person like me, could not do that. So, I just use a for loop to download these files. Presentation was not available to download and all pages were images. 

Login to your Unix system and use for loop at your prompt.

[sam@master RI]$ for((i=1;i<=350;i++)); do wget https://meropreseation.com/ebooks/travel-E-Book/content/pages/page$i.jpg; done



Downloading files to windows system from Unix system.

PS C:\Users\Sam\RI> scp sam@192.168.100.100:/home/sam/RI/* .



Friday, September 10, 2021

RHCSA - Linux partition

 

Disk Management With Parted Command In Linux:
=============================================

MBR partition scheme and GPT partition scheme both use different method to store partition information in disk. We cannot use both scheme in a single disk.
Since in this tutorial we will create both types of partitions, we need two separate disks. We have already added two virtual disks in our system.

# lsblk

OR

# fdisk –l

Creating MBR Partition with parted command:

The parted command needs the name of disk where we want to create the partition as its argument.

# parted

Always use parted command with argument. Without argument it will start with first available disk.

# parted /dev/sdb

print

The print command provides important information about the hard disk. This information includes manufacturer information, disk model, disk size, Partition Table and disk flag. If this is a new disk, we will get unrecognised disk label error. Disk label is the information which is used to determine the type of disk. The parted command needs a valid disk label before it can do anything with disk.
To see it practically run mkpart command. The mkpart command is used to create new partition.

mkpart

As above output confirmations that we are not allowed to create new partition unless it has a valid disk label. The msdos and gpt are two valid disk labels which we can use here. The msdos label is used to define the disk as MBR disk and the gpt label is used to define the disk as GPT disk.

To assign the label mklabel command is used. Let’s assign the msdos label to this disk.

Type mklabel and press Enter key.
Type msdos and press Enter key.
Verify the action with print command.

# parted /dev/sdb

mklabel

msdos

print

Do not use this command if disk contains data. This command is very risky. This command will convert disk in un-partitioned blank disk silently. 

Now disk has label. We can create partition in it. To create partition following steps are used.

Type mkpart and press Enter key.

As we know in MBR partition scheme we are allowed to create maximum four primary partitions. If more partitions are required, we have to use one primary partition as extended partition. Further Extended partition can be used to create 15 logical partitions.

Type the partition type and press Enter key.

Type the starting point for partition and press Enter key.

The parted utility supports very limited file system types. To add worse, most of them are out dated nowadays. We will make file system individually later. By now just keep the default file system type.

Type the ending point for partition. We can use KB, MB or GB units to define the size of partition.

We can verify the creation of partition with print command

Following figure illustrates above steps

mkpart

primary

ext2

1M

600M

print

Always start first partition with 1MB even only first 512 bytes are used to store the MBR data. This way we can avoid several entry point errors.

Following same process create two more partitions

mkpart

primary

ext2

601

800

mkpart

primary

801

1000

print

We have created three primary partitions from maximum (four) allowed. Now we can create one more primary partition or can create one extended partition.

Let’s create one allowed extended partition. Since extended partition is used to create all allowed logical partitions, we should allocate the maximum disk space in this partition. We will assign all remaining disk space in this partition.

mkpart

extended

1001

2100

print

All logical partitions will be created in extended partition. The sum (of size) of all logical partitions cannot go beyond the extended partition. In this example we created an extended partition of 1145MB, so we can create logical partitions from 1145MB. We are allowed to create up to 15 logical partitions in extended partition.
We can create any number of partitions from range of one to fifteen. The only limit is that the sum of all partitions must be below the size of extended partition.

Let’s create a single logical partition of all available space.

mkpart

logical

ext2

1002

2045

print

We have used all space of extended partition in one logical partition. So even we are allowed to create up to 15 logical partitions and free space is available outside the extended partition, we cannot create the another logical partition. To create another logical partition we need free space inside the extended partition not outside the partition.

So far we have created all possible partitions including primary, extended and logical partitions.

To exit from parted use quit command.

quit

The parted cannot update the in-memory kernel partition table. Kernel reads partition table when system boots. So the kernel will be updated about this change at next reboot automatically. Meanwhile if we want to update the kernel immediately, we can use partprobe command which force kernel to reread the partition table.

# partprobe /dev/sdb

# lsblk

# fdisk -l /dev/sdb

Creating GPT partition with parted command:
GPT is the new partition scheme. It allows us to create up to 128 partitions. It does not divide partitions in primary, extended and logical. First part of this article explains basic concepts of GPT in detail with examples.

We will create GPT partition in /dev/sdb disk. Let’s initiate parted again for /dev/sdb disk

# parted /dev/sdc

print

mkpart

mklabel

gpt

Now disk has a valid label. We can create partition in it. Creating partition is a six steps process.

Type mkpart and press Enter key
Set desired descriptive name for partition
Accept default file system type
Enter starting point of partition
Enter ending point of partition
Verify the partition with print command

mkpart

linux

ext2

1M

600M

print

mkpart

documents

601

1000

print

quit

# partprobe /dev/sdc

lsblk

So far we have created MBR and GPT partitions in /dev/sdb and /dev/sdc respectively.

These partitions are useless unless we put a file system in them. File system is a logical container which allows us to store files and directories.

How to create file system
To create a file system in partition we format it with supported file system. To format a partition following command is used.

# mkfs.ext3 /dev/sdb1

# mkfs.ext4 /dev/sdb2

# mkdir /srv/test1 ; mkdir /srv/test2

# mount /dev/sdb1 /srv/test1

# mount /dev/sdc1 /srv/test2

# df -hT

Make entries in /etc/fstab for permanent mounting.

# cd /srv/test1

# touch {1..10}

# ls -l

For LVM:

# pvcreate /dev/sdc1

# pvs

# vgcreate LinuxVG /dev/sdc1

# vgs

# lvcreate -L 500M -n LinuxLV LinuxVG

# lvs

# mkfs.xfs /dev/LinuxLV/LinuxVG

# mkdir /srv/lvm

# mount /dev/LinuxLV/LinuxVG /srv/lvm

# df -hT

# cd /srv/lvm

# touch {a..m}

# ls -l

How to delete MBR partitions
To delete a partition rm sub-command is used. Before we delete a partition it must be un-mounted. We cannot delete a mounted partition. Let’s see it practically.

# umount /srv/test*

# df -hT

# parted /dev/sdb

print

rm 1

rm 2

rm 3

rm 5

print

rm 4

print

quit

# partprobe

Delete GPT partitions
Deleting a GPT partition is as same as deleting a MBR partition. Initiate parted command with GPT disk (/dev/sdb) and use print command to view the number of partition and use rm sub command to delete that partition.









Wednesday, September 1, 2021

Day2 - Docker - container, volume, start container

Day 2 - Introduction to Docker
Day2 - Docker - container, volume, start container
Can I start/stop the container? How about image?
- You can start/stop container and remove container but you can not stop/start image. You can pull image and remove the image.
How to run a container?
$ docker run -dt centos bash # Runs on deatach mode
here, you got a template called centos and created one container.
The container has started.
Check the running containers
$ docker ps
Now, how do you login to container?
$ docker ps
$ docker exec -it <container name/ID> bash
here bash is the working shell
$ docker exec -it centos bash
Now, create a new session of host machine and stop the container
$ docker container stop <container_ID> ## run docker ps to find the container id
Create a new container
$ docker run --rm -it contos bash
Note:
docker ps - shows you container list that are running
docker ps -a -> shows you list of all container, in fact history

How to remove a container
$ docker ps # get the contiainer id
$ docket container rm element_1
$ docker ps -a $ list all available container including stop ones
$ docket run --rm -it --name <name of container>
$ docker run --rm -it --name first_cont ubuntu bash
Now, you are at the container prompt. run hostname, you will see some id.
if you type exit or quit at the prompt, you will be out of container and container will stop as well.
on the host machine, type 
$ docker ps # you will see the containers running
$ docker ps -a # list all containers including stopped one.

Lets login to continer
$ docket run --rm -it --name first_cont --hostname ubuntu ubuntu bash
and type hostname' cat /etc/os-release at the prompt.
Note: Downloaded images are read only images. 
container runs on a concept called copy on write (COW)
copy on write mean, you are adding content on the container.
at the container prompt, type 
# apt-get update   -> it will go and update the container
so, you can write to your container but you can't update the image. (readonly)
At the prompt, run
$ apt-get install apache2 # we are installing apache
Note: if you are using interactive mode and you exit out of the container prompt, container will be removed.
$ docker images ls # list container images
$ docker image rm ubuntu
$ docker pull ubuntu
go to the URL hub.docker.com
at the search box, type ubuntu and click on ubuntu official
- click on docker file.
- read everything on the file and try to understand it.
- This file is the foundation of the image.
also search for nginx and read the dockerfile for the image.
so, images are build based on dockerfile.
[ Remember: Copy on write filessytem]
so what happens when you run docker pull command?
- pull command first goes to the hub.docker.com and checks the dockerfile and grabs all the things stated on the file. Once pull is complated, you will have particular image. These images are stored in local repository. The default location is /var/lib/docker
Things to remember,
- Images are read only but container that are based on images can be modified.
- Docker containers are volatile
  - if you store data in a container, and you remove the container, all the data is lost. so containers are usually immutable (ephenreal - temporary or disposible)
Once you remove the container, data on the containers are gone.
$ docker run -it --name first-cont --hostname ubuntu ubuntu bash
# echo "Hello" > hello.txt
# cat hello.txt
# exit
$ docker ps # container is gone/ stopped
$ docker ps -a
Start the stopped container
$ docker ps -a 
$ docker ps
$ docker container start first_cont  # first_cont is started
Now, you have to login
$ docker exec -it first_cont bash
# cat hello.txt # you may still be able to see it.
# exit
$ docker ps
$ docker ps -a
$ docker container rm -f first_cont
$ docker ps ; docker ps -a # now, its gone. all data on the container is gone.
so, containers are temporary, and data is also temporary. So, you can say containers are volatile.
To resolve this issue what we can do is,
1. create a persistence volume
2. Bind mounts
What is the benefit of working with volumes,
1. To keep the data around when container is removed
2. To share data between host and container
why should we use container?
- It is a light weight OS (about 200mb) compare to virtual machine(appr 4GB).
- Only one app is install and it only contains some library and binaries.
- volume helps you to keep data even you remove the container
what happens if you wan to upgrade?
you can still upgrade without any issue.
So, what is the benefit of using volume?
we can say that
1. A data volume is a specially designed directory in the container
2. It is initialized when the container is created. By default, it is not deleted when the container is removed
3. Data volume can be shared across the containers too.
4. Volumes are stored on host machines.
5. You can name particular volume with meaningful name
How to create a volume
$ docker volume ls # lists the volumes
$ docker container run -it ---name secon_con -v /data ubuntu bash
-v -> name of the volume
/ -> mount at root of container
-it -> interactive.
Open new session of the host machine
$ docker volume ls
$ docker inspect <container_ID> second
inspect - what to inspect
the above command gives detail about container such as ip, gateway, id, when it is started, 
image name, volume name, volume id and other info
review the source and the path that start with
/var/lib/docker/volumes/<id>/_data
$ docker volume ls # verify the id, you will find these two same.
$ ls /var/lib/docker/volumes/...../_data
permission denied
$ sudo ls /var/lib/docker/volumes/.../_data
Login to docker and create a file
# cd /data; echo "Hello" >hello.txt
# exit
$ docker ps
$ docker container rm second
$ docker ps -a # everything is done about second container
$ docker volume ls # you will still see the volume
Where the volume is pointing to?
$ docker volume inspect <volume_ID>
$ sudo ls -l /var/lib/docker/volume/<id>/_data
you will still see the data.
if you want to use this volume, you have to specify that this is the volume you want to use when you start a container.

so the question is:
How to start a container with the same volume?








Tuesday, August 31, 2021

Day1 - Docker - Introduction to docker

 Docker is very light weight mini os which does not include kernel. It is good for developers and sysadmins to build, ship and run the distributed application. 
Containerization::
- It is not a new concept. There were jail, zomes, containers, LDOMs,, LXC - linux containers
but all of these virtualization technologies could not do optimim job. 
Docker took over. Its a client/server model. First release in 2013.
Advantage of docker::
- Reduce the size of dev env with the help of small os foot print
  Centos/ubuntu
VM os size     4 GB
Container size  200MB(appx)
- Docker does not need kernel, it gets all support from host os.
- You can develop on one platform and deploy on any platform
- Container/dockers are very light weight
Docker os is called docker images
- very lighweight os and easy to deploy

Lets contair the VMs
Guest VM | Guest VM        c1|c2|c3|c4  -> Containers - container contains some binary/library
Virtualization layer Host OS + Docker Service
Host OS HW
Hardware

You can develop your app -> create your image -> upload to repo -> install (pull) and start using it
- Install on windows/linux/Mac. It just works on any env.
- You generate project image (tomcat, ubuntu, centos)
 For docker imatallation, you can follow the link below
https://get.docker.com/
To install on windows, docker for windows
You can use cloud env link gcp/aws
just follow the installation steps
$ sudo usermod -aG docker jay
$ sudo systemctl start docker
$ sudo systemctl enable docker
$ docker version

Docker works on concepts of image.
Docker registry -> Where docker images are stored/present
hub.docker.com -> docker HUB
You can have public/private registry (repo)
- company info may go private.
search -> centos and look for official
search for apache, java, ubuntu, nginx
these are pre-configured images.
To download the image
$ docker pull centos
check available images
$ docker info -> shows everything . Check the output line by line.
image - pre-configure class (group of objects)
container - is like os and it has application.
How to run container
1. Interactive (it) mode 
2. Detach (dt) mode
Running container in interactive mode
$ docker ps
$ docker run -it centos bash
it -> interactive
centos - name of image
bash - shell it will load
when you run the command, you will be on centos bash prompt.
# cat /etc/os-release
Now, lets try something interesting
$ linux1
$ docker images  -> lists images
look at the output carefully
- check the size, its so light
every image has container ID.
$ exit
you docker stops. 
$ docker ps -> you will see no container running
This is an interactive mode where container dies when you exit out.

Lets run an docker instance
$ docker run -it centos bash
open a new instance of host os and run
$ docker ps -> you will see continer still running
run the top command on both host and container.
you will see lots of processes on host but very few on container.
now, exit out from container, and run
$ docker ps ->  no container is running
$ docker ps -a -> you will see the history
2. Running docker in detach mode
$ docker run -dt centos bash
-dt -> detach mode
you will still on host command prompt, docker is running on the background
$ docker ps -> you will see the instance running
How to loign to docker
$ docker exec -it bash
look at the error message
$ docker exec -it <container id> bash
you will get container id from docker ps command output
you exit out of docker. it is still running. 
if you want to stop, you have to stop manually
$ docker ps
$ docker --help -> search for how to stop
$ docker container stop <container ID>
The beauty of docker is that you can ship your application fast and 
docker starts in seconds.
docker is infact a process. 
HW: download image/install some container such as apache/tomcat/nginx/java/jinkins or more ..

Saturday, August 21, 2021

Day3 - Object Oriented Programming in Python

 Day3 - Object Oriented Programming in Python 
8/21/2021

What is behavior?
-> Behavior represent functionality (functionality is a logic)
We can define following behavior in python
1. Constructor
2. Method

What is method?
- a behavior which represent some functionality will execute whenever programmer will call is called method
for eg, c1.m1 or c1.m2
here, m1 and m2 methods are calling

Types of method 
There are two types of methods
1. Instance method
2. Static method

Instance method
- A method which is taking 'self' keyword as first parameter is called instance method
- Instance method address will be available within the object. Due to this reason, instance method we have to access by using the object.
Some questions you can create from above statement
- What is method?
- What keyword do you use as a first parameter?
- How do you access instance method address?

<Syntax to define instance method>
- To define a method or construct in python, we should prefix 'def' keyword.
def <methodname(Self)>
  <logic>
Example to define instance method
def MyFun(Self):
   print("MyFun is calling")
<SYNTAX to invoke instance method>
<objectname>.<instance methodname()>
eg, 
obj.MyFun()
here, obj is object name and
MyFun method name
What is an object?
- An object is an instance of a class
car is a class
  - your car is an object of class car
  - my car is an object of class car
pem is a class
   - your pen is an object
   - my pen is an object
Human is class
   - Ram is an object
   - Sam is an object of human class
instance is a physical representation
so, class is a logical representation
object is a physical representation of class

What an object contains?
-> An object contains instance variables and address addresses of the instance method.
<SYNTAX to create object>
<ObjectName>=<ClassName()>
for eg,
obj=MyClass()
eg,
class MyClass():
   def MyFun(self):
      print("MyFun is calling ..")
obj=MyClass()
obj.MyFun()


Thursday, August 19, 2021

Day2 - Object oriented programming in Python

 Day2 - Object oriented programming in Python
OOP principles
1. Encapsulation
2. Abstraction
3. Polymorphysm
3. Inheritance
Reading concept
1. Read the book and write notes
2. Record what you learn on your phone
3. Prepare all the questions from the book you read
4. Write the answer to the question
5. Select the best question and take a test without a book.
What is class?
- Class is a collection of states and behaviors
to define a class, we have to use class keyword. 
<syntax>
class <classname>
  <states>
  <behaviours>
First understand the state. What is state?
-> State represents some value. State can be variable or constant.
Types of variables in python
There are 3 types of variables in python
1. Local variable
2. Instance variable
3. State variable
What is a local variable?
-> a variable which is declared inside the method (or function) is called local variable
-> local variable can access only within the method or function.
-> Local variable will be getting memory at the time of method execution.
-> Local variable will be destroyed once method execution is completed.

Create some question based on above definition.
1. What is local variable?
2. What is the scope of local variable?
3. How memory is allocated for local variable?
4. How memory is de-allocated?
Reading tips
Think how many questions can you create on the topic above?
2. Instance variable
-> A variable which is declared inside the constructor or inside the instance method by using self keywork is instance variable.
- Instalce variable gets the memory within the object 
- 'self' is a keyword which represent current class object
- Intance variable will be getting memory at the time of object is creating.
- Instance variable will destroyed once the object is destroyed.
Questions?
1. What is instance variable?
2. How instance variable gets the memory?
3. What keyword is used in instance variable?
4. When instance variable is de-allocated or destroyed?
What is static variable?
static/dynamic coding ..
i and j 
i=j; i<j; i>j ; multiple if, else if, nested if
decision/control statement
A variable which is declared inside the class or inside the static method by prefixing classname is static variable.
Q. When the static variable will be getting memory?
- at the time of class is loading
Q. When the static variable will be destroyed or de-allocated memory?
- At the time of class is unloading
Example to declare instance variable
self.a=10
MyClass.b = 20
Here,
name of the class is: MyClass
b is: name of variable
20 is: the value assigned to a variable
as we know, class is collection of state and behaviour. We just discussed about state, now we will discuss about behaviour.
What is behaviour?
- Next class
Reading, writing and implementing tacktics
1. Read the book first topicwise and write the notes on each topic
2. After completing reading and taking notes, close your book and write on a paper without looking at the book.
3. Now, record what you learn on your mobile phone topic wise without looking at the book.
4. Prepare questions and answer of the topic by looking at the book.
5. Now, prepare fews questons by summarizing your old questions
6. Write your answer and record the question and answer.



Wednesday, August 18, 2021

Day1 - Object oriented programming in Python

 8/18/2021
Day1 - Object oriented programming in Python
When you are learning something, learn like a child.
When you are working, work like a professional.
Programming language approach
1. Procedural
2. Object oriented
Procedural oriented programming approach
- In procedural oriented programming approach, program (solution) is a collection of function, or method or, procedure. (Block which represent some logic)
Structure of procedural oriented programming
m1() # Method definition
  {
    logic # some logic
  }
m2() # define m2 method
  {
    logic     # some logic
  }
main() # Main method
 {
   m1
   m2
  }
In this program we have three methods: m1, m2 and main methods. 
We have 50 sits and one driver sit. 
driver is a main method. main method controls the program the way driver controls the bus.
In above program
- First program execution starts from main method
- Second, it reads the m1 method and control goes to look for m1 method and when it finds, it executes it
- 3rd, it reads m2 and control goes to look for m2 method and reads the logic and executes the block of code.
A programming language which follows the above programming approach is a procedural oriented programming language.
Due to some limitation of this approach, industry experts are intruducing a new programming approach which is called object oriented programming approach.
Object Oriented programming approach (OOP)
-> In OOP approach, the program is a collection of classes. A programming language that follows above programming approach is an object oriented programming language.
Structure of OOP approach
class c1 # definition of class
{
  m1() # definition of mdule
     {
        logic
     }
   m2() # definition
     {
         logic
     }
}
class c2
{
  main() # definition of main method. programming execution control by main method
  {
    c1.m1 # calling
    c1.m2
  }
}

Program execution starts from main method. After that control checks c1.m1 and start look for c1 and m1 and executes when it finds it
after that control goes to c1.m2. It start looking for c1 cladd and go to m2. once it reads, it executes. 
when control reaches the closing braces, program terminates. This kind of programming approach is called OOP. languages
Some of them are c++, JAVA, C#.net
What about python?
- python is procedural as well as oop.
function, method -> procedural
class - oop
m1() # function, method
{
}
m2()
{
}
class c1 # class
{
 m3()
  {
  }
}

OOPS methods
Every OOP language follows 4 principles
1. Encapsulation
2. Abstraction
3. Polymorphism
4. Inheratence
To achieve all 4 princliples, every object oriented programming language has to follow the 2 object orientted concepts below.
1. class
2. object
What is object?

Friday, August 13, 2021

links

 https://rhtapps.redhat.com/promo/course/do007?segment=3
https://www.youtube.com/watch?v=dadKFIEJQbc&list=PL55uMtDpag8psxkSr3PrK6Jx0G7EfCRYw&index=7
https://www.udemy.com/course/git-github-crash-course/learn/lecture/25672800#overview
https://www.youtube.com/watch?v=sNDs6AoNmA8
https://www.udemy.com/course/automate/learn/lecture/3465796#overview
https://www.udemy.com/course/mastering-git-for-beginners-and-experts/learn/lecture/26290392#overview
https://drive.google.com/file/d/1mi4WjUWQ1AqB1LM_RThwQ0-FEz5u9xhr/view



Thursday, August 12, 2021

Ansible for begginers

 Ansible for begginers
- Ansible introduction and setup
- Playbooks, modules
- Inventory and Variables
- Roles, loops & benefits
- Troubleshooting

Module1: Introduction to Ansible
1. What will you learn in this course?
2. Introduction to ansible automation.
3. Why ansible?
4. Ansible features
5. Why should we automate?
Lab: Instal and set up ansible

Module2: Ansible inventory and ad-hoc commands
1. Ansible inventory
2. Host patterns
3. Ansible Ad-Hoc commands
LAB: Create inventory file and running ad-hoc commands

Module3: Ansible playbook, modules and priviledge escalation
1. Ansible play, playbook
2. Ansible modules
3. Ansible roles



manchhe ko kuro

 दर्द को भी अब दर्द होने लगा है,
दर्द ही आपके घाव धोने लगा है,
दर्द के साथ कभी रोए आप
अब दर्द आपको छू कर रोने लगा है।


नारी नहीं बेचारी इसके सब्र का बांध ना तोड़ो !
दुर्गा बन प्रतिशोध ये लेगी अबला ka भ्र्म छोडो !
     नारी शक्ति की सुपरहिट कविता

मैंने डर को डरते देखा है,
मैने मौत को मरते देखा है,
दिल में उम्मीद जिंदा रख ये मेरे दोस्त,
मैने अन्धों को पढ़ते देखा है।


ख्वाब टूटे हैं मगर हौंसले ज़िंदा हैं।
हम वो हैं जहां मुश्किलें शर्मिंदा हैं।।

21वीं सदी के स्वावलंबी ,स्वाभिमानी भारतीय नारी को सलाम🙏🙏
सक्षम बनो और आगे बढ़ो,जय हिंद

Tuesday, August 3, 2021

X11 Forwarding through SSH using PuTTy

 


1. Open putty
2. Click on connection under Category on the left pane
3. Expand SSH and click on X11
4. Click on check box next to Enable X11 forwarding
5. Go to the session and enter the hostname and also type host name under saved Session
6. Click Save and click on open
7. Enter your username and Passwd
8. Run echo "DISPLAY" and see if your display is exported.
Note: If not, run your X Server (MobaX term comes with X server)
9. Type xhost or any GUI program to load your application on GUI.

Thursday, July 29, 2021

Some good urls

 LX accord will be around 28k OTD give or take and the CR-V LX will be around 30-31K OTD

Caleb Mondoloka
CR-V EX will be around 32-33K OTD, and the Accord doesn't have an EX
only a Sport special edition and Ex-L


https://www.youtube.com/watch?v=SLB_c_ayRMo

https://www.golinuxcloud.com/tmux-cheatsheet/
http://willthames.github.io/2016/09/21/using-command-and-shell-in-ansible.html
https://www.golinuxcloud.com/ansible-tutorial/
https://www.golinuxcloud.com/kubernetes-tutorial/
https://github.com/kodekloudhub/certified-kubernetes-administrator-course
https://github.com/mmumshad/kubernetes-the-hard-way

https://www.reddit.com/r/devops/comments/mvad97/gitlab_offers_gitlab_certified_associate/

https://www.shell-tips.com/bash/debug-script/

https://www.udemy.com/course/automate/learn/lecture/3465796#overview
https://www.youtube.com/watch?v=v_S64kldryc


https://k21academy.com/docker-kubernetes/certified-kubernetes-administrator-cka-certification-training-step-by-step-activity-guides-hands-on-lab-exercise/


STAR interview technique
https://www.amazon.jobs/en/principles

https://www.mersenne.org/download/

https://learn.flackbox.com/courses/81445/lectures/1177240

ansible
https://rhtapps.redhat.com/promo/course/do007?segment=3
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html#yaml-syntax

git
https://www.udemy.com/course/git-github-crash-course/learn/lecture/25672796#overview
https://www.youtube.com/watch?v=FyAAIHHClqI
https://www.udemy.com/course/mastering-git-for-beginners-and-experts/learn/lecture/26290392#overview

https://www.youtube.com/watch?v=v_S64kldryc&t=219s
https://www.halvorsen.blog/documents/programming/python/python.php
https://youtu.be/dadKFIEJQbc
https://www.youtube.com/watch?v=v_S64kldryc

https://www.youtube.com/channel/UCs4dFR-31isXFkNuYSBHgLg

https://linuxhint.com/read_file_line_by_line_bash/
https://www.youtube.com/watch?v=kE-6KDyf-0o

https://www.udemy.com/course/creating-your-first-udemy-course-unofficial/learn/lecture/18810984#overview

https://www.youtube.com/watch?v=sNDs6AoNmA8


sqlite

>  sqlite2 --version

$ yum info sqlite

git - tag

 Tags (label) - Like a tag on your t-shirt @ the store, its  a reference name applied to particular  commit ID.

Git has option to tag a commit in the repository history so that you can find it easily at the later point in time.

To apply tag to a commit
$ git tag -a <pattern->name of the tag> -m "Commit message" <commitid>

If you apply tag on your local repo, it will only be available to local repo.
is it for yourself or for everyone. If its for everyone, you have to apply from remote repo.

Contents of the tag
$ git show <pattern>

Display list of tags available
$ git tag

Push the tags
$ git push --tags
You need to have permission to push tags.

Delete a tag
$ git tag -d <tag>


Naming conversion
QA_data_epic
Release Version:
R1.2
R1.3
R1.4


Lets do by example

1. Lets first clone the repo
$ git https://github.com/abc/myrepo.git workspace00

2. List all tags available
$ cd workstation; git tag

3. Apply tag
- first find a commit ID and apply
$ git log --oneline -2

$ git tag -a "R1.2" -m "Put comment for release 1.2" <commit_ID>
$ git tag -a "R1.2" -m "Put comment for release 1.2" abc123

Now view the tag
$ git log --oneline -2

now,  you can refer this tag to refer to this commit ID.

$ git show R1.2
shows commit ID and message...

Can you have multiple Tags?
Yes, but need to be different type of tag.

Can you apply one tag on one commit and same on different commit id?
- No

Lets apply a tag
$ git tag -a "R1.3 -m "Comment for release 1.3" abc123

You see one commit id has multiple tags on it. But can not use same tag to apply to different commit ID.

$ git tag -a "R1.3" -m "Put comment for release 1.3" abc123
Fatal: Failed to resolve "abc123" as a valid ref.

We can apply a tag only to one commit at a time.
However one commit id can have multiple tag on it.

if you have permission to push the tag, you can do it.

$ git push --tags

Note: In your org, @private repo, you may not have permission to push it.

$ git tag
$ git tag -d R1.3

$ git log --oneline -2

Repo -> Branch -> Commit_ID


Merge VS Rebase

What is rebase?

- Merge is a process of taking content from one branch and put it into another branch. Merge creates a new commit_ID at the destination branch.

- Rebase is in fact a different type of merge. What it does is, it does not add new commit_ID, but it realign the branch.


Lets say you have branch and some commit ID.
You create a new branch (say test) from one commit ID at master.
and you have some new commit IDs on test branch.

Now, go back to your source branch, and if you do a commit; if you modify something on test branch, and if you try to merge something from test branch to its source branch 'master',  what happens is -
it will take the changes at the source branch 'master' and from the barnch where you trying to mesge.  Both of them put together and it creates new reference which is called 'new commit id' through merge.

Rebase
- On a latest commit ID, it will feel like this branch is created on new commit ID.





Wednesday, July 28, 2021

RHCSA exam prep notes

 1. How to reset root password on RHEL8 server?
-> Reboot your system
-> On your boot (timer) menu, press arrow key
-> Press e to edit
-> Go to the link starts with linux
-> Go to end of the line by pressing end on your keyboard
-> type - rd.break enforcing=0
-> press ctrl+x to save and exit
-> You will be at the prompt menu # Emergency mode
-> Mount sysroot # mount -o remount,rw /sysroot/
# chroot /sysroot
# passwd root

autorelabel
-> Exit exit at the prompt
-> Login to your system and run
# restorecon /etc/shadow

2. Assign static IP address
either use nmcli command line tool or
use manually
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth0 (interface name)
 BOOTPROTO="static"
 ONBOOT="yes"
 IPADDR=192.168.100.100
 NETMASK=/24
 GATEWAY=192.168.100.1
 DNS1=192.68.100.1 - DNS server ip

# systemctl restart network
# systemctl restart NetworkManager

# cat /etc/resolv.conf

# netstat -rn

# ping gateway
# ping google.com # if access to outside @internet will allowed.

# ssh hostname (IP)

3. Disable firewall, enable SElinux
# systemctl stop firewalld
# systemctl disable firewalld

# getenforce
# setenforce 0
# vi /etc/selinux/config
SELINUX=enforcing

4. Set up repo
# vi exam.repo
[examrepo1]
baseurl=http://path
gpgcheck=0

[examrepo2]
baseurl=http:url
gpgcheck=0

# yum clean all
#  yum repolist
# yum search httpd
# yum install httpd

5. Assign hostname to your system
# hostnamectl -h
# hostnamectl set-hostname myhost.eg.com



Tuesday, July 27, 2021

Python - day 16 if elif else continue

 
Session 16
task1: Implement vowel program using if else?

Condition1 condition2 condition3 (Pair conditions)

Note: When we are implementing pair conditions, we should use logical operators to concatinate (join or between).

like
and
or
about
and

True and True -> True
True and Flase -> False
False and True -> False
False or False -> False

When do we use operator?
-> When following statement should execute any one condition is true.


task2
Implement vowel program using if else and which should handle case sensitive?

-> Implement above vower program by using if else and which should handle case sensitive by using pre-defined method?

Design with o/p

task3
write a python program to accept student 3 subject marks and display the result?

Step1: Design with O/P
----------------------
Solution:-

Task4
Implement above program using 6 subjects

task5: Accept person age display person status



rpm: Find out what files are in my rpm package

 rpm: Find out what files are in my rpm package

Use following syntax to list the files for already INSTALLED package:
rpm -ql package-name

Use following syntax to list the files for RPM package:
rpm -qlp package.rpm

Type the following command to list the files for gnupg*.rpm package file:
$ rpm -qlp rpm -qlp gnupg-1.4.5-1.i386.rpm


In this example, list files in a installed package called ksh:
$ rpm -ql ksh


See the files installed by a yum package named bash:
repoquery --list bash
repoquery -l '*bash*'

Syntax
repoquery -l {package-name-here}
repoquery -q -l {package-name-here}
repoquery -q -l --plugins {package-name-here}
repoquery -q -l --plugins *{package-name-here}*
repoquery -q -l --plugins http
repoquery -q -l --plugins ksh

here,
    -l : List files in package
    -q : For rpmquery compatibility (not needed)
    --plugins : Enable plug-ins support

List the contents of a package using yum command

1. Open the terminal bash shell and type:
$ sudo yum install yum-utils

2. See the files installed by a yum package named bash:
$ repoquery --list bash
$ repoquery -l '*bash*'



https://www.cyberciti.biz/faq/howto-list-find-files-in-rpm-package/


Creating a CA-Signed Certificate for the Tomcat Server

 Creating a CA-Signed Certificate for the Tomcat Server

Procedure

1. From the command prompt, go to the folder that contains the keytool.exe file:
 - For Windows systems, go to C:\Program Files\Commvault\ContentStore\jre\bin.
 - For Linux systems, go to /usr/lib/jvm/jdkx/bin.


2. To create the keystore file containing the key-pair/certificate to be signed, run the following command:

For Windows:
> keytool -genkey -alias tomcat -keyalg RSA -keystore "C:\mykeystore.jks" -ext SAN=dns:<domainname>
> keytool -genkey -alias tomcat -keyalg RSA -keystore "C:\mykeystore.jks" -ext "SAN=dns:myserv.eg.com,dns:cnameserv.eg.com,EMAIL:admin@eg.com"

For Linux:
# keytool -genkey -alias tomcat -keyalg RSA -keystore "/mykeystore.jks" -ext SAN=dns:<domainname>


3. Generate a CSR, run the following command:

keytool -certreq -keyalg RSA -alias tomcat -file C:\tomcat.csr -keystore C:\mykeystore.jks -validity <daysValid> -ext SAN=dns:<domainname>

keytool -certreq -keyalg RSA -alias tomcat -file C:\tomcat.csr -keystore C:\mykeystore.jks -validity 365 -ext SAN=dns:myserv.eg.com,dns:cnameserv.eg.com

4. Upload the CSR to the CA website, indicate the type of Tomcat server, and submit for signing.
5. Download the root, intermediate, and issued server/domain certificates.

6. Import each signed certificate that is issued by the CA using the following commands:

    a. Root certificate:
    keytool -import -alias root -keystore C:\mykeystore.jks -trustcacerts -file C:\valicert_class2_root.crt

    b. Intermediate certificate:
    keytool -import -alias intermed -keystore C:\mykeystore.jks -trustcacerts -file C:\gd_intermediate.crt

    c. Issued server/domain certificate:
    keytool -import -alias tomcat -keystore C:\mykeystore.jks -trustcacerts -file C:\server_certificate_whatevername.crt


Note: The keystore parameter must be the path to the keystore file that was used to generate the CSR. You must use the same keystore file throughout this procedure.


https://documentation.commvault.com/commvault/v11/article?p=50497.htm

7. Configure certificate
1. Stop the Tomcat Server.
2. Go to software_installation_path/Apache/Conf, and then back up the server.xml file that is part of the Apache configuration.
3. Copy the generated keystore file to software_installation_path/Apache.

4. For new installations of Version 11 SP9 or higher, in the server.xml file, modify the path to the generated keystore file and the keystore password values:

<Certificate certificateKeystoreFile="software_installation_path/Apache/your_file" certificateKeystorePassword="password" certificateKeystoreType="JKS"/>

8. Restart the service
a. Click Start and point to All Programs.
b. Click Commvault > Process Manager.
c. Under the Services tab, right-click a running service and then click Restart.



Python - day15 - if else

 Session 14:  7/15/2021

Review
<syntax2>
if <condition>:
  st1
  st2
else:
  st3
  st4



a=int(input("Enter first number"))
b=int(input("Please enter 2nd number"))

if a>b:
  print("A is greater then B")
else:
  print("A is less than B"


====================================

When will you go for if elif else?
When we have more than 2 options to choose from based on condition, we will use if elif else.
In this case, if the condition is true, it will execute the statement and skips the rest of the statement.

On the other hand, if if condition is false, the control will go to elif part and executes and else part skips. but if elif is false, then executes the else part.



Write a python program to accept one letter and check if it is vowel or not?

Step1: Design with o/p
----------------------

o/p
-------------------------
enter your letter:
user enters a, store a into a variable called letter: a
return: it is vowel.
Enter your letter:
user enter b, store b into variable called letter: b
return: its not a vowel.

coding
--------
letter=input("Enter your letter")
if letter=='a':
  print("It is a vowel")
elif letter=='e':
  print("It is a vowel")
elif letter=='i':
  print("It is a vowel')
elif letter=='o':
  print("It is a vowel')
elif letter=='u':
  print("It is a vowel")
else
  print("It is not a vowel")

When you run this code
input - enter ur letter
user enters a
a=a
condition is true, the it is vowel and rest of the condition is skips.

run it again
user enters b
b=a -> false , skips
b=e and keep checking and it will go to else part and returns the value
it is not vowel.

In this code we have 6 conditions, one for vower and other for consonent

Task1:
implement above program by using if else?

letter=input("Enter a letter")
if(letter=='a'|'e'|'i'|'o'|'u'):
  print("The letter is vowel")
else:
  print("The letter is not a vowel"


task2
Implement above vowel program by using if else and which should handle casesensitive?

Step1: Design with 0/p
=======================

le=input("Enter a letter")
if (le=='A' or le='a' or le=='E' or le=='e' or le=='I' or le=='i' or le=='o' or le=='O' or le=='U' or le=='u'):
  print(le, "is a vowel")
else
  print(le, "is not a consonant")


Task3
-----
Write a python program to accept student 3 subject marks and display the result?

Step1: Design with O/P
----------------------

o/p
----------
Enter m1 marks: 60
enter m2 marks: 70
enter m3 marks: 80

m1+m2+m3 = 60+70+80 = totmarks
totmarks/3 -> avg marks

Now display result
result can be vary..
avgmarks=70
1. fail: if > 35 in any one subject
2. First division: if >=60
3. 2nd division: if avgmarks is between 50-59
4. 3rd divison: if avg marks is in between 35 to 49

so output form above command is

Result is: Fist division.



Review and complete these tasks before tomorrow class.


----------------------------------

task4:
implement above program using 6 subjects.

task5:
Accept person's age display person status?

Step1: Design with o/p
----------------------

1. if age>=59
print senior citizen

2. if age is in between 25 to 57
- working citizen
3. if age is in between 16 and 24
- college students
4. if age is between 4-15
  - school kids
5. if kids are in between 1-3
  playing kids
6. invalid selection


o/p
---------------
Please enter your age:
user enters 59
sore 59 into a variable 'age' so age=50

print:
you are senior citizen.




Python - Day14 - if else

 Day/Session 14: Condition - 7/14/2021

Simple if
1. if lese
<syntax1>
if <condition>:
  st1
else:
  st2


When condition 1 is true it will execute statemetn1 and if fails, executes2.


first control will check the condition, if the condition is true, it will execute statement 1. it will skip the else statement.

if the condition is false, it will skip the if statement and goes to else part and executes else part.


<syntax2>
-------------
if <condition>:
  st1
  st2
else:
  st3
  st4

control will check the condition. if the condition is true it will enter into if condition and executes the statement 1 and statement 2. It skips the else part.
if condition is false, it skips the if part and conrol goes to else part and executes the else part.


eg1.
Write a python program to accept i and j value. Compare j and j values:

Step1: Design with o/p
----------------------

o/p
-----------------------
enter i value: 10
10 you store into i, i=10

enter j value: 5
store 5 int j, j=5

Write a condititon j is greater than i.

-> open your idle
File -> new file

i=int(input("Please enter i value"))
j=int(input("Enter j value"))
if i>j:
  print("i is greater than j")
else:
  print("j is greater than j")


run the program

enter 10, 10 will be stored in i
enter next number 5, stored in j.

next compares
i >j -> 10 > j -> condition is true so
it will execute if block. it skips else block.


There is a chance that user may type i=10 and j=10

what happens?
Since if condition evaluates and it is not true, it will skips the if blocks and goes to else part.

Since we don't have choice to write 3rd option, it will executes the else part.

to resolve this issue, we have to go to if, else, if part.

when do you use simple if?
-> we use simple if when particular condition need to verify.
when we have to c
in simple if, we have only one option. That means, when we have one option based on condition, we use simple if.

When do you use if else?
-> When we have 2 options, we want to execute one option based on condition.

3. if elif else
----------------
<SYNTAX>
---------
if <condition1>:
  st1
elif <condition2>:
  st2
else:
  st3

when you have more than 2 options.

first control will check condition1. if condition is true, it will execute st1 and skip elif and else part.

2nd option:

control checks the condition1 and if condition1 is false, it will skip and goes to elif and checks condition2. If its true, it executes and skips else part.

if elif contition 2 is false, it will skip the condition2 and control goes to else part and executes st3.


--------------------------

Eg,
Implement compare i and j using if elif else?
write down all the options

i=int(input("Enter i value:")
j=int(input("Enter j value:")

if i>j:
  print("i is greater than j")
elif:
  print(j is greater than i")
else:
  print("i is equal to j")

run the program:
enter i value: 10 -> 10 will be stored in i
enter j value: 5 -> 5 will stored in j


enter 5 and 10
5 greater than 10 -> skip if
compares elif part
conditon is true, executes
and prints the statemetn 2 and skips the else part

3rd, enter 10 and 10
compares first codition - flase,
end condition: false
executes else part.


you can use elif (3rd condition) but its not necessary. ..
Note: Do'nt use unnecesary conditions.


i=int(input("Enter i value:")
j=int(input("Enter j value:")

if i>j:
  print("i is greater than j")
elif:
  print(j is greater than i")
elif i==j:
  print("i is equal to j")


Q. Implement above program using the requiremet below.

a. user enters 10 and 5
b. User enters 10 and 10 value
c. User enters 5 and 10 values.
Write the code for this condition


Step1: Design with O/p

o/p
---------------------------------
Enter i value: 10 - user enter 10
10 stored in 10

enter j value: 5
user enter 5 and stored in j.

and display
i is greater than j.
j value is : 10

i=int(input("Enter i value:")
j=int(input("Enter j value:")

if i>j:
  print("i is greater than j")
  print(The value of i is:", i)
elif j>i:
  print(j is greater than i")
  print("i value is:",j)
elif i==j:
  print("i is equal to j")
  print("i value us:", i)
  print("j value is:",j)



10 adn 5

10>10
condition is true, executes the statemetn.
skips rest elif and else part

5>10 - false if skip
elif 5>10 -> false and executes

review the code above...


Python - day13 - if else

 Day 13 - Python 7-13-2021

1. Simple if
<syntax1>
if <condition>:
  st1
st2


by using relational operators

> -> Greater than
For eg,
-> 10>5  -> true,
   10>20 -> false
   10<20 -> true
   10<5  -> False
   10>=10 -> Yes -> True
   10 <=20 -> True
   10 <=10 -> True
   10==10  -> True
   10!=20  -> True
   10!=10  -> False

<  -> Less than
>=
<=
==
!=



coding

if 10>5:
  print("Hi")
print("Hello")

we have two statements.
Which statement is conditional dependent statement?
the first one..

what is the output of this code?
Since first condition is true, it will print hi and hello is regular statement, so it will also prints the output

first condition 10>5 is checked and its true so print Hi is printed
the control goes to next statement, and prints hello.



next,
if 10>20:
  print("Hi"
print("Hello")

here you will get only Hello outout

10>20 is false so it skips the statement. goes to next statement and reads it. It prints Hello.


<syntax2>
if <condition>:
  statement1
  st2
st3

we have two consitional statement. and one regular statement.

First condition is checked and if it is true, following two statements are printed.

lets say if condition is false, it will skip these two statements and go to next.

we have two statement conditional dependent and we have one conditional indenendent.


what happens when condition is false,
if condition is false, it will skip st1 and st2 and following statement is always executed.

if 10>5:
  print("Hi")
  print("Hello")

print("Bye")

what is the output?
->
Hi
Hello
Bye

10>10 true,
control will enter next statement and print Hi, Hello and goes to regular statement and prints bye.

if 10>50:
  print("Hi")
  print("Hello")
print("Bye")

what is the output?

o/p
--------
bye


10>50 will check and it false, it skips that section and goes to next section and prints bye.

eg,
Implement divide by zero error program by using simple if to handle run time error.

Design with output(o/p)
------------------------
Enter first number: 10
10 i sstored into a variable a.
Enter 2nd number: 0
user enter 0 and stored it into a variable b.

Please enter 2nd number other than zero: 5
user enter 5 and stored in c.
Division result is: 2

third statement is condition dependence. if user enter b==0:
checking the condition b.
3rd is condition accepting number other than 0.

So, we have to write a program. How to write a prigarm?

a=int(input("Enter first number:"))
b=int(input("Enter 2nd number:"))
if b==0:
  b=int(input("Please enter 2nd number other than 0"))
c=a/b
print("Division result is:", c)

here, user enters first number 10 stored in a
user enters 0 and stored on b
it will prompt user to enter a number other than zero.

and result will be printed.

lets say frist user enter 10 and stored in a
2nd user enter 5 and stored in b.


review
o/p
---------------
first
enter first number executes and user enters 10 and stored in a
control goes to 2nd line and user enter 0 and 0 is stoed in b.
after that control will check the condition

0=0 which is true and executes next staetmetn.
please enter 2nd number other than zero.
lets assume, user enters 5 and stored in c.
now, control goes to next statement

c=10/5-2.0
now, print
Divison result is 2.0.

what happens

simple if is only verifies only once so we have to use loops if you have to verify multiple condition.
our user may not be gentle man who enter only one right answer.




Review yesterday's 5 home work.








Python - Day 12 - condition - if else

 Day 12. Python

Write a python program to accept 2 numbers from the user and perform division and display division result?

Step1:

Step

vi test.py or open with idle

a=ent(input("Enter first number:"))
b=ent(input("Enter 2nd number:"))
c=a/b
print("Divison result is:", c)

run module

Enter first number:
enter 2nd number:


10 will be storing in a and so on


what happens if user enters 10 and 0?

error: run time error - zeroDivisionError: division by zero
value can not be divide by 0.


observation:
-----------
in the program above, when user entered first number 10 and second number 0, it will throw divide by zero error (run time error). Because of that program execution will be terminated abnormally.

run the program

enter first no: 10
enter 2nd no: 0

error:



Control Statement
in every programming language, control statement is very importand
how to handle run time errors?
- We can handle run time errors in 2 ways.
1. By using login
2. By using exception handling mechanism

1. By using login
- for this, we use control statement

2. Using exception hadling mechanism
-

What can we do using control statement?
- Using comtrol statement, we can control the program control execution flow according to our requirement.


When do we use control statement?
-> When we want to control the program execution flow as per our requirement.

We will go for control statements.


In python, we have 3 types of control statements.
1. Conditional statements
2. Loops
3. Transfer Statements

1. Conditional statements

Lets look at 4 scenarios

---------------------------------

statement 1
statement 2
statement 3
statement 4
statement 5

you have 5 lines of code and execution in order. We don't need any control statement


2nd scenario

---------------------------------

statement 1
statement 2
statement 3 ***
statement 4
statement 5


here staement3 may execute or may not execute. In this type of condition weneed conditional stement

---------------------------------

3nd
statement 1
statement 2
statement 3 ***
statement 4
statement 5


here statement 3 executing multiple time so we use look


---------------------------------
4th
statement 1
statement 2
statement 3  ***
statement 4
statement 5  ***


here, executing 1 and jumping to stetmenet 3 and jumping to 5, we use transfer statement.

as per the situation, we use one of the condition.


=============================

1. Conditional statements
What can we do with conditional statement?
- Using conditional statements, we can execute single statement or multiple statements based on condition.

When do we use conditional statements?
-> When you want to execute single statement or multiple statements based on condition, we will use conditional statements.

Types of conditional statements?
- In python, we have following conditional statements

1. Simple if
2. if else
3. if elif
4. multiple if
5. nested if


HW
Write a program using simple if, if else, if elif, multiple if, and nested if.


==============================

xcellis:


QXS-4 series chassis overview and qxs-456 chassis overview

xcellis I artico documentation center





Friday, July 23, 2021

Some HP Servers

Some HP servers

HPE DL325 G10 128GB 24 cores
HPE DL380p 384 GB 24 cores
HPE DL580 G10 3TB RAM 88 cores
SuperDome Flex 14TB 288 cores




 

 

Tuesday, July 20, 2021

ROM Flash Component for Linux - HPE ProLiant DL325 Gen10 (A41) Servers

 ROM Flash Component for Linux - HPE ProLiant DL325 Gen10 (A41) Servers

 HPE A41 - Bios update

 Download the software

Multi-part downloadFile name:    firmware-system-a41-2.20_2019_09_17-1.1.x86_64.compsig (2.0 KB)   
File name:    firmware-system-a41-2.20_2019_09_17-1.1.x86_64.rpm (16 MB)

 Installation:

To update firmware from Linux operating system on target server:

Install the RPM package
> rpm -Uvh <filename>.rpm

See where the files land
> rpm -qlp <filename>.rpm

Change to the directory you see in the previous step and run hpsetup by typing ‘./hpsetup’ at the command prompt.

 # cd /usr/lib/x86_64-linux-gnu/firmware.../

# ./hpsetup

login with your iLO management account/PW when prompted

type 'y' and enter to update the software.


when prompt for reboot, say y.

 

Reboot Requirement:
Reboot is required after installation for updates to take effect and hardware stability to be maintained.

https://support.hpe.com/hpesc/public/swd/detail?swItemId=MTX-531cc9e031d243a48b39a6430f#tab3

 

 

 

How to create a Linux RPM package

 

How to create a Linux RPM package

You've written a great script that you want to distribute, so why not package it as an RPM?
Image
How to create a Linux RPM package

Photo by Ketut Subiyanto from Pexels

This article shows you how to package a script into an RPM file for easy installation, updating, and removal from your Linux systems. Before I jump into the details, I'll explain what an RPM package is, and how you can install, query, remove, and, most importantly, create one yourself.

This article covers:

  • What an RPM package is.
  • How to create an RPM package.
  • How to install, query, and remove an RPM package.

What is an RPM package?

RPM stands for Red Hat Package Manager. It was developed by Red Hat and is primarily used on Red Hat-based Linux operating systems (Fedora, CentOS, RHEL, etc.).

An RPM package uses the .rpm extension and is a bundle (a collection) of different files. It can contain the following:

  • Binary files, also known as executables (nmap, stat, xattr, ssh, sshd, etc.).
  • Configuration files (sshd.conf, updatedb.conf, logrotate.conf, etc.).
  • Documentation files (README, TODO, AUTHOR, etc.).

The name of every RPM package is comprised as follows:

<name>-<version>-<release>.<arch>.rpm

An example:

bdsync-0.11.1-1.x86_64.rpm

[ You might also enjoy: Linux package management with YUM and RPM ]

How to create an RPM package

You'll need the following components to build an RPM package:

  • A workstation or a virtual machine (I am using Fedora 32 on a virtual machine).
  • Software to build the package.
  • Source code to package.
  • SPEC file to build the RPM.

Installing the required software

The following packages need to be installed to build the RPM package:

$ sudo dnf install -y rpmdevtools rpmlint

After installing rpmdevtools, we can run the following as a user called sai.local:

$ rpmdev-setuptree

Note: Do not build RPM packages as the root user. This is highly discouraged.

The above command creates the following directory structure:

rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
  • The BUILD directory is used during the build process of the RPM package. This is where the temporary files are stored, moved around, etc.
  • The RPMS directory holds RPM packages built for different architectures and noarch if specified in .spec file or during the build.
  • The SOURCES directory, as the name implies, holds sources. This can be a simple script, a complex C project that needs to be compiled, a pre-compiled program, etc. Usually, the sources are compressed as .tar.gz or .tgz files.
  • The SPEC directory contains the .spec files. The .spec file defines how a package is built. More on that later.
  • The SRPMS directory holds the .src.rpm packages. A Source RPM package doesn’t belong to an architecture or distribution. The actual .rpm package build is based on the .src.rpm package.

A .src.rpm package is very flexible since it can be built and re-built on every other RPM-based distribution and architecture.

Since you're now familiar with what each directory holds, here's how to create a simple but functional bash script that I'll show you how to package.

Create the bash script

You are probably familiar with the following error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
da:ea:16:ff:db:d3:5c:0c:12:11:de:dd:2d:ba:fd:2a.
Please contact your system administrator.
Add correct host key in /home/foo/.ssh/known_hosts to get rid of this message.
Offending key in /home/foo/.ssh/known_hosts:42
RSA host key for domain.com has changed, and you have requested strict checking.
Host key verification failed.

So the purpose of this bash script is to remove the offending key from ~/.known_hosts without having to manually edit the file and remove 42.

Note that ssh-keygen -R didn’t work in my case, so I created a script called rm-ssh-offendingkey to automate this process. Here it is:

#!/usr/bin/env bash

rmoffendingKey()
{
  local offendingKey="$1"
  local st=1
  if [[ ! -z $offendingKey && $offendingKey =~ [[:digit:]] ]]; then
    sed -i "${offendingKey}d" ~/.ssh/known_hosts
    st=$?
  else
    printf '%s\n' "You need to provide a line number" >&2
  fi  
  return $st
}
rmoffendingKey “$1

Place the script in the designated directory

To build the script, you need to put it in the directory the RPM build process is expecting it to be in. Create the directory structure:

$ mkdir p ~/rpmbuild/SOURCES/sshscript-1/rm-ssh-offendingkey/

Put the rm-ssh-offendingkey script in the sshscript-1/rm-ssh-offendingkey directory.

Subsequently, I .tar.gz the source as follows:

$ cd ~/rpmbuild/SOURCES/ && tar zcvf sshscripts-1.tar.gz sshscripts-1/

Create the .spec file

To be able to package the script, you need to create a .spec file. To make a default .spec file for the package, I am going to use the following syntax:

rpmdev-newspec rm-ssh-offendingkey

Now let’s run tree ~/rpmbuild to see what the directory structure looks like:

/home/sai.local/rpmbuild/
├── BUILD
├── BUILDROOT
├── RPMS
├── SOURCES
│   └── sshscripts-1
│       └── rm-ssh-offendingkey-1
│           └── rm-ssh-offendingkey
├── SPECS
│   └── rm-ssh-offendingkey.spec
└── SRPMS

The generated rm-ssh-offendingkey.spec file needs some modifications. The generated .spec file assumes that I am going to compile and build software. Since I'm packaging a simple bash script, I'll remove some unnecessary lines from the .spec file and add others. For example, I added Requires: bash so that the package requires bash to be installed as well. I also added BuildArch: noarch which means that the package should work on a 32-bit and a 64-bit CPU architecture.

Name:           sshscripts
Version:        1
Release:        0
Summary:        A simple bash script to remove ssh offending key from known hosts
BuildArch:      noarch

License:        GPL
#URL:            
Source0:        %{name}-%{version}.tar.gz

#BuildRequires:  
Requires:       bash

%description
This is a simple script that somehow automates the removal of ssh offending key from the ~/.ssh/known_hosts file

%prep
%setup -q

%build

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
cp rm-ssh-offendingkey-1/* $RPM_BUILD_ROOT/%{_bindir}

%clean
rm -rf $RPM_BUILD_ROOT

%files
%{_bindir}/rm-ssh-offendingkey

%changelog
* Sun Nov  8 2020 Valentin Bajrami <valentin.bajrami@slimmer.ai> - 0.1
- First version being packaged

It's important to specify which files are going to be installed under the %files section. Here I’ve explicitly put the following line:

%files
%{_bindir}/rm-ssh-offendingkey

This is sufficient since I only want this script to go to /usr/bin. Oh, by the way, %{_bindir} is called a macro and translates to /usr/bin. You can verify this by running:

$> rpm --eval '%{_bindir}'
/usr/bin

Other useful macros to be aware of are:

Macro          Translates to
%{_sbindir}    /usr/sbin
%{_datadir}    /usr/share
%{_sysconfdir}    /etc

Checking the .spec file on error (rpmlint)

At the beginning of the article, I installed the rpmlint package along with rpmdev-tools, which helps me to check the .spec file for errors.

$ rpmlint ~/rpmbuild/SPECS/rm-ssh-ffendingkey.spec
/home/sai.local/rpmbuild/SPECS/rm-ssh-ffendingkey.spec: W: invalid-url Source0: sshscripts-1.tar.gz
0 packages and 1 specfiles checked; 0 errors, 1 warnings.

Everthing looks good.

Building the package (rpmbuild)

To build the RPM package you can use the rpmbuild command. Earlier in this tutorial, I mentioned the difference between the .src.rpm (Source RPM package) and the .rpm package.

To create the .src rpm package, use:

$ rpmbuild -bs ~/rpmbuild/SPECS/rm-ssh-offendingkey.spec

The flags -bs have the following meanings:

  • -b | build
  • -s | source

To create the binary .rpm package, use:

$ rpmbuild -bb ~/rpmbuild/SPECS/rm-ssh-offendingkey.spec

The flags -bb have the following meanings:

  • -b | build
  • -b | binary

If all goes well, you now have the following directory structure:

$ tree ~/rpmbuild/
/home/sai.local/rpmbuild/
├── BUILD
│   └── sshscripts-1
│       ├── debugfiles.list
│       ├── debuglinks.list
│       ├── debugsourcefiles.list
│       ├── debugsources.list
│       ├── elfbins.list
│       └── rm-ssh-offendingkey-1
│           └── rm-ssh-offendingkey
├── BUILDROOT
├── RPMS
│   └── noarch
│       └── sshscripts-1-0.noarch.rpm
├── SOURCES
│   ├── sshscripts-1
│   │   └── rm-ssh-offendingkey-1
│   │       └── rm-ssh-offendingkey
│   └── sshscripts-1.tar.gz
├── SPECS
│   └── rm-ssh-offendingkey.spec
└── SRPMS

11 directories, 10 files

The following lines are indicating that the RPM package has successfully been built.

├── RPMS
│   └── noarch
│       └── sshscripts-1-0.noarch.rpm

Installing the RPM package

After a successful build of the package, you now can install the RPM package as follows:

$ sudo rpm -ivh ~/rpmbuild/RPMS/noarch/sshscripts-1-0.noarch.rpm

Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:sshscripts-1-0                   ################################# [100%]

Verifying the package has been installed

To verify the package has correctly been installed, run the following command:

$ rpm -qi sshscripts-1
Name        : sshscripts
Version     : 1
Release     : 0
Architecture: noarch
Install Date: Mon 09 Nov 2020 01:29:51 AM CET
Group       : Unspecified
Size        : 294
License     : GPL
Signature   : (none)
Source RPM  : sshscripts-1-0.src.rpm
Build Date  : Mon 09 Nov 2020 01:08:14 AM CET
Build Host  : slimmerAI
Summary     : A simple bash script to remove ssh offending key from known hosts
Description :
This is a simple script that somehow automates the removal of ssh offending key from the ~/.ssh/known_hosts file

Querying some more info about the package, in the spec file, I did add a %changelog entry. This %changelog entry can be viewed as follows:

$ rpm -q sshscripts-1 --changelog
* Sun Nov 08 2020 Valentin Bajrami <valentin.bajrami@slimmer.ai> - 0.1
- First version being packaged

See what’s in the RPM package

It is very easy and quite convenient to see which files an RPM package contains. This information is retrieved as follows:

$ rpm -ql sshscripts-1
/usr/bin/rm-ssh-offendingkey

Removing the RPM package

Removing the package from the system is just as easy as installing it.

$ sudo rpm -ve sshscripts-1
[sudo] password for sai.local:
Preparing packages...
sshscripts-1-0.noarch
  • - v | verbose
  • - e | erase

Final thoughts

In this document, I covered the very basics of an RPM package, including how to build, install, and remove it from your system. The .spec file can get very complicated as you build more advanced software. If you plan to continue your journey on building RPM packages, don’t forget to check out mock and the mock GitHub page.


https://www.redhat.com/sysadmin/create-rpm-package

https://www.redhat.com/en/services/training/rh024-red-hat-linux-technical-overview?intcmp=701f20000012ngPAAQ&section=Outcomes

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...