Unit-5 Notes
Unit-5 Notes
What is GIT?
GIT is a distributed version control system used to track changes in source code during
software development. It allows multiple developers to work on the same project without
overwriting each other’s work.
Features of GIT:
GIT Architecture:
• git init, git clone, git add, git commit, git push, git pull, git status, git log
•
Git is a powerful and widely used version control system that helps developers track changes
in their code, collaborate with others, and manage project history effectively. Whether you are
a professional developer or just starting out, understanding Git is important for modern
software development. This article will introduce you to Git, explain its core concepts, and
provide practical examples to help you get started.
1. Repositories
A repository (or repo) is a storage space where your project files and their history are kept.
There are two types of repositories in Git:
• Local Repository: A copy of the project on your local machine.
• Remote Repository: A version of the project hosted on a server, often on platforms like
GitHub, GitLab, or Bitbucket.
2. Commits
A commit is a snapshot of your project at a specific point in time. Each commit has a unique
identifier (hash) and includes a message describing the changes made. Commits allow you to
track and review the history of your project.
3. Branches
A branch is a separate line of development. The default branch is called main or master. You
can create new branches to work on features or fixes independently. Once the work is
complete, the branch can be merged back into the main branch.
4. Merging
Merging is the process of integrating changes from one branch into another. It allows you to
combine the work done in different branches and resolve any conflicts that arise.
5. Cloning
Cloning a repository means creating a local copy of a remote repository. This copy includes
all files, branches, and commit history.
1. Installing Git
Git can be installed on various operating systems.
4. Add Changes:
To stage changes for the next commit:
git add <file-name>
Or to add all changes:
git add .
1. Install Git: Download and install Git from the official Git website.
2. Configure Git: Set up your username and email.
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
3. Create a Repository: Navigate to your project directory and initialize a Git repository.
git init
4. Make Your First Commit: Add files to the staging area and commit your changes.
git add .
git commit -m "Initial commit"
Key Terminologies
• Git Branch: A parallel version of the code within a Git repository, allowing for separate
development and experimentation.
• Main Branch (formerly Master Branch): The primary branch of a Git repository where
the production-ready code resides.
• Feature Branch: A branch created to work on a specific feature or task isolated from the
main branch.
• Merge: The process of combining changes from one branch into another.
• Pull Request (PR): A request made by a developer to merge their changes into another
branch, often used for code review.
• CI/CD Pipeline: Continuous Integration and Continuous Deployment pipeline,
automating the process of building, testing, and deploying code changes.
A branching strategy is a strategy that software development teams adopt for writing,
merging and deploying code with the help of a version control system like Git. It lays down a
set of rules that aid the developers on how to go about the development process and interact
with a shared codebase. Strategies like these are essential as they help in keeping project
repositories organized, error free and avoid the dreaded merge conflicts when multiple
developers simultaneously push and pull code from the same repository.
Encountering merge conflicts can impede the swift delivery of code, thereby obstructing the
establishment and upkeep of an efficient DevOps workflow. DevOps aims to facilitate a rapid
process for releasing incremental code changes. Therefore, implementing a structured
branching strategy can alleviate this challenge, enabling developers to collaborate seamlessly
and minimize conflicts. This approach fosters parallel workstreams within teams, promoting
quicker releases and reduced likelihood of conflicts through a well-defined process for source
control modifications.
The Branching strategies provides following features:
• Parallel development
• Enhanced productivity due to efficient collaboration
• Organized and structured feature releases
• Clear path for software development process
• Bug-free environment without disrupting development workflow
Gitflow Workflow
GitFlow enables parallel development, where developers can work separately on feature
branches, where a feature branch is created from a master branch. After completion of
changes, the feature branch is merged with the master branch.
The types of branches that can be present in GitFlow are:
• Master - Used for product release
• Develop - Used for ongoing development
• Feature Branching - branches off the develop branch to develop new features.
• Release - Assist in preparing a new production release and bug fixing, typically branched
from the develop branch, and necessitating merges back into both develop and master
branches.
• Hotfix - Hotfix branches aid in addressing discovered bugs swiftly, allowing developers
to continue their work on the develop branch while the issue is resolved. Unlike release
branches, hotfix branches are created from master branch specifically for critical bug
resolution in the production release.
The Master and Develop branches are the main branches, and persist throughout the journey
of the software. The other branches are essentially supporting branches and are short-lived.
Pros Of Gitflow
Git – Merge
•
Git is a powerful version control system that helps developers manage code versions
efficiently. One of the most fundamental operations in Git is merging, which allows you to
integrate changes from one branch into another.
What is Git Merge?
Git merge is a command used to combine the changes from two different branches into one.
It helps in integrating work from multiple branches, ensuring that all changes are integrated
and up-to-date in the target branch without losing any progress made on either branch.
• Preserves History: Keeps commit history of both branches.
• Automatic and Manual: Automatically merges unless there are conflicts.
• Fast-Forward Merge: Moves the branch pointer forward if no diverging changes exist.
• Merge Commit: Creates a special commit to combine histories.
• No Deletion: Branches remain intact after merging.
• Used for Integration: Commonly integrates feature branches into main branches.
Syntax
git merge <branch-name>
• Common Base: When merging two branches, Git looks for the common base commit.
• Merge Commit: Once it finds the common base, Git creates a new “merge commit” to
combine the changes.
• Conflict Resolution: If there are any conflicts between the branches, Git will prompt you
to resolve them.
Git – Merge
• In our case, we have two branches one is the default branch called “main” and the other
branch named “dev” and this is how our git repo looks before merging.
• Here git finds the common base, creates a new merge commit, and merged them.
Git – Merge
1. Fast-forward merging
• This occurs when the target branch (e.g., main) is directly ahead of the feature branch
(e.g., dev).
• Instead of creating a merge commit, Git simply moves the current branch’s tip to the
target branch’s tip.
• Fast-forward merging is only possible when branches haven’t diverged
Git – Merge
2. Three-way merging
• This type occurs when the base branch has changed since the branch was first created.
• Git generates a new merge commit by comparing changes in both branches with the base
branch.
Note : Git also supports some other types of merging like recursive and octopus margin. With
the help of a single merge commit “octopus merging” can merge multiple branches at once.
“Recursive merging” is similar to three-way merging but it can handle some more complex
merge operations than the three-way merging.
Essential Commands To Perform Git Merging
To perform a git merge, you need a Git repository with at least two branches. Here’s how to
proceed:
• Create a new branch
git branch <name of the branch you wanna create>
• Merge two branches: First, check out the target branch, then run:
git merge <name of the current branch>
• Now we have successfully merged our two branches and as you can see we have the same
changes or you can say commits in both branches.
What Is Git?
Git is a distributed version control system that is used to store the source code in software
development to track its changes. It facilitates the developers to work collaboratively with
teams on repositories to manage the codebase versions i.e., maintaining the history of project
modifications. On using git, developers can seamlessly move through the different project
states, and merge changes efficiently ensuring a streamlined and organized approach to
software development.
Features Of Git
The Efficient local operations, Secured Version control, flexible workflows, and collaborative
tools enhanced the developers for effective usage of git in diverse ways. The following sections
discuss some of the git features.
1. Performance Of Git
• Local Operations: Git performs most of the operations locally boosting the speed and
efficiency.
• Light Weight Branching: It creates and combines the branches quickly enabling the
parallel development of programming.
• Optimized Merging: It comes up with effective methods for simplifying the integration
of modifications from several branches.
2. Git Security
• Data Integrity: Git comes with tampered resistant version control system ensuring via
cryptographic hashing.
• Access Controls: Git facilitates in restricting the user access and prevent from illegal
modifications by defining permissions.
• Secure Protocols: It allows in exchanges of secure data over SSH and HTTPS protocols.
A VCS or the Version Control System is used to track versions of the files and store them in a
specific place known as repository. The process of copying the content from an existing Git
Repository with the help of various Git Tools is termed git cloning. Once the cloning process
is done, the user gets the complete repository on his local machine. Git by default assumes the
work to be done on the repository as a user, once the cloning is done. Users can also create a
new repository or delete an existing repository. To delete a repository, the simpler way is to
just delete the folder containing the repository. Repositories can be divided into two types based
on the usage on a server. These are:
• Bare Repositories: These repositories are used to share the changes that are done by
different developers. A user is not allowed to modify this repository or create a new
version for this repository based on the modifications done.
• Non-bare Repositories: Non-bare repositories are user-friendly and hence allow the user
to create new modifications of files and also create new versions for the repositories. The
cloning process by default creates a non-bare repository if any parameter is not specified
during the clone operation.
• Untracked: In this stage, the Git repository is unable to track the file, which means that
the file is never staged nor it is committed. The file is present in the working directory but
Git is unaware of its existence.
• Tracked: When the Git repository tracks a file, which means the file is committed but is
not staged in the working directory. In this the file changes have been committed at some
point in the repository’s history.
• Staged: In this stage, the file is ready to be committed and is placed in the staging area
waiting for the next commit. The changes in the file have been marked and to be included
in the next commit.
• Modified/Dirty: When the changes are made to the file i.e. the file is modified but the
change is not yet staged.
After the changes are done in the working area, the user can either update these changes in the
GIT repository or revert the changes.
After performing various modifications on a file in the Working Area, GIT needs to follow two
more steps to save these changes in the local repository. These steps are:
1. Adding the changes to the Index(Staging Area)
2. Committing the indexed changes into the repository
Adding changes to the Index This process is done by the use of git add command. When the
changes have been made in the Working Tree/Area. These changes need to be added to the
Staging Area for further modification of the file. git add command adds the file in the local
repository. This stages them for the commit process.
er.
Cloning And Synchronizing With Remote Repositories
Git allows the users to perform operations on the Repositories by cloning them on the local
machine. This will result in the creation of various different copies of the project. These copies
are stored on the local machine and hence, the users will not be able to sync their changes with
other developers. To overcome this problem, Git allows performing syncing of these local
repositories with the remote repositories. This synchronization can be done by the use of two
commands in the Git listed as follows:
• push
• pull
Git Push
This command is used to push all the commits of the current repository to the tracked remote
repository. This command can be used to push your repository to multiple repositories at
once.
Syntax
$ git push -u origin master
To push all the contents of our local repository that belong to the master branch to the server
(Global repository).
Git Pull
Pull command is used to fetch the commits from a remote repository and stores them in the
remote branches. There might be a case when other users perform changes on their copy of
repositories and upload them with other remote repositories. But in that case, your copy of the
repository will become out of date. Hence, to re-synchronize your copy of the repository with
the remote repository, the user has to just use the git pull command to fetch the content of the
remote repository.
Syntax
$ git pull
Additional Git Commands
Git Status
It is used for checking the status of git repository, i.e., if the files are committed or not, files
in staging area or untracked file.
Syntax
$ git status
Git Log
It is used to track all the changes made in the repository, providing the information on
contributors and their contributions.
Syntax
$ git log
.gitignore
You may use .gitignore if you want to hide any file when uploading online. Just simply
create a .gitignore file, and write all the files names you want to ignore.
Git Merge
It is used to merge two repository, without losing the data. It merge the specified repository to
the current repository.
Syntax
$ git merge <repo-name>
Git Checkout
It is used to rollback to previous version of the project which was committed anytime earlier.
You can copy to hash-code from git log and use it to rollback.
Syntax
$ git checkout <hash-code>
Feature of MySQL
Step 1: Open terminal using Ctrl+Alt+T. Now copy and paste the following command in the
terminal to install MySQL in Linux.
sudo apt install mysql-server
Step 6: Create a password. Then Re-enter the password, then to continue press “y”.
Now the whole setup is done. Hence, MySQL installaion is successfully done!
Hence, we have successfully created a database using create database command. You are
now ready to start using MySQL. MySQL is the best relational database that will keep all
your data secure. Many Companies use MySQL because of its solid data security and
is supported by multiple applications.
•
MongoDB is a popular NoSQL database offering flexibility, scalability, and ease of use.
Installing and configuring MongoDB in Ubuntu is a straightforward process, but it requires
careful attention in detail to ensure a smooth setup.
In this article, we’ll learn how to install and configure MongoDB in Ubuntu. We’ll walk us
through each step, from installation to configuration, enabling us to harness the power of
MongoDB on our Ubuntu system. Let’s look at the requirements for installing MongoDB in
Ubuntu.
Step 1: First we need to update and upgrade our system repository to install MongoDB. Type
the following command in our terminal and then press Enter.
sudo apt update && sudo apt upgrade
Step 2: Now, install the MongoDB package using ‘apt‘. Type the following command and
press Enter.
sudo apt install -y mongodb
Step 3: Check the service status for MongoDB with the help of following command:
sudo systemctl status mongodb
As it can be seen that the service has stopped, to start the service we can use :
sudo systemctl start mongodb
Step 6: Accessing the MongoDB Shell
MongoDB provides a command-line interface called the MongoDB shell, which allows us to
interact with the database.
To access the MongoDB shell, simply type the following command in your terminal:
mongo
We are now connected to the MongoDB server, and you can start executing commands to
create databases, collections, and documents.
Features of MongoDB
Advantages:
• It has 600+ Penetration testing and network security tools pre-installed.
• It is completely free and open source. So you can use it for free and even contribute for its
development.
• It supports many languages.
• Great for those who are intermediate in linux and have their hands on Linux commands.
• Could be easily used with Raspberry Pi.
Disadvantages:
• It is not recommended for those who are new to linux and want to learn linux.(As it is
Penetration Oriented)
• It is a bit slower.
• Some software may malfunction.
1. Nmap Tool
Nmap is an open-source network scanner that is used to recon/scan networks. It is used to
discover hosts, ports, and services along with their versions over a network. It sends packets
to the host and then analyzes the responses in order to produce the desired results. It could
even be used for host discovery, operating system detection, or scanning for open ports. It is
one of the most popular reconnaissance tools.
To use nmap:
• Ping the host with the ping command to get the IP address
ping hostname
• Open the terminal and enter the following command there.
nmap -sV ipaddress
Replace the IP address with the IP address of the host you want to scan.
• It will display all the captured details of the host.
Read more about nmap.
2. ZenMAP
It is another useful tool for the scanning phase of Ethical Hacking in Kali Linux. It uses the
Graphical User Interface. It is a great tool for network discovery and security auditing. It does
the same functions as that of the Nmap tool or in other words, it is the graphical Interface
version of the Nmap tool. It uses command line Interface. It is a free utility tool for network
discovery and security auditing. Tasks such as network inventory, managing service upgrade
schedules, and monitoring host or service uptime are considered really useful by systems and
network administrators.
To use Zenmap, enter the target URL in the target field to scan the target.
3. whois lookup
whois is a database record of all the registered domains over the internet. It is used for many
purposes, a few of them are listed below.
• It is used by Network Administrators in order to identify and fix DNS or domain-related
issues.
• It is used to check the availability of domain names.
• It is used to identify trademark infringement.
• It could even be used to track down the registrants of the Fraud domain.
To use whois lookup, enter the following command in the terminal
whois geeksforgeeks.org
Replace geeksforgeeks.org with the name of the website you want to lookup.
4. SPARTA
SPARTA is a python based Graphical User Interface tool which is used in the scanning and
enumeration phase of information gathering. It is a toolkit having a collection of some useful
tools for information gathering. It is used for many purposes, a few of them are listed below.
• It is used to export Nmap output to an XML file.
• It is used to automate the process of Nikto tool to every HTTP service or any other
service.
• It is used to save the scan of the hosts you have scanned earlier in order to save time.
• It is used to reuse the password which is already found and is not present in the wordlist.
To use SPARTA, enter the IP address of the host you want to scan in the host section to start
scanning.
5. nslookup
nslookup stands for nameserver lookup, which is a command used to get the information
from the DNS server. It queries DNS to obtain a domain name, IP address mapping, or any
other DNS record. It even helps in troubleshooting DNS-related problems. It is used for many
purposes, a few of them are listed below.
• To get the IP address of a domain.
• For reverse DNS lookup
• For lookup for any record
• Lookup for an SOA record
• Lookup for an ns record
• Lookup for an MX record
• Lookup for a txt record
6. Osintgram
This AWS tutorial is designed for beginners and professionals to learn AWS’s basic and
advanced concepts. Learn about the various topics of AWS, such as introduction, history of
AWS, global infrastructure, features of AWS, IAM, storage services, database services,
application Services, etc., and other AWS products such as S3, EC2, Lambda, and more. By
the end of this tutorial, readers will have a basic understanding of what AWS is and how it can
be used to support their computing needs.
•
EC2 stands for Elastic Compute Cloud a service from Amazon Web Services (AWS). EC2 is
an on-demand computing service on the AWS cloud platform. It lets you rent virtual computers
to run your applications. You pay only for what you use.
Instead of buying and managing your own servers, EC2 gives you a virtual machine, where
you can run websites, apps, or even big data tasks. You can choose how much memory,
storage, and processing power you need- and stop it when you’re done. EC2 offers security,
reliability, high performance, and cost-effective infrastructure to meet demanding business
needs.
You can deploy your applications in EC2 servers without any worrying about the underlying
infrastructure. You configure the EC2-Instance in a very secure manner by using the
VPC, Subnets, and Security groups. You can scale the configuration of the EC2 instance you
have configured based on the demand of the application by attaching the autoscaling group to
the EC2 instance. You can scale up and scale down the instance based on the incoming traffic
of the application.
The following figure shows the EC2-Instance which is deployed in VPC (Virtual Private
Cloud).
3. Memory-Optimized Instances
• High memory-to-CPU ratios for large data sets.
• Perfect for in-memory databases, real-time big data analytics, and high-performance
computing (HPC).
Examples: R5, X1e instances.
• Amazon Linux
• Windows Server
• Ubuntu Server
• SUSE Linux
• Red Hat Linux
1. Free Tier
If you’re new to AWS, you can try EC2 for free with the Free Tier. You get up to 750 hours
per month of t2.micro instances for one year, which is perfect for learning, experimenting,
or running lightweight applications. If you exceed the free limits, you’ll only pay for what’s
above the Free Tier.
2. On-Demand Instances
With On-Demand Instances, you pay for the compute power you use, by the second, with
a minimum of 60 seconds. There’s no need to commit to a long-term contract or make any
upfront payments. This is ideal for applications that are unpredictable or for short-term use
cases where you only want to pay for what you need.
3. Savings Plans
If you know you’ll need consistent computing power, Savings Plans let you commit to a
certain level of usage over a 1- or 3-year term. By making this commitment, you can save
significantly compared to On-Demand pricing. The best part is that you can apply the
discount across a wide range of instances, so it’s flexible based on your needs.
4. Reserved Instances
Reserved Instances give you the chance to commit to a specific instance type and region
for 1 or 3 years. This helps reduce costs by reserving capacity in advance. It’s great for
steady applications that need reliable performance over a long period. Reserved Instances can
also give you significant discounts compared to On-Demand pricing.
5. Spot Instances
Spot Instances let you bid for unused EC2 capacity, which can give you up to 90% off the
regular price. They’re perfect for tasks that are flexible and can be interrupted, like batch
processing or big data analysis. However, AWS can terminate these instances with little
notice, so they work best for non-urgent workloads.
6. Dedicated Hosts
Dedicated Hosts provide you with a physical EC2 server fully dedicated to your use. This is
ideal if you have server-bound software licenses or need to meet
specific compliance requirements. You can also use this option as part of a Savings Plan to
save on costs. Dedicated Hosts allow you to have more control over the physical
infrastructure for your applications.
8. Per-Second Billing
EC2’s per-second billing means that you only pay for the exact compute time you use, down
to the second. There’s no need to pay for unused minutes or extra time, making it a more
cost-effective option for short-lived tasks or workloads that are dynamic in nature.
Get Started With Amazon EC2 (Elastic Compute Cloud) Linux Instances
Step 1: First login into your AWS account. Once you are directed to the management console.
From the left click on “Services” and from the listed options click on EC2.
Step 2: Afterward, you will be redirected to the EC2 console. Here is the image attached to
refer to various features in EC2.
• Data Storage: Amazon s3 acts as the best option for scaling both small and large
storage applications. It helps in storing and retrieving the data-intensitive applications
as per needs in ideal time.
• Backup and Recovery: Many Organizations are using Amazon S3 to backup their
critical data and maintain the data durability and availability for recovery needs.
• Hosting Static Websites: Amazon S3 facilitates in storing HTML, CSS and other web
content from Users/developers allowing them for hosting Static Websites benefiting
with low-latency access and cost-effectiveness. To know more detailing refer this
Article – How to host static websites using Amazon S3
• Data Archiving: Amazon S3 Glacier service integration helps as a cost-effective
solution for long-term data storing which are less frequently accessed applications.
• Big Data Analytics: Amazon S3 is often considered as data lake because of its capacity
to store large amounts of both structured and unstructured data offering seamless
integration with other AWS Analytics and AWS Machine Learning Services.
•
1. Relational Database :
RDBMS stands for Relational Database Management Systems. It is most popular database. In
it, data is store in the form of row that is in the form of tuple. It contain numbers of table and
data can be easily accessed because data is store in the table. This Model was proposed by
E.F. Codd.
2. NoSQL :
NoSQL Database stands for a non-SQL database. NoSQL database doesn’t use table to store
the data like relational database. It is used for storing and fetching the data in database and
generally used to store the large amount of data. It supports query language and provides
better performance.
Difference between Relational database and NoSQL :
Relational Database NoSQL
Data arrives from one or few locations. Data arrives from many locations.
Its difficult to make changes in database once Enables easy and frequent changes to
it is defined database