<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Srinivas karnati</title>
    <description>The latest articles on DEV Community by Srinivas karnati (@karnatisrinivas).</description>
    <link>https://dev.to/karnatisrinivas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F808650%2F8187fc91-ac13-4fd4-84e4-97295bcacc7d.png</url>
      <title>DEV Community: Srinivas karnati</title>
      <link>https://dev.to/karnatisrinivas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karnatisrinivas"/>
    <language>en</language>
    <item>
      <title>ErrImagePull and ImagePullBackOff in Kubernetes</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Wed, 18 Jan 2023 06:15:25 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/errimagepull-and-imagepullbackoff-in-kubernetes-47oa</link>
      <guid>https://dev.to/karnatisrinivas/errimagepull-and-imagepullbackoff-in-kubernetes-47oa</guid>
      <description>&lt;p&gt;When you create a pod in Kubernetes, &lt;a href="https://medium.com/@__karnati/wh-37100ac1a702" rel="noopener noreferrer"&gt;it goes through a lot of steps.&lt;/a&gt; One of the important tasks is to pull the container image from the registry. While pulling those images from the registry, pods sometimes experience issues. If an error occurs, pods go into &lt;code&gt;ErrImagePull, ImagePullBackOff&lt;/code&gt; errors.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ErrImagePull&lt;/code&gt; happens when the image that is specified in the pod spec can’t be fetched.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ImagePullBackOff&lt;/code&gt; is the grace period while the image pull is fixed. After each unsuccessful pull, the delay (grace period) increases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Container Image and Image Pull Policy&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A container image&lt;/strong&gt; includes the binary data of the application and its dependencies. So you have to create the image for your application and push it to the registry before you refer that image in the Pod. The image registry by default is Docker unless you specified the registry.&lt;/p&gt;

&lt;p&gt;Tags are also an important part of the image name, tags are used to identify different versions of the image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image pull policy&lt;/strong&gt; defines when the kubelet tries to pull the image. the &lt;code&gt;IfNotPresent&lt;/code&gt; value tells the kubelet to pull the image only if it is not present locally. &lt;code&gt;Never&lt;/code&gt; tells the kubelet not to fetch the image. And &lt;code&gt;Always&lt;/code&gt; tells kubelet to check the registry and pull the image for this pod. By default, the Image pull policy is set to Always.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;ErrImagePull&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This occurs when the kubelet tries to pull the image from the registry (based on its image pull policy). Sometimes things can go wrong, we might have messed up the image spec in the pod definition.&lt;/p&gt;

&lt;p&gt;For example, I have specified my image as &lt;code&gt;nginxxx&lt;/code&gt; . Let’s check the pod status by running &lt;code&gt;kubectl get pods&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;controlplane &lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods
NAME     READY   STATUS         RESTARTS   AGE
my-pod   0/1     ErrImagePull   0          13s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ImagePullBackOff
&lt;/h3&gt;

&lt;p&gt;ImagePullBackOff is the waiting status, a grace period with increasing time for every retry. Once this grace period completes, Kubernetes pulls the image again. Maximum backoff time is of five minutes.&lt;/p&gt;

&lt;p&gt;So let’s try seeing the pod status again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;controlplane &lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods
NAME     READY   STATUS             RESTARTS   AGE
my-pod   0/1     ImagePullBackOff   0          2m43s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can get more information about the issues and retries by &lt;code&gt;kubectl decsribe pod/&amp;lt;your-podname&amp;gt;&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;controlplane &lt;span class="nv"&gt;$ &lt;/span&gt;kubectl describe pod/my-pod 
Name:             my-pod
Namespace:        default
&lt;span class="nt"&gt;--------------------------&lt;/span&gt;
Status:           Pending
IP:               192.168.1.3
IPs:
  IP:  192.168.1.3
Containers:
  my-pod:
    Container ID:   
    Image:          nginxxx
    Image ID:       
    Port:           &amp;lt;none&amp;gt;
    Host Port:      &amp;lt;none&amp;gt;
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
&lt;span class="nt"&gt;---------------------------&lt;/span&gt;
Events:
  Type     Reason     Age                    From               Message
  &lt;span class="nt"&gt;----&lt;/span&gt;     &lt;span class="nt"&gt;------&lt;/span&gt;     &lt;span class="nt"&gt;----&lt;/span&gt;                   &lt;span class="nt"&gt;----&lt;/span&gt;               &lt;span class="nt"&gt;-------&lt;/span&gt;
  Normal   Scheduled  5m18s                  default-scheduler  Successfully assigned default/my-pod to node01
  Normal   Pulling    3m26s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 5m18s&lt;span class="o"&gt;)&lt;/span&gt;  kubelet            Pulling image &lt;span class="s2"&gt;"nginxxx"&lt;/span&gt;
  Warning  Failed     3m20s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 5m12s&lt;span class="o"&gt;)&lt;/span&gt;  kubelet            Failed to pull image &lt;span class="s2"&gt;"nginxxx"&lt;/span&gt;: rpc error: code &lt;span class="o"&gt;=&lt;/span&gt; Unknown desc &lt;span class="o"&gt;=&lt;/span&gt; failed to pull and unpack image &lt;span class="s2"&gt;"docker.io/library/nginxxx:latest"&lt;/span&gt;: failed to resolve reference &lt;span class="s2"&gt;"docker.io/library/nginxxx:latest"&lt;/span&gt;: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
  Warning  Failed     3m20s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 5m12s&lt;span class="o"&gt;)&lt;/span&gt;  kubelet            Error: ErrImagePull
  Warning  Failed     3m5s &lt;span class="o"&gt;(&lt;/span&gt;x6 over 5m11s&lt;span class="o"&gt;)&lt;/span&gt;   kubelet            Error: ImagePullBackOff
  Normal   BackOff    4s &lt;span class="o"&gt;(&lt;/span&gt;x19 over 5m11s&lt;span class="o"&gt;)&lt;/span&gt;    kubelet            Back-off pulling image &lt;span class="s2"&gt;"nginxxx"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The events section shows details about the issue that happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common causes for ErrImagePull and ImagePullBackOff&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pod Spec provides the wrong registry name- resolve it by editing the pod specification and providing the correct registry&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pod Spec mentioned the wrong image name — we can resolve it by providing the correct image in the pod spec.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Invalid image tag in Pod Spec — we can resolve it by giving the correct image tag. If not provided, by default it will be labeled as the latest. If the image doesn’t contain the latest tag, you must provide a valid tag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Authentication issue while accessing registry — Resolve it by providing correct secrets to the image registry. Add the secret reference in the Pod spec.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The container registry is not accessible- we can fix the issue by restoring the network connection and allowing the pod to retry pulling the image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And those are just some of there might be more reasons why kubelet is not able to pull the image.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For troubleshooting these errors, your best friend is &lt;code&gt;kubectl describe pod/&amp;lt;yourpodname&amp;gt;&lt;/code&gt; .&lt;/p&gt;




&lt;p&gt;That’s a wrap!!!&lt;/p&gt;

&lt;p&gt;Hope you learned something. Let me know your feedback and if you have any suggestions or questions, you can connect with me on &lt;a href="https://twitter.com/__karnati" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Till next,&lt;/p&gt;

&lt;p&gt;Happy kubectl’ing&lt;/p&gt;

</description>
      <category>offers</category>
      <category>marketing</category>
      <category>webperf</category>
    </item>
    <item>
      <title>What happens when you create a pod?</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Sun, 15 Jan 2023 06:04:58 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/what-happens-when-you-create-a-pod-1ab3</link>
      <guid>https://dev.to/karnatisrinivas/what-happens-when-you-create-a-pod-1ab3</guid>
      <description>&lt;p&gt;A pod is the smallest deployable unit that you can create and manage in Kubernetes.&lt;/p&gt;

&lt;p&gt;But how to create a pod, is just as simple as running &lt;code&gt;kubectl run my-pod --image=nginx&lt;/code&gt; . But this simple task undergoes a complicated workflow that touches a lot of components in the cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So what happens exactly,&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First things first, you need to tell the &lt;strong&gt;API server&lt;/strong&gt; that you need a pod to be created. So you use kubectl it to send YAML (pod manifest) to the API. API server receives the request and saves the definition to the database which is default etcd.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;etcd&lt;/strong&gt; is the key value store in Kubernetes that stores the entire state of the cluster. Now we have asked API Server to create a pod, so etcd will now store the Pod. At this point, Pod is stored in etcd. And it will be in the pending state now.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now &lt;strong&gt;Scheduler&lt;/strong&gt; sees the pending state and checks the nodes to make the decision to schedule the pod to the node. No pod is created until now, it just schedules the pod to a node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On each worker node, we have a &lt;strong&gt;kubelet&lt;/strong&gt; which is more of an interface between the control plane and components in the worker node. The kubelet is the scheduled node now retrieves the pod template and starts creating it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The kubelet now asks &lt;strong&gt;CRI (container runtime interface)&lt;/strong&gt; to create a container (one which our pod def contains).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The kubelet also asks &lt;strong&gt;CNI ( container network interface)&lt;/strong&gt; to attach the container to the network. Now CNI assigns an IP address to the POD.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, kubelet checks any probes that are defined.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we have an IP address at which our pod is running. The last job of the kubelet is to report back to the Control plane. So Kubelet reports the IP address to the control Plane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The POD is now created and is finally marked as &lt;strong&gt;running.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This shows the high-level workflow of what pod creation goes through, but please note these steps might have missed some minute details.&lt;/p&gt;







&lt;p&gt;That's a wrap!!!&lt;/p&gt;

&lt;p&gt;Hope you learned something. Let me know your feedback and if you have any suggestions or questions, you can connect with me on &lt;a href="https://twitter.com/__karnati" rel="noopener noreferrer"&gt;Twitter.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Till next,&lt;br&gt;
Happy kubectl'ing&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
      <category>discuss</category>
      <category>learning</category>
    </item>
    <item>
      <title>Kubernetes Objects</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Mon, 04 Apr 2022 04:35:24 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/kubernetes-objects-4npf</link>
      <guid>https://dev.to/karnatisrinivas/kubernetes-objects-4npf</guid>
      <description>&lt;p&gt;Kubernetes objects are different types of entities provided by Kubernetes for deploying, maintaining, and scaling applications either on cloud or on-premise infrastructure. In this post we will go through different kubernetes objects that we'll use in our applcation deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pods
&lt;/h2&gt;

&lt;p&gt;A pod is the most basic object that you can create in an Kubernetes cluster. It usually contains one or more running containers. Containers in a pod share the same network, storage, and lifecycle. What this means is that they can communicate with each other directly, and will both be stopped and started at the same time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pod Definition&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: my-first-pod
  labels:
    name: my-first-pod
    app: nginx-app
spec:
  containers:
     - image: nginx
        name: nginx-app
        ports:
           - containerPort: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down the yaml definition we've just used, as we will be using similar definition in other objects definitions as well.  And also try to understand this definition file will do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;apiVersion:&lt;/strong&gt;  This definies which version of the Kubernetes API you're using to create this object. There are several versions, and several objects are introduced with each version. Some common ones are v1, apps/v1, and extensions/v1beta1. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--19GCPWsg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.bogotobogo.com/DevOps/Docker/images/Docker-Kubeernetes-Pods-Services/kind-apiVersion.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--19GCPWsg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.bogotobogo.com/DevOps/Docker/images/Docker-Kubeernetes-Pods-Services/kind-apiVersion.png" alt="api versions for different configs" width="813" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kind:&lt;/strong&gt; This is the type of Kubernetes object. In this example we’re creating a pod. (so Pod)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Metadata:&lt;/strong&gt; The metadata is the information about the object. The metadata usually contains the name you want to give the object , the labels etc. For the labels, you can define as many labels as you want like name, app, owner, group, tier etc,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spec:&lt;/strong&gt; The spec section is where you define the specifications of your object (the desired state of the object). In the case of a pod, it’s where you describe the state of your container. Some options you can specify in the spec section are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container:&lt;/strong&gt; Here you specify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The image that you want to run in your pod&lt;/li&gt;
&lt;li&gt;The name of the container that you’ll run in your pod.&lt;/li&gt;
&lt;li&gt;The ports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's create the Pod with our pod-definition.yaml file: &lt;/p&gt;

&lt;p&gt;Now go to your terminal, make sure you’re in the directory where you created your file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f pod-definition.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will create the pod with nginx image as defined in the pod-definition file. and you can view the Pods by using &lt;code&gt;kubectl get pods&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  ReplicaSet
&lt;/h2&gt;

&lt;p&gt;The ReplicaSet is used to create multiple copies of the same pod in a Kubernetes cluster. It helps ensure that at any given time, the desired number of pods specified are in the running state. &lt;/p&gt;

&lt;p&gt;ReplicaSet helps bring up a new instance of a Pod when the existing one fails, scale it up when the running instances are not up to the specified number, and scale down or delete Pods if another instance with the same label is created. A ReplicaSet ensures that a specified number of Pod replicas are running continuously and helps with load-balancing in case of an increase in resource usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ReplicaSet Definition&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: myapp-replicaset
  labels:
    app: myapp
    tier: frontend
spec:
  replicas: 2
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      labels:
        tier: frontend
    spec:
      containers:
      - name: nginx-app
        image: nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create ReplicaSet, go to your terminal and run the following command with your YAML Definition file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f ReplicaSet-definition.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the ReplicatSet is running, you can check its status using &lt;code&gt;kubectl get replicaset &amp;lt;your-replicaset-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;p&gt;Deployments are Kubernetes objects that are used for managing pods. The first thing a Deployment does when it’s created is to create a replicaset. The replicaset creates pods according to the number specified in the replica option. If you look at the YAML definition for the Deployment below, you’ll notice that the spec section of the deployment looks just like the definition for a replicaset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
  labels:
    app: mongo
spec:
  replicas: 2
  selector:
    matchLabels:
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
      - name: mongo
        image: mongo

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So when you create a Deployment, it will create a Replicaset with the pods mentioned in definition.&lt;br&gt;
Deployments can be used to scale your application by increasing the number of running pods, or update the running application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f Deployment-definition.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can view the Deployments with &lt;code&gt;kubectl get deployments&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Namespace
&lt;/h2&gt;

&lt;p&gt;Namespaces are used to organize objects in a Kubernetes cluster. They enable you to group resources together and perform actions on those resources. &lt;/p&gt;

&lt;p&gt;To see all the namespaces in you environment , use &lt;code&gt;kubectl get namespaces&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Creating a Namespace can be done with a single command. If you wanted to create a Namespace called ‘testing’ you would run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create namespace testing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can create a namespace using YAML Definition, as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Namespace
metadata:
  name: testing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have created a namespace, but how do we create the objects in the newly created namespace. For that you need to reference the namespace in the definition file/command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: myPod
  namespace: testing
  labels:
    name: namespaced-pod
spec:
    containers:
      - image: hello-world
         name: firstpod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Service
&lt;/h2&gt;

&lt;p&gt;Kubernetes Service is used to expose an application deployed on a set of pods using a single endpoint. Service enables network access to a set of Pods in Kubernetes.&lt;/p&gt;

&lt;p&gt;A service in Kubernetes can be created via an API request by passing in a service definition such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: myApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example the service is named my-service and will target TCP port 9376 on any pod with the metadata label "app=MyApp" . Kubernetes constantly evaluates the service’s label selector to determine at any given moment which pods are included in the service. This means that a new service can include existing pods that already match the label selector.&lt;/p&gt;

&lt;h3&gt;
  
  
  Service Types
&lt;/h3&gt;

&lt;p&gt;The default and simplest service type is &lt;code&gt;ClusterIP&lt;/code&gt; . It exposes the service’s ClusterIP address internally to the Kubernetes cluster.  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;NodePort&lt;/code&gt; – exposes the service on the specified port number, on all nodes in the Kubernetes cluster. Meaning that an incoming request to a node’s IP on the specified port will get routed to the service’s ClusterIP .&lt;/p&gt;

&lt;p&gt;&lt;code&gt;LoadBalancer&lt;/code&gt; – service is exposed like in NodePort but creates a load balancer in the cloud where Kubernetes is running (if supported by the cloud provider) that receives external requests to the service. It then distributes them among the cluster nodes using NodePort. To specify this type add this line to the spec:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type: LoadBalancer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>cloudnative</category>
    </item>
    <item>
      <title>15 Docker Commands you should know</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Tue, 08 Mar 2022 06:19:44 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/15-docker-commands-you-should-know-5hd4</link>
      <guid>https://dev.to/karnatisrinivas/15-docker-commands-you-should-know-5hd4</guid>
      <description>&lt;p&gt;Docker is a containerization system which packages and runs the application with its dependencies inside a container.  In this article, I mentioned about 18 Docker Commands you need to know while working with Docker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. docker --version&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the first things we all want to know is how to find the installed docker version.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VTaKpdGa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718330094/ytrR5AUUC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VTaKpdGa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718330094/ytrR5AUUC.png" alt="Screenshot 2022-03-08 at 11.15.10 AM.png" width="820" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. docker pull&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The 'docker pull' is a Docker command to download a Docker image or a repository locally on the host from a public or private registry. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qCcEetKz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718385983/UPXJnkLnv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qCcEetKz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718385983/UPXJnkLnv.png" alt="Screenshot 2022-03-08 at 11.16.15 AM.png" width="880" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. docker images&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;List all the docker images pulled on the system with image details such as TAG/IMAGE ID/SIZE etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nqIaUdGW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718418269/p9PELX28z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nqIaUdGW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718418269/p9PELX28z.png" alt="Screenshot 2022-03-08 at 11.16.48 AM.png" width="880" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. docker run&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The docker run command creates a container from a given image and starts the container using a given command. It is one of the first commands you should become familiar with when starting to work with Docker.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--91L93_Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718453863/YwSF62RqP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--91L93_Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718453863/YwSF62RqP.png" alt="Screenshot 2022-03-08 at 11.17.23 AM.png" width="880" height="573"&gt;&lt;/a&gt;&lt;br&gt;
If the image is not present locally, docker first pulls the image from the repository and runs it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C7g22e31--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718506497/tNMxO_LnC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C7g22e31--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718506497/tNMxO_LnC.png" alt="Screenshot 2022-03-08 at 11.18.15 AM.png" width="880" height="222"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;5. docker ps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;docker ps command lists all the docker containers are running with container details. To list all the docker containers running/exited/stopped with container details, we use docker &lt;code&gt;ps -a&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5rIl7VXG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718555532/Ua1PF19oO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5rIl7VXG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718555532/Ua1PF19oO.png" alt="Screenshot 2022-03-08 at 11.18.52 AM.png" width="880" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. docker start/ stop/restart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;docker start command in docker starts the docker container with container id mentioned in the command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--668zJnke--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718883587/omM3cluyJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--668zJnke--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718883587/omM3cluyJ.png" alt="Screenshot 2022-03-08 at 11.24.31 AM.png" width="848" height="174"&gt;&lt;/a&gt;&lt;br&gt;
docker stop stops a container with container id mentioned in the command. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DpZk0Zzx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718912987/aqro1yVNM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DpZk0Zzx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718912987/aqro1yVNM.png" alt="Screenshot 2022-03-08 at 11.25.00 AM.png" width="680" height="162"&gt;&lt;/a&gt;&lt;br&gt;
To restart the docker container, we use docker restart.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OwSaMEU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718937274/uZ78J_ZHh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OwSaMEU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718937274/uZ78J_ZHh.png" alt="Screenshot 2022-03-08 at 11.25.27 AM.png" width="680" height="190"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;7. docker rm&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Remove the docker container with container id mentioned in the command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JPF_T6Jh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718995370/QhDRTajFy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JPF_T6Jh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646718995370/QhDRTajFy.png" alt="Screenshot 2022-03-08 at 11.26.21 AM.png" width="880" height="169"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;8. docker rmi&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Remove the docker image with the docker image id mentioned in the command&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pOQVKdQa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719046660/tK3n-SJ_c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pOQVKdQa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719046660/tK3n-SJ_c.png" alt="Screenshot 2022-03-08 at 11.27.13 AM.png" width="880" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. docker commit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a new image from a container’s changes. It can be useful to commit a container’s file changes or settings into a new image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HIZJZLlt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719267842/VUzElNDLC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HIZJZLlt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719267842/VUzElNDLC.png" alt="Screenshot 2022-03-08 at 11.30.56 AM.png" width="880" height="114"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;10. docker login&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Login into docker hub. You will be asked your docker hub credentials to log in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hjRPBvDZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719306601/eX7RrowWF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hjRPBvDZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719306601/eX7RrowWF.png" alt="Screenshot 2022-03-08 at 11.31.33 AM.png" width="880" height="163"&gt;&lt;/a&gt;&lt;br&gt;
I already had my credentials setup, so it didn't ask me to enter login id and password. &lt;br&gt;
&lt;strong&gt;11. docker push&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Upload a docker image with the image name mentioned in the command on the dockerhub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6QGen_Ev--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719455889/4b_68PEWv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6QGen_Ev--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719455889/4b_68PEWv.png" alt="Screenshot 2022-03-08 at 11.31.33 AM.png" width="880" height="163"&gt;&lt;/a&gt;&lt;br&gt;
Once it is successful, you would be able to see the docker image in your docker hub repo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y0fRdpKC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719494374/_eXD1cgCl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y0fRdpKC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719494374/_eXD1cgCl.png" alt="Screenshot 2022-03-08 at 11.34.06 AM.png" width="880" height="98"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;12. docker info&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Get detailed information about docker installed on the system including the kernel version, number of containers and images, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NLzRa197--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719530324/4tI3n2I-k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NLzRa197--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719530324/4tI3n2I-k.png" alt="Screenshot 2022-03-08 at 11.35.18 AM.png" width="880" height="891"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;13. docker history&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shows the history of a docker image with the image name mentioned in the command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0lYhlDaq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719729466/14yeRnox-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0lYhlDaq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719729466/14yeRnox-.png" alt="Screenshot 2022-03-08 at 11.37.10 AM.png" width="880" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. docker search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Search for a docker image on dockerhub with the name mentioned in the command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M8Eo-CRK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719917955/vuZSC4Q2-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M8Eo-CRK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719917955/vuZSC4Q2-.png" alt="Screenshot 2022-03-08 at 11.41.43 AM.png" width="880" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. docker logout&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logging out from dockerhub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6nDY6l0F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719949918/vQ81R31Z7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6nDY6l0F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646719949918/vQ81R31Z7.png" alt="Screenshot 2022-03-08 at 11.42.17 AM.png" width="880" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with me on
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/srinivas-karnati"&gt;&lt;br&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--imBRhTaX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/LinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite" width="107" height="28"&gt; &lt;br&gt;
 &lt;/a&gt; &lt;br&gt;
&lt;a href="https://twitter.com/__karnati"&gt;&lt;br&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--opAxX3tY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Twitter-1DA1F2%3Fstyle%3Dfor-the-badge%26logo%3Dtwitter%26logoColor%3Dwhite" width="100" height="28"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>cloud</category>
      <category>azure</category>
    </item>
    <item>
      <title>Getting Started with Azure CLI</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Fri, 04 Mar 2022 14:41:00 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/getting-started-with-azure-cli-53lo</link>
      <guid>https://dev.to/karnatisrinivas/getting-started-with-azure-cli-53lo</guid>
      <description>&lt;h3&gt;
  
  
  What is Azure CLI?
&lt;/h3&gt;

&lt;p&gt;The Azure Command-Line Interface (CLI) is a command-line tool which connect to Azure and execute administrative commands on Azure resources. It allows the execution of commands through a terminal using interactive command-line prompts or a script.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to install the Azure CLI on Macos?
&lt;/h3&gt;

&lt;p&gt;Azure CLI is available to install in Windows, macOS and Linux environments. It can also be run in a Docker container and Azure Cloud Shell.&lt;/p&gt;

&lt;p&gt;We can install Azure CLI on MacOS using &lt;strong&gt;Homebrew package manager&lt;/strong&gt;. Homebrew makes it easy to keep your installation of the CLI update to date. It is always a best practice to update the homebrew first and install the packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew update 
brew install azure-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the dependencies are installed, you can check the version of Azure CLI using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sign into Azure CLI
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To sign into the Azure, Run the &lt;code&gt;login&lt;/code&gt; command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the CLI can open your default browser, it will do so and load an Azure sign-in page.&lt;/p&gt;

&lt;p&gt;Otherwise, open &lt;a href="https://aka.ms/devicelogin"&gt;https://aka.ms/devicelogin&lt;/a&gt; on your browser and enter the authorization code displayed in your terminal.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign in with your account credentials in the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Azure CLI Examples
&lt;/h4&gt;

&lt;p&gt;To see subscriptions in your Azure account, we can use &lt;code&gt;account&lt;/code&gt; as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az account list 

\\ We can also use account show

az account show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see resources that are created in your azure account, we can use &lt;code&gt;resource&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az resource list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;--help&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;To search for commands, use &lt;code&gt;az find&lt;/code&gt;. For example, to search for command names containing network, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az find network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the &lt;code&gt;--help&lt;/code&gt; argument to get a complete list of commands and subgroups of a group. For example, to find the CLI commands for working with &lt;code&gt;account&lt;/code&gt; we use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az account --help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a Virtual Network using Azure CLI
&lt;/h3&gt;

&lt;p&gt;Virtual networks (VNets) is something that allows Azure resources to communicate securely with each other. VNets can also be connected to other VNets if their address ranges don't overlap. &lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;az network vnet create&lt;/code&gt; command to create a virtual network named &lt;strong&gt;VNet1&lt;/strong&gt; with address prefix of 10.1.0.0/16 and a subnet named Subnet1 with address prefix of 10.1.1.0/24.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az network vnet create \
 --name "vnet1" \
--resource-group "my_learning" \
--address-prefixes 10.1.0.0/16 
--subnet-name "subnet1" \
--subnet-prefixes 10.1.1.0/24

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use shell variables to pass the values like as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
vnetName=vnet1
subnetName=subnet1
vnetAddressPrefix=10.1.0.0/16
subnetAddressPrefix=10.1.1.0/24

az network vnet create \
  --name $vnetName \
  --resource-group $resourceGroup \
  --address-prefixes $vnetAddress \
  --subnet-name $subnetName \
  --subnet-prefixes $subnetAddress

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run the commands mentioned earlier, upon successful execution you will be able to see the vnet created in the resources list.&lt;/p&gt;

&lt;p&gt;In the Terminal :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b5_W4WMb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646401992490/LyYPimjf-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b5_W4WMb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646401992490/LyYPimjf-.png" alt="Screenshot 2022-03-04 at 7.21.22 PM.png" width="880" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Portal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6RKGIke---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646402010868/MRQ1v5Uav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6RKGIke---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646402010868/MRQ1v5Uav.png" alt="Screenshot 2022-03-04 at 7.23.20 PM.png" width="880" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Virtual Machine (VM) using CLI
&lt;/h3&gt;

&lt;p&gt;We use the &lt;code&gt;az vm create&lt;/code&gt; command to create a new virtual machine running Ubuntu, which uses SSH authentication for login, and is connected to the subnet and VNet we created just now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az vm create --name "myVM1" --resource-group "my_learning" 
--image UbuntuLTS --vnet-name "vnet1" 
--subnet "subnet1" --generate-ssh-keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upon successfull execution, you should be able to see the following output which displays all information you need to access the VM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H2ZzTbMG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646402658242/AA2lXUhCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H2ZzTbMG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646402658242/AA2lXUhCQ.png" alt="Screenshot 2022-03-04 at 7.34.06 PM.png" width="880" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Confirm that the VM is running by connecting over SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh &amp;lt;public IP address&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go ahead and log out from the VM by typing exit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UQpMnCab--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646402822512/eL-xYcgrT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UQpMnCab--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646402822512/eL-xYcgrT.png" alt="Screenshot 2022-03-04 at 7.36.52 PM.png" width="880" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Always Clean up the resources which are not in use to save billing costs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;**Connect with me on: *&lt;/em&gt;*&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/srinivas-karnati"&gt;&lt;br&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--imBRhTaX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/LinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite" width="107" height="28"&gt; &lt;br&gt;
 &lt;/a&gt; &lt;br&gt;
&lt;a href="https://twitter.com/__karnati"&gt;&lt;br&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--opAxX3tY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Twitter-1DA1F2%3Fstyle%3Dfor-the-badge%26logo%3Dtwitter%26logoColor%3Dwhite" width="100" height="28"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

</description>
      <category>azure</category>
      <category>cloud</category>
      <category>devops</category>
      <category>cloudskills</category>
    </item>
    <item>
      <title>Network Security Groups In Azure</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Mon, 28 Feb 2022 14:12:47 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/network-security-groups-in-azure-mfd</link>
      <guid>https://dev.to/karnatisrinivas/network-security-groups-in-azure-mfd</guid>
      <description>&lt;h3&gt;
  
  
  Network Security Group
&lt;/h3&gt;

&lt;p&gt;An Azure Network Security Group (NSG) is a core component of Azure’s security. You can use an Azure network security group to filter network traffic to and from Azure resources in an Azure virtual network. Network (VNet). &lt;/p&gt;

&lt;p&gt;A network security group contains security rules that &lt;strong&gt;allow or deny&lt;/strong&gt; inbound network traffic to, or outbound network traffic from, several types of Azure resources. For each rule, you can specify source and destination, port, and protocol.&lt;/p&gt;

&lt;p&gt;Each rule in a NSG specifies the following properties:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;A unique name within the network security group.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Priority&lt;/td&gt;
&lt;td&gt;A number between 100 and 4096. Rules are processed in priority order, with lower numbers processed before higher numbers, because lower numbers have higher priority. Once traffic matches a rule, processing stops. As a result, any rules that exist with lower priorities (higher numbers) that have the same attributes as rules with higher priorities are not processed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source/Destination&lt;/td&gt;
&lt;td&gt;This setting defines the source or destination of the network traffic. It can be set to “Any” for traffic from anywhere, or you could lock it down to a single IP address or an IP range.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Protocol&lt;/td&gt;
&lt;td&gt;TCP, UDP, ICMP, ESP, AH, or Any.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Direction&lt;/td&gt;
&lt;td&gt;This setting defines the direction of the network traffic, and you can set it to either Inbound or Outbound.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Port Range&lt;/td&gt;
&lt;td&gt;The port range setting describes the port or port range of the rule. You can specify a single port, e.g., 443, or a range of ports, e.g., 1000-2000.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Action&lt;/td&gt;
&lt;td&gt;This setting defines what action needs to be done, "Allow" or "Deny"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Default Security rules:
&lt;/h3&gt;

&lt;p&gt;When you create an Azure NSG, Azure creates the following default rules in each network security group.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IeHqwVtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646046222227/PZLU6TABT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IeHqwVtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646046222227/PZLU6TABT.png" alt="Screenshot 2022-02-28 at 4.33.31 PM.png" width="880" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Azure Network security groups execute rules in order of priority, with the lower numbered priorities processed before high numbers. &lt;/p&gt;

&lt;h4&gt;
  
  
  Create a Network security group
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;On the Azure Portal, select Create a resource -&amp;gt; Networking -&amp;gt; Network Security Group&lt;/li&gt;
&lt;li&gt;In the Create network security group page, under the Basics tab, set values for the following settings:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Subscription&lt;/td&gt;
&lt;td&gt;Choose your subscription.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resource group&lt;/td&gt;
&lt;td&gt;Choose an existing resource group, or select Create new to create a new resource group.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;Enter a unique text string within a resource group.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Region&lt;/td&gt;
&lt;td&gt;Choose the location you want.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Select Review + create.&lt;/li&gt;
&lt;li&gt;After you see the Validation passed message, select Create.
To view your network security groups. Search for and select &lt;strong&gt;Network security groups&lt;/strong&gt;. The list of network security groups appears for your subscription.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Create a security rule
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;In Azure Portal, Search for and select Network security groups. Select the name of the network security group you want to add a security rule to. In the network security group's menu bar, choose &lt;strong&gt;Inbound security rules&lt;/strong&gt; or &lt;strong&gt;Outbound security rules.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Select Add. Select or add values for the following settings, and then select OK:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BTIcZr8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646057197647/1_Akcogp2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BTIcZr8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646057197647/1_Akcogp2.png" alt="Screenshot 2022-02-28 at 7.36.14 PM.png" width="870" height="1348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xhDm_-9D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646057211570/hKEKcoJHV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xhDm_-9D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646057211570/hKEKcoJHV.png" alt="Screenshot 2022-02-28 at 7.36.26 PM.png" width="842" height="1354"&gt;&lt;/a&gt;&lt;br&gt;
*Source: MS Learn *&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Getting started with Azure Policies</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Tue, 22 Feb 2022 12:16:49 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/getting-started-with-azure-policies-e44</link>
      <guid>https://dev.to/karnatisrinivas/getting-started-with-azure-policies-e44</guid>
      <description>&lt;h2&gt;
  
  
  Azure Policy
&lt;/h2&gt;

&lt;p&gt;Azure Policy is a service in Azure which allows you create polices which enforce and control the properties of a resource. When these policies are used they enforce different rules and effects over your resources, so those resources stay compliant with your IT governance standard. Through its compliance dashboard, it provides an aggregated view to evaluate the overall state of the environment, with the ability to drill down to the per-resource, per-policy granularity.&lt;/p&gt;

&lt;p&gt;Azure Policy uses a JSON format to form the logic the evaluation uses to determine whether a resource is compliant or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Policy definition&lt;/strong&gt; is the conditions which you want controlled. There are built in definitions such as controlling what type of resources can be deployed to enforcing the use of tags on all resources. These are the business rules, described in JSON format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Policy assignment&lt;/strong&gt; is the scope of what the policy definition can take effect around. Scope of assignment can be assigned to a individual, resource, resource group or management group. Policy assignments are inherited by all child resources. &lt;/p&gt;

&lt;h3&gt;
  
  
  Azure Initiative
&lt;/h3&gt;

&lt;p&gt;An Azure initiative is a collection of Azure policy definitions that are grouped together towards a specific goal or purpose in mind. Azure initiatives simplify management of your policies by grouping a set of policies together as one single item. Sometimes also called as &lt;strong&gt;Policyset&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Assign a Policy
&lt;/h3&gt;

&lt;p&gt;To enforce the Complaince with Azure Policies , we need to assign the policy.  In this example, we assign the built-in policy definition called "Allowed locations" to ensure that resources are created in the specific region only.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Azure portal to assign policies. Search for and select Policy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k0OMWFf4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645530563974/JXj_Qlqb-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k0OMWFf4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645530563974/JXj_Qlqb-.png" alt="Screenshot 2022-02-22 at 4.53.23 PM.png" width="880" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Select Assignments on the left side of the Azure Policy page. An assignment is a policy that has been assigned to take place within a specific scope.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Assign Policy from the top of the Policy - Assignments page.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FEEHcuQ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645530590098/4Sbo8Wi88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FEEHcuQ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645530590098/4Sbo8Wi88.png" alt="Screenshot 2022-02-22 at 4.54.03 PM.png" width="880" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the &lt;strong&gt;Assign Policy&lt;/strong&gt; page and &lt;strong&gt;Basics&lt;/strong&gt; tab, select the Scope by selecting the ellipsis and selecting either a management group or subscription. Optionally, select a resource group. A scope determines what resources or grouping of resources the policy assignment gets enforced on. Then select Select at the bottom of the Scope page.&lt;/li&gt;
&lt;li&gt;Resources can be excluded based on the Scope. Exclusions start at one level lower than the level of the Scope. Exclusions are optional.&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;Policy definition&lt;/strong&gt; ellipsis to open the list of available definitions. You can filter the policy definition Type to Built-in to view all and read their descriptions.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Allowed locations&lt;/strong&gt;. If you it, type &lt;strong&gt;locations&lt;/strong&gt; into the search box and then press ENTER or select out of the search box. Select Select at the bottom of the Available Definitions page once you have found and selected the policy definition.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Assignment name&lt;/strong&gt; is automatically populated with the policy name you selected, but you can change it. Leave &lt;strong&gt;Policy enforcement&lt;/strong&gt; as Enabled.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aV0Qb3zu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645530966455/NzV_EEmF-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aV0Qb3zu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645530966455/NzV_EEmF-.png" alt="Screenshot 2022-02-22 at 4.55.19 PM.png" width="880" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the Parameters tab at the top of the wizard.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Allowed locations&lt;/strong&gt;, you need to select the locations in which you want your resources to be created.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rh_AtDjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531049828/NAfeiXPuo.png" alt="Screenshot 2022-02-22 at 4.55.58 PM.png" width="880" height="450"&gt;
&lt;/li&gt;
&lt;li&gt;We will leave the rest of the values as default.&lt;/li&gt;
&lt;li&gt;Select the Review + create tab at the top of the wizard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lyPF14vT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531321455/kknv-71gv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lyPF14vT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531321455/kknv-71gv.png" alt="Screenshot 2022-02-22 at 4.56.14 PM.png" width="880" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Review your selections, then select Create at the bottom of the page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To &lt;strong&gt;test our Policy,&lt;/strong&gt; Let's create two logic apps one in US region and another in India.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To create a  logic apps, click on &lt;strong&gt;Add resource&lt;/strong&gt; -&amp;gt; Search for logic apps&lt;/li&gt;
&lt;li&gt;On the Basics tab, select Your subscription, Resource group, Region (here I selected South India).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d4cGuEFZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531458420/kp5coxD_k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d4cGuEFZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531458420/kp5coxD_k.png" alt="Screenshot 2022-02-22 at 4.57.48 PM.png" width="880" height="617"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I will leave all the remaining details as default, We will &lt;strong&gt;review and create&lt;/strong&gt; the Logic app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oc60QNZe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531612287/gHINQRXD7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oc60QNZe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531612287/gHINQRXD7.png" alt="Screenshot 2022-02-22 at 5.05.29 PM.png" width="880" height="888"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see the deployment is completed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VqikPV3D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531647405/WqrOs22Kk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VqikPV3D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531647405/WqrOs22Kk.png" alt="Screenshot 2022-02-22 at 5.06.52 PM.png" width="880" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repeat the same for the US region, the details of resource are as follows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jutnwjGk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531685077/kUb-HDHb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jutnwjGk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531685077/kUb-HDHb3.png" alt="Screenshot 2022-02-22 at 5.02.20 PM.png" width="880" height="927"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Though it is not allowed in Policy Definition, validation will be successful.&lt;/li&gt;
&lt;li&gt;Let's try to deploy the resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ceuLNLDD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531758248/lrLvUSU7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ceuLNLDD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645531758248/lrLvUSU7r.png" alt="Screenshot 2022-02-22 at 5.04.40 PM.png" width="880" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see the Deployment is failed due to "Disallowed by the Policy".&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>cloud</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>Create a Virtual Network on Azure</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Sun, 20 Feb 2022 05:45:12 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/create-a-virtual-network-on-azure-1cib</link>
      <guid>https://dev.to/karnatisrinivas/create-a-virtual-network-on-azure-1cib</guid>
      <description>&lt;h3&gt;
  
  
  What is Azure Virtual Network?
&lt;/h3&gt;

&lt;p&gt;Azure Virtual Network (VNet) is the bulding block for establishing your private network in Azure. VNet enables many types of Azure resources, such as Azure Virtual Machines (VM), to securely communicate with each other. VNet is similar to a traditional network that you'd operate in your own data center, but brings with it additional benefits of Azure's infrastructure such as scale, availability, and isolation.&lt;/p&gt;

&lt;p&gt;Azure virtual network enables Azure resources to communicate with each other. &lt;/p&gt;

&lt;p&gt;Key scenarios that you can accomplish with a virtual network include - communication of Azure resources with the internet, communication between Azure resources, communication with on-premises resources, filtering network traffic, routing network traffic, and integration with Azure services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Virtual Network using Azure Portal
&lt;/h3&gt;

&lt;p&gt;In this post, we will create a VNet ( Virtual network), we will add two subnets, and create two VMs, one in each subnet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Virtual network
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To access azure portal, go to &lt;a href="https://portal.azure.com"&gt;https://portal.azure.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;create resource&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Networking&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Virtual Network&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YAZ6032t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645330420395/j2B5WRK2Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YAZ6032t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645330420395/j2B5WRK2Z.png" alt="Screenshot 2022-02-20 at 7.15.15 AM.png" width="880" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In Create virtual network, enter or select this information in the Basics tab:

&lt;ul&gt;
&lt;li&gt;Subscription - Select your subscription.&lt;/li&gt;
&lt;li&gt;Resource group - Select your Resource group. ( or create new)&lt;/li&gt;
&lt;li&gt;Instance details - enter Name and the Region for your Vnet
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lsX0R_iL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645330828172/VYAkUPMUM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lsX0R_iL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645330828172/VYAkUPMUM.png" alt="Screenshot 2022-02-20 at 7.15.54 AM.png" width="880" height="605"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;strong&gt;IP Addresses&lt;/strong&gt; tab, or select the &lt;strong&gt;Next: IP Addresses button&lt;/strong&gt; at the bottom of the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In &lt;strong&gt;IPv4&lt;/strong&gt; address space, select the existing address space and change it to 10.1.0.0/16.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select &lt;strong&gt;+ Add&lt;/strong&gt; subnet, then enter Subnet name and 10.1.1.0/24 for Subnet address range.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Add.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repeat previous two steps to add one more subnet as follows:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B5cWOstV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645331142759/W9lV3AoTI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B5cWOstV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645331142759/W9lV3AoTI.png" alt="Screenshot 2022-02-20 at 7.18.14 AM.png" width="880" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We will leave the rest as default and select &lt;strong&gt;Review + Create&lt;/strong&gt;. Once the validation is passed, click on &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Once the deployment is completed, you will see your deployed Virtual Network on your resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_XuElmCb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645331298260/_GRBGeib-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_XuElmCb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645331298260/_GRBGeib-.png" alt="Screenshot 2022-02-20 at 7.19.35 AM.png" width="880" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Virtual Machines
&lt;/h3&gt;

&lt;p&gt;We will create two VMs in our virtual network:&lt;/p&gt;

&lt;h4&gt;
  
  
  Create the first VM
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;On the upper-left side of the portal, select Create a resource &amp;gt; Compute &amp;gt; Virtual machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In Create a virtual machine, type or select the values in the Basics tab:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subscription - Select your Azure subscription&lt;/li&gt;
&lt;li&gt;Resource Group    - Select the Resource group, you've created.&lt;/li&gt;
&lt;li&gt;Instance details
&lt;/li&gt;
&lt;li&gt;Virtual machine name  Enter name for your VM&lt;/li&gt;
&lt;li&gt;Region    Select the Region( I select South India)&lt;/li&gt;
&lt;li&gt;Availability Options  Select No infrastructure redundancy required&lt;/li&gt;
&lt;li&gt;Image     - I selected Ubuntu 20.04.&lt;/li&gt;
&lt;li&gt;Azure Spot instance   Select No&lt;/li&gt;
&lt;li&gt;Size  Choose VM size or take default setting&lt;/li&gt;
&lt;li&gt;Administrator account
&lt;/li&gt;
&lt;li&gt;Username  Enter a username&lt;/li&gt;
&lt;li&gt;Password  Enter a password&lt;/li&gt;
&lt;li&gt;Confirm password  Reenter password&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_MjvFr87--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645332191047/8Gjpr2RrK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_MjvFr87--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645332191047/8Gjpr2RrK.png" alt="Screenshot 2022-02-20 at 7.25.31 AM.png" width="816" height="1360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;strong&gt;Disks&lt;/strong&gt; tab, select the preferred disk type or leave defaults. &lt;/li&gt;
&lt;li&gt;In the Networking tab, select or enter:

&lt;ul&gt;
&lt;li&gt;Virtual network   - Select Vnet1 ( the name of Virtual network you created).&lt;/li&gt;
&lt;li&gt;Subnet    Select vnet1-subnet1 (The first subnet)&lt;/li&gt;
&lt;li&gt;Public IP     Leave the defaults &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jZJREcjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645332415369/Aspv_LwCq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jZJREcjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645332415369/Aspv_LwCq.png" alt="Screenshot 2022-02-20 at 7.26.46 AM.png" width="880" height="823"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select &lt;strong&gt;Review + Create&lt;/strong&gt;. You will be taken to Review page where Azure checks your VMs Configuration.&lt;/li&gt;
&lt;li&gt;Once the validation is passed, Select Create. Once the deployment is completed, you will see the VM in your resources list.
#### Create the Second VM
Repeat the above steps to create a New Virtual Machine with following Networking Configuration.&lt;/li&gt;
&lt;li&gt;Virtual Network - Vnet1&lt;/li&gt;
&lt;li&gt;Subnet - select vnet1-subnet2 ( second subnet)
Keep the rest as similar to first VM, and create the virtual machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Communicate between VMs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To Connect to your VM (vnet1-vm1), you can either use &lt;strong&gt;Connect&lt;/strong&gt; button, or you can access using public IP via SSH
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh username@IPaddress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;enter the username and password you created for the virtual machine previously.&lt;/li&gt;
&lt;li&gt;Once you are in the VM, enter &lt;code&gt;ping vnet1-vm2&lt;/code&gt; ( to check the second VM's reachability).
You'll receive a message similar to this output:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zg6m4kd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645333554373/cGUMEWHgX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zg6m4kd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645333554373/cGUMEWHgX.png" alt="Screenshot 2022-02-20 at 7.48.39 AM.png" width="880" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repeat the same steps for VM2 to test if VM1 is accessible or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xgBLNqm2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645333681618/PjvsMiTX2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xgBLNqm2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645333681618/PjvsMiTX2.png" alt="Screenshot 2022-02-20 at 7.50.11 AM.png" width="880" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>azure</category>
      <category>cloud</category>
      <category>devops</category>
      <category>cloudskills</category>
    </item>
    <item>
      <title>OSI Model and it's layers</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Sun, 20 Feb 2022 05:43:54 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/osi-model-and-its-layers-9cc</link>
      <guid>https://dev.to/karnatisrinivas/osi-model-and-its-layers-9cc</guid>
      <description>&lt;p&gt;A network  both contains hardware and software that sends data from one location to another. The end goal of the networking is to allow two devices share the data.&lt;/p&gt;

&lt;p&gt;The hardware part of networking, consists of physical equipment that carries signal from one point of the network to another. While the software consist of instructions sets that make possible the services that we expect from a network.&lt;/p&gt;

&lt;p&gt;The task of sending data from one point in the another can be performed by different layers in the network. &lt;/p&gt;

&lt;p&gt;There are two popular network models:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OSI Model&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TCP/IP&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In OSI Model, the rules for networking are divided into seven different layers.&lt;/p&gt;

&lt;h3&gt;
  
  
  OSI Model
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Open Systems Interconnection (OSI) Model&lt;/strong&gt; is an ISO standard that describes the functions of networking system.&lt;/p&gt;

&lt;p&gt;The OSI model is a layered architecture that allows communication between all types of computer systems regardless of their underlying architecture.&lt;/p&gt;

&lt;p&gt;In the OSI model, the communications between a computing system are divided into seven different  layers: &lt;strong&gt;Physical, Data Link, Network, Transport, Session, Presentation, and Application.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hrBsrd8s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644930430674/kIkbCbg-k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hrBsrd8s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644930430674/kIkbCbg-k.png" alt="application.png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Physical Layer
&lt;/h3&gt;

&lt;p&gt;The physical layer is the layer 1 of the OSI, responsible for sending bits from one computer to another through a physical medium. It deals with the setup of physical connection to the network and with transmission and reception of signals.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_IgT9vNu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644931554429/9_k3h2Y9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_IgT9vNu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644931554429/9_k3h2Y9w.png" alt="application(1).png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Functions of Physical Layer
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Representation of Bits&lt;/strong&gt; - defines how the stream of bits is encoded into signals for transmission i.e. how 0s and 1s are changes to signal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Rate&lt;/strong&gt; - defines the rate of transmission i.e. the number of bits sent per second.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Synchronization&lt;/strong&gt; - does the synchronization of bits by providing a clock. The clock controls both sender and receiver thus providing synchronization at a bit level. One bit is transmitted or received during each clock cycle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interface&lt;/strong&gt; - defines the transmission interface between devices and transmission medium. For example which electrical connectors and cables to use are defined by the physical layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Topologies&lt;/strong&gt; - defines the topology to use - bus, star, mesh, or ring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Transmission Modes&lt;/strong&gt; - defines the direction of transmission between two devices: Simplex(One-way communication), Half Duplex(Two-way communication but one at a time), Full Duplex(Two-way simultaneous communication).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Link Layer (DLL)
&lt;/h3&gt;

&lt;p&gt;The data link layer is responsible for the node to node(or hop to hope) delivery of the message. It makes sure data transfer is error-free from one node to another, over the physical layer. This is also where we introduce or first see MAC addresses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gHnj2hUk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644931564751/ZNjHOtVC6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gHnj2hUk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644931564751/ZNjHOtVC6.png" alt="application(2).png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Functions of the Data Link Layer:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Framing *&lt;/em&gt;- The data link layer divides the stream of bits received from the network layer into manageable data units called frames.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Physical Addressing&lt;/strong&gt; - After creating frames, DLL adds physical addresses(MAC address) of the sender and receiver in the header of each frame.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Control&lt;/strong&gt; - The Datalink layer adds reliability to the physical layer by adding mechanisms to detect and retransmit damaged or lost frames. It also uses a mechanism to recognize duplicate frames.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Access Control&lt;/strong&gt; - When two or more devices are connected to the same link, data link layer protocols are necessary to determine which device has control over the link at any given time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Network layer
&lt;/h3&gt;

&lt;p&gt;The network layer is responsible for receiving frames from the data link layer, and delivering them to their destinations among based on the addresses contained inside the frame. &lt;/p&gt;

&lt;p&gt;The network layer finds the destination by using logical addresses, such as IP (internet protocol). At this layer, routers are a crucial component used to quite literally route information where it needs to go between networks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--se6Bx6iF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644933397361/mBGxshVQC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--se6Bx6iF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644933397361/mBGxshVQC.png" alt="application(3).png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Functions of Network Layer:
&lt;/h4&gt;

&lt;p&gt;The network layer is responsible for the source to destination delivery of a packet across multiple networks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logical addressing&lt;/strong&gt; - Network layers allocate a unique address called IP address to the header of the packet to distinguish each device.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Routing&lt;/strong&gt; - The network layer determines which route is suitable from source to destination across multiple networks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Layer 2 MAC Address is introduced, but in Layer 3 IP address is introduced. The difference between MAC and IP address is that MAC Address is used to ensure the physical address of the computer. It uniquely identifies the devices on a network. &lt;br&gt;
While IP addresses are used to uniquely identifies the connection of the network with that device takes part in a network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transport Layer
&lt;/h3&gt;

&lt;p&gt;The transport layer is responsible for service to service delivery of the entire message.&lt;/p&gt;

&lt;p&gt;A Service is an application program running on a host. The network layer oversees source to destination delivery of individual packets, it does not recognize any relationship between those packets and treats them individually as though each piece belonged to a separate application, whether or not it does. The transport layer, on the other hand, ensures that the whole message arrives intact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4t3NOMU_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644934198525/HA9utLf3-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4t3NOMU_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644934198525/HA9utLf3-.png" alt="application(4).png" width="880" height="489"&gt;&lt;/a&gt;&lt;br&gt;
Functions of Transport Layer:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Port Addressing&lt;/strong&gt; - The transport layer header includes the port address(a 16-bit address allocated to every process) which delivers a message from a specific process on one computer to another process on another computer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Segmentation and Reassembly&lt;/strong&gt; - A message is divided into transmittable segments, with each segment containing a sequence number. The receiver transport layer uses these numbers to reassembles segments and replace packets that were lost in the transmission.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Connection Control&lt;/strong&gt; - The transport layer can be either connectionless or connection-oriented.&lt;/p&gt;
&lt;h3&gt;
  
  
  Session Layer
&lt;/h3&gt;

&lt;p&gt;The session later is responsible for dialog control and synchronization.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M7JSFd7u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644944535154/qUB6wvjFq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M7JSFd7u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644944535154/qUB6wvjFq.png" alt="application(5).png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Functions of Session Layer -
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;** Session maintainence**: The session layer is respnsible to establish, use and terminate a connection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dialog Control&lt;/strong&gt; - The session layer allows two systems to enter into a dialog. It allows the communication between two processes to take place in either half-duplex(one way at a time) or full-duplex(two ways at a time) mode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Synchronization&lt;/strong&gt; - The session layer allows a process to add synchronization points to a stream of data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Presentation layer
&lt;/h3&gt;

&lt;p&gt;The Presentation Layer deals with the syntax and semantics of the information transmitted between two systems. The Presentation Layer is responsible for translation, compression, and encryption.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---t0Ab4r1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644944545766/_POQLXclQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---t0Ab4r1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644944545766/_POQLXclQ.png" alt="application(6).png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Functions of Presentation Layer -
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Translation&lt;/strong&gt; - This Layer translates the exchanging information into a compatible format between the sender and receiver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Encryption&lt;/strong&gt; - The presentation Layer uses some algorithms for encrypting the information before sending it to the receiver, and decryption on the receiver side reverses the original process to transform the message back to its original form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compression&lt;/strong&gt; - Presentation Layer compresses the number of bits contained in the information using some algorithms. It maybe of either lossy or lossless compression.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Application Layer
&lt;/h3&gt;

&lt;p&gt;The application layer enables the user, whether human or software, to access the network. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mkBCEafB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644944553563/Gq79tk3YM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mkBCEafB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644944553563/Gq79tk3YM.png" alt="application(7).png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Overview of layers
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6GGiHNen--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.guru99.com/images/1/092119_0729_LayersofOSI1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6GGiHNen--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.guru99.com/images/1/092119_0729_LayersofOSI1.png" alt="overview" width="880" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>azure</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Automating user management with bash script</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Sun, 20 Feb 2022 05:42:50 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/automating-user-management-with-bash-script-46ie</link>
      <guid>https://dev.to/karnatisrinivas/automating-user-management-with-bash-script-46ie</guid>
      <description>&lt;p&gt;As a System administrator, creating users on multiple servers maybe something that you would do on a daily basis. It maybe an easy task to create a user on single server but imagine that you need to add a user on 100+ different Linux servers. Isn't it a tedious task? so let's create a bash script that automates it.&lt;/p&gt;

&lt;p&gt;First, let us create a text file that includes all the server hostnames or IP addresses where you wish to add the user.&lt;/p&gt;

&lt;p&gt;Here in this example, I've created a file &lt;strong&gt;servers.txt&lt;/strong&gt; that includes the servers names ( here I have two servers):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644813548350%2FlCVP-Y4t_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644813548350%2FlCVP-Y4t_.png" alt="Screenshot 2022-02-14 at 9.56.44 AM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now take a look at the following &lt;strong&gt;addusers.sh&lt;/strong&gt; bash script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
servers=$(cat servers.txt)
echo -n "Enter the username: "
read userName
echo -n "Enter the user id: "
read userID

for i in $servers; do
echo $i
ssh $i "sudo useradd -m -u $userID $userName"
if [ $? -eq 0 ]; then
echo "User $userName added on $i"
else
echo "Error on $i"
fi
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644813871353%2Fpg-5MZRgZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644813871353%2Fpg-5MZRgZ.png" alt="Screenshot 2022-02-14 at 9.57.11 AM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you run addusers.sh, the script will first ask you to enter the username and the user id of the user who you want to add; then, it will loop over and connect to all the servers in the servers.txt file via SSH and add the requested user.&lt;/p&gt;

&lt;p&gt;Let's run the &lt;strong&gt;addusers.sh&lt;/strong&gt; script and see how it executes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644814387804%2Fh3VyLEmBEP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644814387804%2Fh3VyLEmBEP.png" alt="Screenshot 2022-02-14 at 10.22.49 AM.png"&gt;&lt;/a&gt;&lt;br&gt;
If you haven't enabled password-less login via SSH, it will prompt to enter the password to gain access to server. &lt;/p&gt;

&lt;p&gt;The script ran successfully and testuser2 account was created on the two servers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must have a valid account that has super user access on all the servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a beginner to Bash Scripting, I found it really impressive to know that with bash scripting you can automate many boring, tedious task in Linux!&lt;/p&gt;

</description>
      <category>bash</category>
      <category>cloud</category>
      <category>linux</category>
    </item>
    <item>
      <title>Basics Of Bash Scripting</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Sun, 20 Feb 2022 05:41:44 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/basics-of-bash-scripting-4gc8</link>
      <guid>https://dev.to/karnatisrinivas/basics-of-bash-scripting-4gc8</guid>
      <description>&lt;h2&gt;
  
  
  What is a Shell
&lt;/h2&gt;

&lt;p&gt;The shell is a computer program, it takes each command and passes it to the operating system kernel to be executed. It then displays the results of this operation on your screen.&lt;br&gt;
Different systems may use different shells. The most commonly available shells are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bourne shell (sh)&lt;/li&gt;
&lt;li&gt;Bourne Again Shell (bash)&lt;/li&gt;
&lt;li&gt;C shell (csh)&lt;/li&gt;
&lt;li&gt;Z Shell (zsh)&lt;/li&gt;
&lt;li&gt;Korn shell (ksh)
by using &lt;code&gt;cat /etc/shells&lt;/code&gt;, We can see the list of available shells in our Linux system.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Shell Script
&lt;/h2&gt;

&lt;p&gt;A shell script is a file that contains a list of commands that are executed sequentially by the Unix shell. The main components of a Shell Script are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shebang ( #!/bin/bash) &lt;/li&gt;
&lt;li&gt;Comments (starts with #)&lt;/li&gt;
&lt;li&gt;Actual Commands of Linux( ls, cd, mkdir, chmod etc...)&lt;/li&gt;
&lt;li&gt;Statements ( If, for , while etc.,)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to execute, the shell script file need to have executable permissions. &lt;/p&gt;

&lt;p&gt;Sample Shell Script :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
# script to print - Hello World!
echo "Hello World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is a basic script, that prints hello world to the terminal. Here the first line is called as "shebang" which tells the shell to run the file as bash script. The second line is a comment which is ignored while execution. And the &lt;code&gt;echo&lt;/code&gt; command which print the stdout to terminal screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uVKhj0p3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644637675174/E-nZxpc79.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uVKhj0p3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644637675174/E-nZxpc79.png" alt="Screenshot 2022-02-12 at 9.17.35 AM.png" width="880" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can execute the script either by Bash source, or execute it as a shell-script by making it executable (using &lt;code&gt;chmod&lt;/code&gt;) from the path. &lt;/p&gt;

&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;p&gt;We all know,  we need variables to store some value which we are gonna use repeatedly. Bash has variables using which you can store values. Let's create and use some variables in Bash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
name = srinivas
echo $name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a variable, we simply write the variable name and assign the value to the variable. To access the variable add $ sign before the variable name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bXK32LgY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644638396480/AFAewUdRL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bXK32LgY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644638396480/AFAewUdRL.png" alt="Screenshot 2022-02-12 at 9.27.48 AM.png" width="880" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conditional statements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  If Statement
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if COMMAND_TO_TEST
then
  STATEMENTS
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; statement starts with the 'if' keyword followed by the conditional expression and the then keyword. The statement ends with the &lt;code&gt;fi&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;If the COMMAND_TO_TEST evaluates to True, the STATEMENTS gets executed. If COMMAND_TO_TESTreturns False, nothing happens; the STATEMENTS get ignored.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

echo -n "Enter a number: "
read number

if [[ $number -gt 100 ]]
then
  echo "The variable is greater than 100."
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script will prompt you to enter a number. When you enter 120, the test command will evaluate to true because 120 is greater than 100, and the echo command inside the then clause will be executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cwslkp6D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644674115890/jT4kRRgPx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cwslkp6D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644674115890/jT4kRRgPx.png" alt="Screenshot 2022-02-12 at 7.24.10 PM.png" width="880" height="401"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;-gt&lt;/code&gt; in the script is numeric comparison - greater than. The following table lists comparison operators for both numbers and strings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dRw4UVh---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644674222334/YGrfECDXa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dRw4UVh---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644674222334/YGrfECDXa.png" alt="Screenshot 2022-02-12 at 7.26.49 PM.png" width="880" height="262"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  if...else Statement
&lt;/h3&gt;

&lt;p&gt;The Bash if..else statement takes the following form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if COMMAND_TO_TEST
then
  STATEMENTS1
else
  STATEMENTS2
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the COMMAND_TO_TEST evaluates to True, the STATEMENTS1 will be executed. Otherwise, if COMMAND_TO_TEST returns False, the STATEMENTS2 will be executed. You can have only one else clause in the statement.&lt;/p&gt;

&lt;p&gt;Let’s add an else clause to the previous example script:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--klC4-Wjn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644675721972/25ZV3cLjJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--klC4-Wjn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644675721972/25ZV3cLjJ.png" alt="Screenshot 2022-02-12 at 7.51.43 PM.png" width="880" height="472"&gt;&lt;/a&gt;&lt;br&gt;
When you enter 100, the test command will evaluate to false and else block executes. &lt;/p&gt;
&lt;h3&gt;
  
  
  if...elif...else Statement
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if COMMAND_TO_TEST
then
  STATEMENTS1
elif COMMAND_TO_TEST
then
  STATEMENTS2
else
  STATEMENTS3
fi

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The conditions are evaluated sequentially. Once a condition returns True, the remaining conditions are not performed, and program control moves to the end of the if statements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--md6ePDQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644676069460/i9FnPzW1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--md6ePDQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644676069460/i9FnPzW1c.png" alt="Screenshot 2022-02-12 at 7.57.32 PM.png" width="880" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;BASH also allows you to nest if statements within if statements. You can place multiple if statements inside another if statement and you can also use logical operators like &lt;code&gt;OR&lt;/code&gt; and &lt;code&gt;AND&lt;/code&gt; operators allow you to use multiple conditions in the if statements.&lt;/p&gt;
&lt;h2&gt;
  
  
  Loops
&lt;/h2&gt;

&lt;p&gt;Loops are useful when you want to run a series of commands repeatedly until a certain condition is reached.&lt;/p&gt;

&lt;p&gt;There are three basic loop types in Bash scripting. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;for loop&lt;/li&gt;
&lt;li&gt;While loop&lt;/li&gt;
&lt;li&gt;until loop
### for loop
The basic &lt;code&gt;for&lt;/code&gt; loop in Bash looks like:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for item in [LIST]
do
  [COMMANDS]
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the below example, the loop will iterate over a each number in the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for number in 0 1 2 4 5 6 7 8 
do
  echo "number : $number"
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RkEJDSUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644724222870/TOqLIldeu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RkEJDSUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644724222870/TOqLIldeu.png" alt="Screenshot 2022-02-13 at 9.17.56 AM.png" width="880" height="398"&gt;&lt;/a&gt;&lt;br&gt;
For looping over a number range, we can use &lt;code&gt;{0..8}&lt;/code&gt;. In the latest versions of Bash, it is also possible to &lt;strong&gt;specify an increment&lt;/strong&gt; when using ranges. The expression takes the following form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for number in {0..10..2} 
do
  echo "number : $number"
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xZ3ZLRib--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644724237697/QWkuRcCzd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xZ3ZLRib--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644724237697/QWkuRcCzd.png" alt="Screenshot 2022-02-13 at 9.20.02 AM.png" width="880" height="275"&gt;&lt;/a&gt;&lt;br&gt;
We can also use the &lt;code&gt;for&lt;/code&gt; loop as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for ((INITIALIZATION; TEST; STEP))
do
  [COMMANDS]
done

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eEGMMCVH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644724747723/p28CTC0_g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eEGMMCVH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644724747723/p28CTC0_g.png" alt="Screenshot 2022-02-13 at 9.28.52 AM.png" width="880" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;break&lt;/code&gt; and &lt;code&gt;continue&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;We all know, the break and continue statements can be used to control the loop execution. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;break statement&lt;/strong&gt; terminates the current loop and passes program control to the statement that follows the terminated statement. It is usually used to terminate the loop when a certain condition is met.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;continue statement&lt;/strong&gt; exits the current iteration of a loop and passes program control to the next iteration of the loop.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bash &lt;code&gt;while&lt;/code&gt; loop
&lt;/h3&gt;

&lt;p&gt;The while loop is used to performs a given set of commands an number of times as long as the given condition evaluates to true.&lt;/p&gt;

&lt;p&gt;The Bash while loop takes the following form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while [CONDITION to TEST]
do
  [COMMANDS to EXECUTE]
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the following example, for each iteration, the current value of the variable &lt;code&gt;i&lt;/code&gt; is printed and incremented by one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;number=0
while [ $number -le 5 ]
do
  echo "Number: $number"
  ((number++))
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above script loops as long as &lt;code&gt;i&lt;/code&gt; is less than 5.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YQkTnGUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644725942070/Q6gWDRGj-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YQkTnGUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644725942070/Q6gWDRGj-.png" alt="Screenshot 2022-02-13 at 9.48.44 AM.png" width="868" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash &lt;code&gt;until&lt;/code&gt; loop
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;until&lt;/code&gt; loop is used to execute a given set of commands as long as the given condition evaluates to false.&lt;/p&gt;

&lt;p&gt;The Bash until loop takes the following form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;until [CONDITION to TEST]
do
  [COMMANDS to EXECUTE]
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the following example, on each iteration the loop prints the current value of the &lt;code&gt;number&lt;/code&gt; and increments the variable by one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
number=0
until [ $number -gt 3 ]
do
  echo "Number: $number"
  ((number++))
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop iterates until the variable has a value greater than three. The script gives the following output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--um6bJgdf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644726403689/RvDZ_2MUD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--um6bJgdf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644726403689/RvDZ_2MUD.png" alt="Screenshot 2022-02-13 at 9.56.27 AM.png" width="880" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;while&lt;/code&gt; and &lt;code&gt;until&lt;/code&gt; loops are similar to each other. The main difference is that the while loop iterates as long as the condition evaluates to &lt;code&gt;true&lt;/code&gt; and the until loop iterates as long as the condition evaluates to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Functions in Bash
&lt;/h3&gt;

&lt;p&gt;Function are part of any programming language , we can define the function as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function_name () {
  commands to execute
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's look at the following example which prints "hello world" to screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
helloworld () {
   echo "Hello_world"
}
helloworld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run the script, it will print &lt;code&gt;Hello_world&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DdGVo7R8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644727077401/bjKFFIGhY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DdGVo7R8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644727077401/bjKFFIGhY.png" alt="Screenshot 2022-02-13 at 10.07.42 AM.png" width="880" height="400"&gt;&lt;/a&gt;&lt;br&gt;
We can also declare a function using the keyword &lt;code&gt;function&lt;/code&gt; just like we do in most of the programming languages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gKpggc13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644727279891/Ihhi-2yLp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gKpggc13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644727279891/Ihhi-2yLp.png" alt="Screenshot 2022-02-13 at 10.10.01 AM.png" width="870" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlike functions in “real” programming languages, Bash functions don’t allow you to return a value when called. &lt;br&gt;
The return status can be specified by using the return keyword, and it is assigned to the variable $?. The return statement terminates the function. You can think of it as the function’s exit status .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
my_function () {
  echo "Test of Return"
  return 7
}

my_function
echo $?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kG5jyd4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644727665702/-z3Svgqqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kG5jyd4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644727665702/-z3Svgqqg.png" alt="Screenshot 2022-02-13 at 10.16.54 AM.png" width="880" height="146"&gt;&lt;/a&gt;&lt;br&gt;
A Bash function is a block of reusable code designed to perform a particular operation. Once defined, the function can be called multiple times within a script.&lt;/p&gt;

&lt;p&gt;Connect with me on &lt;a href="https://www.linkedin.com/in/srinivas-karnati/"&gt;Linkedin&lt;/a&gt;, &lt;a href="https://twitter.com/__karnati"&gt;Twitter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Setting up an Ubuntu 20.04 VPS</title>
      <dc:creator>Srinivas karnati</dc:creator>
      <pubDate>Sun, 20 Feb 2022 05:40:55 +0000</pubDate>
      <link>https://dev.to/karnatisrinivas/setting-up-an-ubuntu-2004-vps-3ckm</link>
      <guid>https://dev.to/karnatisrinivas/setting-up-an-ubuntu-2004-vps-3ckm</guid>
      <description>&lt;h3&gt;
  
  
  Creating an VPS
&lt;/h3&gt;

&lt;p&gt;VPS, or Virtual Private Server, is an virtual machine configured to operate as a physical computer under virtualization software on a dedicated server. It stores all of the data and files that are useful for your application .You would interact with a VPS just as you would a physical, dedicated server.&lt;/p&gt;

&lt;p&gt;I use &lt;a href="https://m.do.co/c/174c0787f826" rel="noopener noreferrer"&gt;Digital Ocean&lt;/a&gt; for creating my VPS. Ofcourse you can use any of the other service providers. Once you login into your account, you will be presented with the below screen.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644380816868%2F9zqEDLc2b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644380816868%2F9zqEDLc2b.png" alt="Screenshot 2022-02-09 at 9.56.44 AM.png"&gt;&lt;/a&gt;&lt;br&gt;
Click on Create and then Droplets (VPS) , you will get a screen where you can choose the Operating system, and plan size. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644380919100%2Fz8KKj2VSZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644380919100%2Fz8KKj2VSZ.png" alt="Screenshot 2022-02-09 at 9.18.04 AM.png"&gt;&lt;/a&gt;&lt;br&gt;
Choose a region which is closest to your target users. This is basically the physical location where the server will be located. Finally, choose a password and click create droplet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644380965191%2F7FPpJW8h5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644380965191%2F7FPpJW8h5.png" alt="Screenshot 2022-02-09 at 9.18.34 AM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Creation of droplet is done, you will see the details of the Server like Public IP, Private IP and some hardware details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381093757%2FEWumgmxHU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381093757%2FEWumgmxHU.png" alt="Screenshot 2022-02-09 at 9.20.08 AM.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Accessing the Server
&lt;/h3&gt;

&lt;p&gt;We will use an SSH Client to get access to the server's terminal (our VPS), and once we have access to the terminal, we can start executing commands on this server. &lt;/p&gt;

&lt;p&gt;To log in to our server, we need to know its public IP address ( which we already have).&lt;/p&gt;

&lt;p&gt;Execute the following command on the terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh root@yourserver_PublicIP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381239726%2FdXDGzBJVk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381239726%2FdXDGzBJVk.png" alt="Screenshot 2022-02-09 at 9.22.03 AM.png"&gt;&lt;/a&gt;&lt;br&gt;
Enter the password you have created while creating the droplet in DigitalOcean. Once you enter the password when prompted, you will be logged in as root user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381306838%2F90PjduSKK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381306838%2F90PjduSKK.png" alt="Screenshot 2022-02-09 at 9.22.44 AM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You an execute almost all the Linux Commands on your Ubuntu Server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381393211%2F_ZwC0Sfty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644381393211%2F_ZwC0Sfty.png" alt="Screenshot 2022-02-09 at 9.23.57 AM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can create non-root users, by &lt;code&gt;useradd&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useradd srinivas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be asked to enter some information and a password. Once you are provided the details required, It will create a non root user profile in the server.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;exit&lt;/code&gt; command will close the server's terminal. &lt;/p&gt;

&lt;p&gt;You can configure as many servers as you want of your choice( but beware of Billing ). Hope you got basic understanding on how to setup a VPS and how to access it. :)&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
