Skip to main content

Posts

Linux Tip : How to Switch user as root if you have Sudoers access

Today we will see how one can become a root user if he / she has sudoers access. In some organizations if you try to switch user to root ( sudo su - root ), you may see error like below : Sorry, user <username> is not allowed to execute '/bin/su - root' as root on <hostname> But you can try other method to switch as root user. Lets look into those steps. Method 1 : Type  sudo vi -c '!bash' in the command line console and that's it. Method 2 :   Type   sudo vi a.txt  in the command line console , it will open vi editor just press ESC (Escape) and then :sh and Enter Hope you all enjoyed this little hack, do share your queries in the comment box below.

PowerShell Tip : How to find Host node name from inside the VM

Let's assume a scenario where you are inside the Virtual Machine but you want to the know the Host node name. Unless you maintain some inventory management system, it would be a troublesome job to identify the same. Here is how this can be achieved using Powershell. Just run the below one-liner on the VM : (Get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")

Kubernetes and Docker Notes

What is Kubernetes ? Kubernetes (K8s) is a container orchestration tool, which helps to manage, deploy and scale containers like Docker etc. Kubernetes was designed by Google using Go Lang. What is Docker ? Docker is an open source project that automates the deployment of applications inside containers. What are Containers ? ⚡Containers are basically layer of Base image and application image, stacked together with all their necessary dependencies and configuration. ⚡Containers are portable and scalable.  Docker Public Repository :   https://hub.docker.com/ How to install Docker on Windows  ? Note : Hardware Virtualization should be enabled on the host box in order to install Docker.  1. Go to the link =  https://docs.docker.com/desktop/windows/install/ 2. Download and Install the application To verify if installation was successful or not, just type :  docker run hello-world while running the above command I got the below error, it was because I didn't run...

Powershell Tip : How to fetch public ip using Powershell Console

There are several ways to fetch your public ip like below : But today we are going to see the simplest way to fetch the same via Powershell console : Command : (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content

How to check if SPF Record is valid or not ?

Before starting, lets understand what is SPF Record and its uses ? SPF Record is a Sender Policy Framework record. It is used by the mail servers to identify if the mails are coming from an authorized hosts or not. This helps to prevent spammers from sending mails using the Fake From address of your domain. Always avoid to keep multiple SPF Records for a domain. You can use the below domains to create or check if SPF Record is valid or not : 1. Create and check SPF record online (spf-record.com) 2. Free SPF Record Checker - Check SPF Record - SPF Record Lookup - DMARCLY 3. SPF Query Tool (kitterman.com)

How to see remote changes before doing Git Pull

Before going through the steps, lets first understand what is the purpose of GIT Pull ? In simple terms, GIT PULL is a GIT Command which access the Remote repository and checks which all files were modified or created and is different from the local repository. Once it finds that info, it downloads those file to your local repository.  Technically speaking, GIT Pull runs 2 commands i.e GIT Fetch and GIT Merge in background. GIT Fetch downloads the latest change to the local repository while GIT Merge merges the remote content refs and heads to new local merge commit. so you can say the below is same : GIT Pull <remote> -or- GIT Fetch <remote> GIT Merge origin/master So lets begin with the steps on how to see the remote (origin/master) changes before doing Git Pull :  Git fetch origin Git log master..origin/master Git diff master..origin/master Git pull / Git merge origin/master Happy Leaning! How to get started with GIT in Windows : Check out here

Powershell Tip : How to find the IP Address of a VM from a HyperV

Today we are going to see how to fetch the IPv4 Address details of a VM from a HyperVisor console. We will be using Powershell to achieve the same with a One-Liner code.  You can modify the Command as per your need. Our requirement is to check Only the Running VM's and  get the VM Name and its corresponding IPv4 Address. So lets get started. CODE (Execute in HyperV ): Get-VM | ? State -eq "Running" | select Name, @{l="IPv4Address";e={($_.NetworkAdapters.IPAddresses -match "(?<Address >((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))")} } CODE DETAILS : 1. Get-VM : Fetches the VM List present on the HyperVisor 2. ? State -EQ "Running" : It is similar to Where-Object {$_.State -eq "Running"} , here we are using where-object to fetch only the Running VM list from the Pipeline. 3. NetworkAdapters properties of the VM Contains the IPAddresses information, we are using IPv4 address Regex to get ...