<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Januda Bethmin on Medium]]></title>
        <description><![CDATA[Stories by Januda Bethmin on Medium]]></description>
        <link>https://medium.com/@desilvabethmin?source=rss-3edf04a73a34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4wJfGDKkKKM4k3D_Iw8EDQ.jpeg</url>
            <title>Stories by Januda Bethmin on Medium</title>
            <link>https://medium.com/@desilvabethmin?source=rss-3edf04a73a34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 04:58:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@desilvabethmin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CICD Pipeline using Github Actions]]></title>
            <link>https://medium.com/@desilvabethmin/cicd-pipeline-using-github-actions-7e7d85996b7b?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e7d85996b7b</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[ecr]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Fri, 23 Aug 2024 09:57:01 GMT</pubDate>
            <atom:updated>2024-08-23T10:09:10.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g5MrJiLeKRuV-81YjiDMtw.png" /></figure><p>GitHub Actions is an easy way to automate all our software workflows with CI/CD. We can use GitHub actions to build, test, and deploy your code right from GitHub and make code reviews, branch management, and issue triaging work as we want.</p><p>Here, I am going to demonstrate how to create a full CICD pipeline that will complete the following objectives:</p><p>1. <strong>Create a Pipeline to Build and Push Docker Images to Docker Hub</strong></p><p>2. <strong>Transition from Docker Hub to AWS ECR</strong></p><p>3. <strong>Deploy Docker Images to AWS EC2 Instances</strong></p><p>4. <strong>Implement a Pipeline for Unit Testing and Building on Pull Requests</strong></p><p>5. <strong>Vulnerability Scanning</strong></p><p>6. <strong>Enforce Branch Protection Rules</strong></p><p>Now, I will walk you through the process of building the CICD pipeline.</p><p>You can find the GitHub repository related to the article <a href="https://github.com/itzzjb/gh-actions-ci-cd-pipelines">here</a>.</p><h3><strong>Building and Pushing Docker Images to Docker Hub and Deploying them to EC2</strong></h3><p>The first step is to set up a CI pipeline that triggers whenever pushes are made to the main branch. This pipeline would build a Docker image based on the application’s Dockerfile and push the built image to Docker Hub.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37c97467e12065a6664c1f78ab9e54f9/href">https://medium.com/media/37c97467e12065a6664c1f78ab9e54f9/href</a></iframe><p>Here we need to configureSSH_USER, SSH_HOST, SSH_PRIVATE_KEY, DOCKER_USERNAME, and DOCKER_PASSWORD in Github repository secrets and use them as environment variables for the workflow.</p><pre>env:<br>  SSH_USER: ${{secrets.SSH_USER}}<br>  SSH_HOST: ${{secrets.SSH_HOST}}<br>  SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}<br>  DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}<br>  DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}</pre><p>We are using docker official predefined actions called docker/login-action@v3 and docker/build-push-action@v6 to build and push the docker image to the docker hub.</p><pre>- name: Login to Docker Hub<br>  uses: docker/login-action@v3<br>  with:<br>    username: ${{env.DOCKER_USERNAME}}<br>    password: ${{env.DOCKER_PASSWORD}} <br><br>- name: Build &amp; Push the Docker Image<br>  uses: docker/build-push-action@v6<br>  with:<br>    push: true<br>    tags: itzzjb/docker-react:latest</pre><p>After successfully pushing the image to docker hub we can pull the docker image from an AWS EC2 instance by SSH into that instance. I will explain this part in the next part.</p><h3><strong>Switching to AWS ECR</strong></h3><p>In the industry, the AWS ECR container registry is used than docker hub. It’s the industry standard registry. So, we are going to change the workflow from docker hub to ECR.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8289e87a33794f3f2370c687b7bcd43/href">https://medium.com/media/d8289e87a33794f3f2370c687b7bcd43/href</a></iframe><p>Here also we need to configureSSH_USER, SSH_HOST, SSH_PRIVATE_KEY, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, ECR_REGISTRY, ECR_REPOSITORY and IMAGE_TAG in Github repository secrets and use them as environment variables for the workflow.</p><pre>env:<br>  SSH_USER: ${{secrets.SSH_USER}}<br>  SSH_HOST: ${{secrets.SSH_HOST}}<br>  SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}<br>  AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}<br>  AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}<br>  AWS_REGION: ${{secrets.AWS_REGION}}<br>  ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}<br>  ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}<br>  IMAGE_TAG: ${{ secrets.IMAGE_TAG }}</pre><p>Just like in dockerhub, we are going to use AWS official predifined actions called aws-actions/configure-aws-credentials@v4 and aws-actions/amazon-ecr-login@v2. Because there were no action to build and push I can to do them manally using commands.</p><pre>- name: Build, Tag, and Push Image to Amazon ECR<br>  run: |<br>    docker build . -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG<br>    docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG</pre><p>After successfully pushing the image to dockerhub we can pull the docker image from an AWS EC2 instance by SSH into that instance.</p><p>We are going to SSH into the AWS EC2 instance that we started from the GitHub action runner. If you wan’t you can use an action like appleboy/ssh-action@v1.0.3. But here I have manually coded SSH scripts.</p><p>You need to do these things by SSHing into the EC2 instance.</p><ol><li><strong>Setup SSH on EC2</strong></li><li><strong>Install and Start Docker on EC2</strong></li><li><strong>Install AWS CLI on EC2</strong></li><li><strong>Configure AWS Credentials on EC2</strong></li><li><strong>Login to ECR on EC2</strong></li><li><strong>Pull and Run Docker image on EC2</strong></li></ol><h3>Implementing Branch Protection Rules</h3><p>We are going to set up some branch protection rules for the main branch of the repository, so no one can push directly to it.</p><p>The only way to push something to the main branch is by creating a pull request to the main branch from another branch. This is useful because we can set some status checks and reviews to be done to these pull requests before they can be merged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZMM5GKqO2EOByFpYuTgSQ.png" /></figure><h3>Unit Testing, Build Test, and Vulnerability Scan as Status Checks</h3><p>We are going to write workflows for that running the unit tests and checking the build of the application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0622cc6403ec3537ab5cd1e502fe5312/href">https://medium.com/media/0622cc6403ec3537ab5cd1e502fe5312/href</a></iframe><p>And to scan vulnerabilities in the file system of the application and the build image using Trivy. The results of the vulnerability scans will be uploaded to the security section of the GitHub repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc3b21e2085923fdd01cf10b57c7d77b/href">https://medium.com/media/cc3b21e2085923fdd01cf10b57c7d77b/href</a></iframe><p>We are going to trigger these workflows on the creation of a pull request to the main branch. And we are going to set up these as status checks from the branch protection rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxHOouL1Nsx-jEOdGZOTGQ.png" /></figure><p>Now, only after the status checks are passed we would be able to merge and push the code to the main branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttez2H4J86FMa3PErAYJLw.png" /></figure><p>After all that, now the CICD pipeline is complete. This pipeline is reusable, you only need to change the values of the GitHub secrets to use it in another application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e7d85996b7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reducing the size of a docker image]]></title>
            <link>https://medium.com/@desilvabethmin/reducing-the-size-of-a-docker-image-a104332a6aca?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/a104332a6aca</guid>
            <category><![CDATA[reduce]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[alpine]]></category>
            <category><![CDATA[size]]></category>
            <category><![CDATA[multi-stage-builds]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Mon, 15 Jul 2024 18:08:45 GMT</pubDate>
            <atom:updated>2024-07-15T18:25:17.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovRuAuqPf4r2xpiWh71rUg.png" /></figure><p>In docker, we are using Dockerfiles to build custom images that we can run as a container. By having smaller-sized containers we can run our applications more efficiently and securely. Also, smaller-sized containers only require a low number of resources. For that, we need to build our images as light as possible.</p><p>Let’s take an example where we create an image for a simple express server. The following is the app.js file that contains the code of the express server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b641361523af7705b374e314288ca88/href">https://medium.com/media/2b641361523af7705b374e314288ca88/href</a></iframe><p>First, let’s create a Dockerfile to build an image that we can use to run a container to use this express server. We use the LTS version of the node’s official image and build and run the express app on top of it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88bf3048962576bd7de9b3fdca68df26/href">https://medium.com/media/88bf3048962576bd7de9b3fdca68df26/href</a></iframe><p>After building the above Dockerfile into an image we can see that the image is 1.57 GB. This is too much for a simple hello world express application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDDbKAKfvdTHn0fvNamBCw.png" /></figure><h3>So, how to reduce the size of the image?</h3><ol><li><strong>Use smaller base images (slim, alpine)</strong></li></ol><p>By using alpine or slim versions of the images we can reduce a significant amount of size from the resulting image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3df158e3d55e3aecd5766bcc6e3239fd/href">https://medium.com/media/3df158e3d55e3aecd5766bcc6e3239fd/href</a></iframe><p>After building the above Dockerfile into an image we can see that the image is 197MB, which is far better than the previous build which was x8 more in size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uz0AJGqBDbXmDZ2K1MzPIg.png" /></figure><p>2. <strong>Set the environment to production</strong></p><p>We can set the environment to production. Then, only the production dependencies will be installed on the image. All the dev dependencies will be ignored. This may result in a significant reduction in the size of the image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bb9c3ed9162aba544f969acabd707fe/href">https://medium.com/media/7bb9c3ed9162aba544f969acabd707fe/href</a></iframe><p><strong>3. Use Multistage build</strong></p><p>We can use the <a href="https://docs.docker.com/build/building/multi-stage/">multi-stage build method </a>to build much smaller docker images. This is the industry-standard method of creating dockerfiles.</p><p>Here we are going to build the docker image in two stages. In the first stage, we build the application in an official node LTS image using dependencies and packages and then we will run the built application on an alpine or slim node image that has the run time for the application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f5546fa69d469b23bb27b919a24f775/href">https://medium.com/media/4f5546fa69d469b23bb27b919a24f775/href</a></iframe><p>After building the above Dockerfile into an image we can see that the image is 194MB, which is far better than all the previous builds. Also, to make the images much smaller we can use <a href="https://console.cloud.google.com/gcr/images/distroless">distroless images </a>too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXQdPpdHrFyvgdoRhLzeYA.png" /></figure><p>By using a multi-stage build method we can build the image in a resources-full base image which has all the packages and dependencies that are needed, and then run the image using a small base image that only has the runtime environment needed to run the specific application. All the other dependencies and packages won’t be included, so we will get a smaller image that results in a smaller working running container.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a104332a6aca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does DNS work?]]></title>
            <link>https://medium.com/@desilvabethmin/how-does-dns-work-bcc33f0e2ede?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc33f0e2ede</guid>
            <category><![CDATA[authoritative-server]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[dns-resolver]]></category>
            <category><![CDATA[root-server]]></category>
            <category><![CDATA[tld-servers]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 07:47:19 GMT</pubDate>
            <atom:updated>2024-06-29T08:12:25.666Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*9sRwjpTJOTrtbOYaPZxVgg.jpeg" /></figure><p>In the world of computing, computers don’t go by names, they go by numbers. That’s how computers talk and identify each other over a network. For that, computers use numbers such as IP addresses.</p><p>Humans, on the other hand, are accustomed to using names instead of numbers. So, to bridge the communication gap between humans and computers and to make communication a lot easier networking engineers developed DNS. DNS is shortened for <strong>Domain Name System</strong>.</p><p>DNS resolves names to numbers. To be more specific it resolves <strong>domain names to IP addresses</strong>.</p><h3>DNS Resolving Process</h3><p>Let’s take the example of the DNS resolving process when accessing the yahoo.com website. When you search for yahoo.com from the browser, your device will first look into yahoo.com’s IP address in <strong>Local, Router, and ISP caches</strong>.</p><p>If the IP address is not found on them, the request will go through multiple servers to find it.</p><figure><img alt="DNS Resolving Process — Graph done by Januda Bethmin" src="https://cdn-images-1.medium.com/max/1024/1*-x1ZpPZKozXTJrK0pstLYA.png" /><figcaption>DNS Resolving Process for Yahoo.com</figcaption></figure><p>First of all the DNS resolver will request to a <strong>root server</strong> asking for the IP address of yahoo.com. There are 13 main root servers in the world. These root servers are operated by 12 different operators (organizations). Root servers <em>don’t store the IP addresses of individual sites</em>, instead, they know how to find the<strong> TDL servers</strong> ( Top Level Domain Servers ). Here, the root server will respond to the DNS resolver sending the IP addresses of .com TLD servers.</p><p>Now, the DNS resolver will request from a .com TLD server asking for the IP address of yahoo.com. TLD servers <em>manage domains under a specific extension like .com, .net or .edu</em>. TLD server will direct the DNS Resolver to the exact <strong>authoritative server</strong> for any domain. Here, the .com TLD server will respond to the DNS resolver by sending the IP addresses of authoritative name servers that contain the yahoo.com domain.</p><p>Authoritative name servers are typically provided by sellers like GoDaddy. These servers <em>hold the actual DNS records for a domain</em>. This includes the IP address that the browser needs to access the website. Here, the DNS resolver will request the IP address of yahoo.com from an authoritative server, and in response, it will get the actual IP address from the server. DNS resolver will now <em>store these DNS records in its cache for future use</em> and send the IP address of yahoo.com to you’re device as a response.</p><p>Finally, now you can access and see the content of the website from the web server of yahoo.com using the IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIjgJ_2w278D36pYujlKGw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc33f0e2ede" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing NGINX on a Mac]]></title>
            <link>https://medium.com/@desilvabethmin/installing-nginx-on-a-mac-436ddeebfea9?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/436ddeebfea9</guid>
            <category><![CDATA[reverse-proxy]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[brew]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Fri, 28 Jun 2024 02:41:53 GMT</pubDate>
            <atom:updated>2024-06-28T02:41:53.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rw5UtkN4fSKRnGll6pNqoA.png" /></figure><p>To try out and learn nginx, we need to install it locally. If you have a Mac, you need to have <strong>brew</strong> installed ( a package manager for Mac).</p><p>We can open the terminal and use the following command to install nginx to the local machine.</p><pre>brew install nginx</pre><p>After the installation, you can see where nginx got installed in the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJmhtly_IGcetYxTWH9Wmg.png" /></figure><p>Now open the nginx directory in that path on vs code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ao8fdwUOBT6PVAqLVR6uEQ.png" /></figure><p>Here, you can see a bunch of files and a folder inside the nginx directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAVuz1S2axV-XQz1uljRtQ.png" /></figure><p>We can edit the nginx.conf file to <strong>configure</strong> nginx as a reverse proxy.</p><p>The configuration will be done so that nginx would be able to reach out to a particular server and serve us over web content.</p><p>Now to <strong>start up</strong> nginx all you have to do is use nginx command in the terminal from anywhere.</p><pre>nginx</pre><p>Now, when we visit localhost:8080 in the browser we would be able to see the following we page being served from nginx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EHDnRCxfOmCBkkIcPZEeZQ.png" /></figure><p>We can always confirm this by inspecting the webpage and going on to the network tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ka0bCYeWNlwfSh2Py3ONNA.png" /></figure><p>Now, nginx is successfully installed and running on your Mac. You can now configure nginx to return other content like files, folders, images, etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=436ddeebfea9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is NGINX?]]></title>
            <link>https://medium.com/@desilvabethmin/what-is-nginx-8abf9da9714b?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/8abf9da9714b</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[web-server]]></category>
            <category><![CDATA[reverse-proxy]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[load-balancing]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Thu, 27 Jun 2024 18:04:20 GMT</pubDate>
            <atom:updated>2024-06-27T18:17:10.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rw5UtkN4fSKRnGll6pNqoA.png" /></figure><p>For an example, let’s visit the website at <a href="https://www.airbnb.ca/">www.airbnb.ca</a>. As soon as we go to the website we can see that the browser is served by a bunch of different contents.</p><p>How did the browser get all of this content? We can understand this by inspecting the webpage and looking into the <strong>network</strong> tab.</p><p>When we refresh the webpage, we will get bombarded with a bunch of different networks. These are network requests made from a browser to a particular server to get content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g0uCeygV8lNUssOwdEC9Rg.png" /></figure><p>When we go and click on the very first network on here, we can get a little more information about it. When browsing the <strong>header</strong> section of this network, we can see that the server is <strong>nginx</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI-mfMzjIIs_kMkKLR6XPQ.png" /></figure><p>So, nginx is the one who served us the content in the browser. That’s why nginx is very typically known as a <strong>web server</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-91Ic3nMBWQTyqjAFEw_sA.jpeg" /></figure><p>Nginx acts as a <strong>reverse proxy</strong> here. This helps to increase the security, performance, and reliability of the server/s.</p><p>If we are getting a lot of traffic to the website, we need to increase the number of servers we have. ( AWS EC2 instances )</p><p>When we increase the number of servers, this presents another problem. Now, we need to be able to pick from which server we need to get the content from.</p><p>This is where nginx comes in. Here, the client only sends the request to the nginx. Nginx will be responsible for forwarding this request to an available server. Here nginx acts as a<strong> load balancer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYXX8_A2mMsoxxnnbvgn1A.jpeg" /></figure><p>Another use case of nginx is <strong>encryption. </strong>When we are visiting a website it is either in http or https. If it is https, it means the server encrypting and decrypting data that is being sent and returned.</p><p>This presents a problem when we have multiple servers. We gonna have to do the encryption and decryption process on every single one of the servers.</p><p>Instead, we can simply have the encryption and decryption process in the nginx server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*3iv-p0afi_HJcE2zMiiREg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8abf9da9714b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Mastery #6 : Using Man pages]]></title>
            <link>https://medium.com/@desilvabethmin/linux-mastery-6-using-man-pages-48e97765b21f?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/48e97765b21f</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[structure]]></category>
            <category><![CDATA[synopsis]]></category>
            <category><![CDATA[manuals]]></category>
            <category><![CDATA[man-pages]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 10:25:21 GMT</pubDate>
            <atom:updated>2024-06-09T16:01:22.067Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Mastery #6 : Using Man Pages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rvVrlXsSEQU1ZyfjNChk3A.jpeg" /></figure><p>We need to be able to search the manual and discover new commands, access the man pages of those commands, and need to able to know how to read the man pages.</p><p>This will give up independence to search for new commands and learn how they work.</p><h3><strong>Opening up a Man page</strong></h3><p>To search the manual first we need to use the “<strong>man</strong>” command. This command deals with everything related to the manual pages.</p><p>We can now give options and inputs to use this command for our needs.</p><p>The “-<strong>k</strong>” option is used to search the manual pages. Here we will search the man pages for the search term “which”.</p><pre>man -k which</pre><p>This goes all the manual and finds anything relevant to the search term “<strong>which</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_T0JAspvhWg1SoAjIWloA.png" /></figure><p>If you want to search for a multiple-word string, you must use double quotations.</p><pre>man -k &quot;list directory contents&quot;</pre><p>On the left side of the output, we got the <strong>names of certain manual pages </strong>that are appropriate to the search term “which”. On the right side, we get a <strong>synopsis of the page</strong> so you can pick the appropriate one. Inside the parenthesis, we get the <strong>section number</strong> where the page is in the manual.</p><p>After selecting the page we need to look into, we can take a deep look at that page using the following command.</p><pre>man sectionNo PageName</pre><p>We selected the <strong>which (1)</strong> page. So, the command for the above scenario will be the following.</p><pre>man 1 which</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xgjmZu7HEiGreyGDD6sdA.png" /></figure><p>To back out to the terminal, we can press <strong>q</strong>.</p><p>But, because of the first section of the manual used so often. We don’t even need to type “<strong>1</strong>”.</p><pre>man which</pre><h3><strong>Reading a Man page</strong></h3><p>After opening up the manual page, we can see that the manual page is broken down into several sections.</p><p><strong>Name:</strong></p><p>This comes up as the output when we search the manual in the first place. ( As an answer to the man -k which command. )</p><p><strong>Synopsis:</strong></p><p>This shows the layout of how to use the command. ( Because each command is structured differently, we would need this part of the man page )</p><p>Let’s get the man page of which command as an example. The synopsis here is which [-a] filename ...</p><p>Note that here we have square brackets surrounding the “<strong>-a</strong>” option. It means using the “<strong>-a</strong>” option is optional for this command.</p><p>Whenever there are square brackets in a man page, it’s<strong> optional</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*isHXIUOB_wn414d1mjsERg.png" /></figure><p>And there is ... at the end of the command. That means you can enter more than one file name for this command.</p><p>Whenever there are ... at the end of a command synopsis, it means that the command can <strong>take multiple inputs</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hh-DEKFATkP70B3H9QsmtA.png" /></figure><p>Also, whenever there are angle brackets ( &lt;SOMETHING&gt; ) in a command, it means that SOMETHING is <strong>mandatory</strong> for the command.</p><p>And if there is a pipe character between two options ( [-a | -p] ), that means you can only pick one from both. You <strong>cannot pick both</strong>.</p><p><strong>Description:</strong></p><p>This is where you see what the command does. It gives an in-depth description of what the command does in plain English.</p><p><strong>Options:</strong></p><p>This gives a list and a description of all the options that can be used with this command.</p><p><strong>Exit Status</strong></p><p>There might be more sections like <strong>Examples, See Also, Environment, Bugs, Reporting Bugs, Offers, History, Copyrights, etc.</strong></p><p>Most of the commands are documented in the man pages. But still, some commands that are directly defined in the shell may not have been documented in man pages.</p><p>We need to use the “help” command to find out about these commands.</p><p>For example, there is no man page dedicated to the “<strong>cd</strong>” command. But we can use the help command to get the information we need.</p><pre>help cd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKUAb2SwmFhwU9MuKY0KlA.png" /></figure><p>Next → Linux Mastery #7 : Command Input and Output</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48e97765b21f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Mastery #5 : Command Manual (Man) Pages]]></title>
            <link>https://medium.com/@desilvabethmin/linux-mastery-5-command-manual-man-pages-8fe33482aa1d?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fe33482aa1d</guid>
            <category><![CDATA[section]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[manuals]]></category>
            <category><![CDATA[commands]]></category>
            <category><![CDATA[man-pages]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Wed, 05 Jun 2024 09:49:27 GMT</pubDate>
            <atom:updated>2024-06-06T10:26:15.530Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Mastery #5 : Command Manual (Man) Pages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rvVrlXsSEQU1ZyfjNChk3A.jpeg" /></figure><p>Each of the Linux commands is written, implemented, and behaves in a slightly different way. Other than memorizing tons of Linux commands we can use <strong>Manual (Man) Pages</strong> to learn how to use each of Linux commands properly.</p><p>Linux comes with an incredible set of Manual Pages that will detail the working of just about everything that the Linux OS has to offer including commands.</p><p><strong>How the Manual is structured?</strong></p><p>Because the manual is massive, having an understanding of the structure behind it to easily navigate.</p><p>The manual is broken up into 8 sections. Each of these sections deals with a specific type of thing that deals with your Linux OS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*rW-zq5C1Oy7x0A7AToT9Hg.jpeg" /></figure><p><strong>User Commands</strong></p><p>These are commands that can run in the shell by any<strong> regular user</strong>. You don’t need any particular administration or root privileges to run these commands.</p><p><strong>System Calls</strong></p><p>This contains <strong>programming functions</strong> that can be used within an application that you write that calls to the Linux kernel. ( Very low-level part of the Linux OS )</p><p><strong>C Library Functions</strong></p><p>These are <strong>functions and libraries</strong> that are written in <strong>C</strong> programming language, that provide interfaces to specific things on your computer.</p><p><strong>Devices and Special Files</strong></p><p>This is about how different <strong>devices</strong> in your computer are <strong>managed</strong>. How things such as CD drives, random number generators, and USB ports are managed and how you can access those using the command line are here.</p><p><strong>File Formats and Conventions</strong></p><p>This is all about all the different <strong>file formats and conventions </strong>of specific files on your computer. Formats for files like Word documents, PDF documents, and configuration files are here.</p><p>When you want to configure your computer and start <strong>customizing </strong>stuff this section will be used often. Because it shows how those files work and structure so you can make changes to them.</p><p><strong>Games</strong></p><p>This section is about any games that are installed on your computer, how they work, and about different commands related to games.</p><p><strong>Miscellaneous</strong></p><p>More <strong>miscellaneous and uncategorized </strong>stuff is here. Usually, stuff like protocols and file systems are here.</p><p><strong>System Administration</strong></p><p>This section holds all the stuff related to system administration. This is like the reverse of section 01.</p><p>All the commands that <strong>required root and administration privileges</strong> that required to run are here. Things like changing passwords, editing important stuff on your computer, and setting up automation are here.</p><p><strong><em>The main sections that gonna be used are the Sections 01, 05, and 08.</em></strong></p><p>Next → Linux Mastery #6 : <a href="https://medium.com/@desilvabethmin/linux-mastery-6-using-man-pages-48e97765b21f">Using the Man Pages</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fe33482aa1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Mastery #4 : Command Structure]]></title>
            <link>https://medium.com/@desilvabethmin/linux-mastery-4-command-structure-e8cdc8bc977b?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8cdc8bc977b</guid>
            <category><![CDATA[structure]]></category>
            <category><![CDATA[putin]]></category>
            <category><![CDATA[commands]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[options]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Wed, 05 Jun 2024 08:19:25 GMT</pubDate>
            <atom:updated>2024-06-05T09:50:36.378Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Mastery #4 : Command Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rvVrlXsSEQU1ZyfjNChk3A.jpeg" /></figure><p>The commands that we type all follow a similar type of structure in the way that you type them. By understanding the structure we will be able to understand the common language that all Linux commands use, instead of memorizing the commands.</p><p><strong>What are commands?</strong></p><p>All commands are a little computer program that is installed somewhere on your computer.</p><p>All the commands/programs have a name ( <em>echo, date, cal</em> ) and it will be the first word typed when we are writing the command on the terminal.</p><p>Each command has a unique behavior that we can look up using the manual pages.</p><p><strong>General Command Structure</strong></p><pre>commandName options input</pre><p><strong><em>commandName</em></strong>: Selects which program we want to run.</p><p>This selected program will be searched from the <strong>shell’s path</strong>. It’s a list of folders that contain these programs.</p><p>We can see the shell’s path by typing the following command.</p><pre>echo $PATH</pre><p>This will give multiple folder paths each separated from “<strong>:</strong>” s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjkNJWVHARLn7pfnnP8Nwg.png" /></figure><p>What the shell would do is, it will start from the <strong>leftmost folder</strong> and start looking for the specific program. If it doesn’t find a folder with that name in any of these folders, the shell will give you an <strong>error</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVCK--mIs6TFVG-B6dBZHA.png" /></figure><p>We can find the folder that the command/program is in using the following command.</p><pre>which echo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqUTy3_bRtXc6GsILxzSPw.png" /></figure><p><strong><em>options</em></strong>: Customize the behavior of the command</p><p>We can give an option to a command after a space and a slash to the commandName.</p><pre>commandName -option</pre><p>If you are trying to call multiple options we can call them one option after the other.</p><pre>commandName -option1 -option2 -option3</pre><p>Or easily like following,</p><pre>commandName -option1option2option3</pre><p>Note that when using multiple options, the order doesn’t matter. It will have the same effect.</p><p>Some command options have both short-form and long-form names.</p><p>The following command with the option will return the current date in universal time.</p><pre>date -u</pre><pre>date --universal</pre><p>Note that when using the short-form the option is proceeded by a single “-” and when using the long-form the option is proceeded by double “-” s.</p><p>Long-form commands make commands easier to read, but they are not available for all options.</p><p>When we need to use multiple long-form options we can only use the following pattern. We can’t change them together as short-term options.</p><pre>commandName --longformoption1 --longformoption2 --longformoption3</pre><p>Some options require inputs too. So, let’s look at the following example.</p><p>The following “<strong>-A</strong>” option ( After ) takes an input ( “<strong>1</strong>” ) to show more number of months ( 1 month ) after the selected month ( December 2024 ) using the other inputs.</p><pre>cal -A 1 12 2024</pre><p>Likewise, we can have the Before ( <strong>-B</strong> ) one too. This will show December 2024 and November and October the two months before December.</p><pre>cal -B 2 12 2024</pre><p>We can also use a combination of A and B options. This results the calenders of November 2024, December 2024, and January 2025.</p><pre>cal -A 1 -B 1 12 2024</pre><p>There might be some commands using “=” to connect the option and it’s input.</p><pre>commandName -option1=input1 -option2=input2</pre><pre>commandName --longformoption1=input1 --longformoption2=input2</pre><p><strong><em>input</em></strong>: Give some input to the command to work on.</p><p>Not all commands require inputs. But most commands will require an input. Inputs are also called “<strong>operands</strong>”.</p><p>To give an input/operand to a command you type a space after the commandName and then type the input. ( <em>Assuming you don’t have any options</em> )</p><p>The following command will return the calendar of the year 2024 on the terminal.</p><pre>cal 2024</pre><p>You can also give more than one input to a command.</p><p>The following command will return the calendar of December of the year 2024 on the terminal.</p><pre>cal 12 2024</pre><p>Note → All the commands in Linux are <strong>case-sensitive</strong>. ( This includes all commandNames, options, and inputs.</p><p>Next →<a href="https://medium.com/@desilvabethmin/linux-mastery-5-command-manual-man-pages-8fe33482aa1d"> Linux Mastery #5 : Command Manual (Man) Pages</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8cdc8bc977b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Mastery #3 : Commands, Shell, Terminal]]></title>
            <link>https://medium.com/@desilvabethmin/linux-mastery-3-commands-shell-terminal-5721771eb7fe?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/5721771eb7fe</guid>
            <category><![CDATA[interpretation]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[commands]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Tue, 04 Jun 2024 08:52:06 GMT</pubDate>
            <atom:updated>2024-06-05T08:20:16.184Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Mastery #3 : Commands, Shell, Terminal</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rvVrlXsSEQU1ZyfjNChk3A.jpeg" /></figure><p>Learning how to use the terminal in Linux will give a huge control over the OS. As they say <em>“With great power comes great responsibility”</em>.</p><p>To maximize the control over the Linux OS, we need to have a solid understanding of what’s going on when you type your commands.</p><h3>What’s going on when we type a command?</h3><p><strong>Difference between commands and the Shell</strong></p><p><strong>Commands</strong> are text. Once you press enter, the meaning of the text is interpreted by a computer program called the <strong>shell</strong>.</p><p>Let’s take a real-world example.</p><p>If you can’t read the language that a word is written, it would not mean much to you. It would simply be just a set of letters. The job of the shell is to interpret that text (word) into a meaning.</p><p>So, let’s take a word like <strong>Gift</strong> as a command, and if we have a shell that can read English. The meaning that will come out is a <strong>present</strong> that we can give to someone on their birthday.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7Je63mhmV-1lcP3W6XO4g.png" /></figure><p>Instead of using a shell that can read English, we use a shell that can read German. Instead of present, the meaning that would come out will be <strong>poison.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YcDmRJONFX3LDFquWP66Yw.png" /></figure><p>Meaning that what comes out of a command will be different depending on the shell that it was interpreted.</p><p><strong>What is the terminal for?</strong></p><p>The terminal is nothing but a window to the shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5pNKpsWTaB48PjMnfvnQBw.png" /></figure><p>There is no way we can write commands onto to shell without the terminal. It’s the middle piece between typing commands and sending them to the shell.</p><p><strong>Types of shells</strong></p><p>Different types of shells can interpret the same command in different ways. The most commonly used shell is the <strong>bash</strong> shell.</p><p>Most Linux distributions use the bash shell including Ubuntu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5opd2gzCK3WAaKElZPBaTA.jpeg" /></figure><p><strong><em>Note: Commands are case-sensitive.</em></strong></p><p>Next → <a href="https://medium.com/@desilvabethmin/linux-mastery-4-command-structure-e8cdc8bc977b">Linux Mastery #4 : Command Structure</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5721771eb7fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Mastery #2 : Basic Commands]]></title>
            <link>https://medium.com/@desilvabethmin/linux-mastery-2-basic-commands-60edffe3133c?source=rss-3edf04a73a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/60edffe3133c</guid>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[commands]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Januda Bethmin]]></dc:creator>
            <pubDate>Tue, 04 Jun 2024 05:33:28 GMT</pubDate>
            <atom:updated>2024-06-04T08:54:02.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Mastery #2 : Basic Commands</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rvVrlXsSEQU1ZyfjNChk3A.jpeg" /></figure><p>Terminal is a potent tool that allows you to issue commands to the computer. The computer will obey these commands and make stuff happen.</p><p>After we write the command in the terminal, we must press <strong>enter </strong>to execute the command.</p><h3>Running your first Linux commands</h3><p>Prints out what we give as input on the terminal</p><pre>echo Hello</pre><figure><img alt="Image of echo command on the linux terminal" src="https://cdn-images-1.medium.com/max/1024/1*SVL18tgwHxIFtl_QgbLYZQ.png" /></figure><p>Show a calendar for the current month with the current date highlighted on the terminal</p><pre>cal</pre><p>There are many ways to customize the behavior of a command.</p><ol><li>Giving an<strong> Input</strong></li><li>Giving an <strong>Option</strong></li><li>etc. <em>( In upcoming stories )</em></li></ol><p>Show a calendar of a selected year with the current date highlighted on the terminal</p><p>Giving an Input</p><pre>cal 2024</pre><p>Giving an Option</p><pre>cal -y</pre><p>Show details about the date, time, timezone, and year on the terminal</p><pre>date</pre><p>We can clean up everything in a terminal window by the following command</p><pre>clear</pre><p>Because the clear command is often used, there is also a keyboard shortcut.</p><p><strong>Ctrl + L / Command + L</strong></p><p>When you want to enter a command you entered previously without having to type it out again, we can use the keyboard&#39;s<strong> up and down arrow keys</strong>.</p><p>Also, you can view the whole command history using the history command.</p><pre>history</pre><p>As a result of the above command, you will get a list of all used commands with the associated line numbers. You can use those line numbers to call a specific command easily.</p><pre>!1</pre><p>To run the most recent command that we ran, we can use the following command.</p><pre>!!</pre><figure><img alt="Image on how to use the history command and the other sub commands" src="https://cdn-images-1.medium.com/max/1024/1*5b39KmTDcRMwtFEDIVrD_Q.png" /></figure><p>This history file can get quite a bit long with time. So, you would need a way to clear the history.</p><p>We can use <strong>-c </strong>and <strong>-w</strong> options for this. This clears the history, then writes those changes and makes them permanent.</p><pre>history -c; history -w</pre><p>Instead of using the GUI or the Keyboard Shortcuts, we can use a command to exit the terminal too.</p><pre>exit</pre><p>Next →<a href="https://medium.com/@desilvabethmin/linux-mastery-3-commands-shell-terminal-5721771eb7fe"> Linux Mastery #3 : Commands, Shell, Terminal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60edffe3133c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>