Skip to main content


Linux Useful commands

Here are the list of some useful Linux commands that's used on a day-to-day work and are equally important for interview purposes.  1. How to check memory usage free -h -h is to make the result readable by humans. 2. How to check disk usage df -h 3. How to check CPU Usage top 4. How to quickly find the process id of a program pgrep <ProcessName> 5. How to find the Linux Kernal version uname -r amar@LPF22E8MA:~$ uname -r 4.4.0-19041-Microsoft 6. How to find the Operating System (OS) version cat /etc/os-release lsb_release -a amar@LPF22E8MA:~$ cat /etc/os-release NAME="Ubuntu" VERSION="20.04 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04 LTS" VERSION_ID="20.04" HOME_URL="" SUPPORT_URL="" BUG_REPORT_URL="" PRIVACY_POLICY_URL="" VERSION_C

PowerShell Tip : How to copy a file remotely using WINRM

Today, we are going to see how to copy a file to remote destination using WINRM. Traditionally SMB Protocol (File Sharing \\Servername\C$) was used to transfer the files but nowadays you will find SMB Protocol disabled on some servers so you will require firewall changes to perform that.  On the other hand WINRM Protocol 5985 is mostly open for Powershell Remote sessions, so we will use that to transfer the files. Lets get started : Step 1 : Create a PS Session for that server  $Session = New-PSSession -ComputerName <ServerName> Step 2 : Use Copy-Item with -ToSession to transfer the file using WINRM Copy-Item -Path C:\Scripts\Amar\TestFile.txt -ToSession $Session -Destination "D:\" TestFile.txt file will get copied from local system to the D Drive of the remote server. Happy Learning :)

ActiveDirectory : How to find unused AD User accounts using Powershell

Today we are going to learn how to remove an AD User which is not Active since a long time lets say 1 year. As a part of Server hardening best practices, you should always run checks to remove the disabled or orphan accounts from Active directory. We will be using the Active Directory module in Powershell to perform the activity : CODE :  $Date =(Get-Date).AddDays(-365) Get-ADUser -Filter 'LastLogondate -le $Date' -Properties LastLogonDate | Select Name, LastLogonDate To remove the ADUser use : Remove-ADUser -Identity "<SamAccountName>"

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 : 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 = 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 Docker desktop app with

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 "").Content