Posts

How to use Grep Command

  The grep command is one of the most useful tools in Linux/Unix for searching text. It scans files or streams line by line and prints the lines that match a given pattern. 🔑 Basic Syntax grep [options] pattern [file...] pattern → the text or regex you want to search for file → the file(s) you want to search in 📘 Common Examples Search for a word in a file grep "error" logfile.txt → Shows all lines in logfile.txt containing the word error . Case-insensitive search grep -i "error" logfile.txt → Matches Error , ERROR , error , etc. Search recursively in a directory grep -r "TODO" ./src → Finds all lines with TODO in files under ./src . Show line numbers grep -n "main" program.c → Displays matching lines with their line numbers. Count matches grep -c "error" logfile.txt → Prints how many lines contain error . Use regex patterns grep "^[0-9]" data.txt → Matches lines starting with a digit. ⚡ Usef...

Mastering Memory: How to Check RAM in Linux and WSL2

If you are running a Linux server or working within WSL2 (Windows Subsystem for Linux) , understanding your memory usage is critical. Whether you're troubleshooting a slow build or trying to figure out why your Windows host feels sluggish, knowing how to read your RAM stats is the first step. In Linux, "Free" RAM doesn't mean what you think it does. Here is the breakdown of how to check your current and maximum memory like a pro. 1. The "Quick Look" Method: free -h The free command is the standard way to get a snapshot of your system. Using the -h flag makes it "human-readable" (showing GiB and MiB instead of raw bytes). free -h How to read the output: Total: This is your Max RAM . In WSL2, this is limited by your .wslconfig settings. Used: What your applications are currently consuming. Available: The most important number. This tells you how much memory is actually left for new processes without the system slowing down. Pro Tip: Don't...

How to reclaim the space in WSL after folder deletion

Image
 Deleting files inside WSL is like throwing trash away inside a house—the house (the .vhdx file) doesn't actually get smaller on the outside until you "move the walls back in." To reclaim that space on your C: drive immediately , follow these steps. In powershell run the below command wsl --shutdown Restart your windows system. Run below command , replace the DistroName with your WSL Distro Name. wsl --manage <DistroName> --set-sparse true How to find the Distro Name: Run the below command in Powershell wsl -l -v Normally ubuntu will be the distro name.

How to know the path of ext4.vhdx in windows

Image
 Finding this file can be a bit of a scavenger hunt because the folder names are often long strings of random characters. The easiest way to find it is to use PowerShell to tell you exactly where it's hiding. Method 1: The "Automatic" Way (PowerShell) Copy and paste this command into a PowerShell window. It will spit out the exact path to your virtual disk: In powershell, run the command  Get-ChildItem -Path "$env:LOCALAPPDATA\Packages" -Filter "ext4.vhdx" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, @{Name="SizeGB";Expression={$_.Length / 1GB}}

How to see exactly which subfolders are the "space hogs" inside a specific directory in WSL

Image
 If you want to navigate through your folders and delete things on the fly, ncdu is the gold standard for WSL users. It feels like a simplified, terminal version of WizTree. Install it:  sudo apt update && sudo apt install ncdu Run it on your suspect folder: ncdu /path/to/your/folder If we wants to check in root of the repo, run below command ncdu ~ You can see the space of each folder like this.

Generate a self-signed certificate (for testing/development)

Image
Use OpenSSL to create a self-signed certificate: Step 1: Install OpenSSL (if not already installed)  # On Ubuntu/WSL sudo apt-get update sudo apt-get install openssl Step 2: Generate the certificate # Create certs directory mkdir -p certs cd certs # Generate a private key and certificate openssl req -x509 -newkey rsa:2048 -keyout signature-key.pem -out signature-cert.pem -days 365 -nodes # Convert to PKCS#12 format (.p12) openssl pkcs12 -export -out signature-cert.p12 -inkey signature-key.pem -in signature-cert.pem -name "Invoice Signing Certificate" When prompted: Enter a password for the .p12 file (To use in env variable) Fill in certificate details (or press Enter to skip) This will generate the certs file for you. Thank you.

How to connect to postgres database in activepieces

Image
In this post, we will see how to connect to postgres database in local activepieces development environment.  Add the Below mentioned env variables  Follow below link to install and setup postgres  https://simplelinuxlearnings.blogspot.com/2025/10/in-wsl-how-to-create-database-update.html Create a new database named activepieces like below. Now, start the application using npm start, your postgres  database should be utilized by activepieces.

In WSL How to create database , Update Password and connect the database in any application

Image
  Make sure, we have postgres installed, run below query to verify that. Run the below command to install  pg_ctlcluster utility command : sudo apt install postgresql postgresql-contrib Run the below command to start the postgresql manually Run the below command to postgres user sudo -i -u postgres psql Run command createdb my_database to create a new database Run the command psql -l to list the list of database  From your current prompt ( postgres@...$ ), enter the PostgreSQL shell: psql Now, paste this command to change the password for postgres user  ALTER USER postgres WITH PASSWORD 'your_secure_password'; Now we can see like below Type \q to exits the PostgreSQL shell and brings you back to the Linux terminal  I installed the below extension in visual studio Select postgresSQL and provide the database details with password and click on Connect button. Now, we can see the database details inside visual studio Lets Thank you!

How to generate a secure value for JWT_SECRET

How to Create a High-Strength JWT_SECRET A secure secret must be long, random, and unpredictable . Simple phrases, dictionary words, or short strings are easily brute-forced or cracked using common tables. A good secret should be at least 32 bytes long (which results in a longer Base64 string) and generated using a cryptographically secure pseudo-random number generator (CSPRNG). Generating a Strong Secret Use your operating system's built-in cryptographic tools to generate the string. On Linux/macOS (Bash): The openssl rand command is a reliable way to generate a strong random string. The -base64 32 flag generates 32 cryptographically random bytes and encodes them in Base64 for safe use in environment files. Bash openssl rand -base64 32 On Windows (PowerShell): PowerShell offers a secure way to generate byte arrays using the .NET Framework's RNGCryptoServiceProvider . This ensures the randomness is suitable for cryptographic purposes. PowerShell $bytes=New-Object Byte[] ...

How to move WSL from one drive to another drive

Image
 Hi, let's see how to move the WSL from C Drive to D Drive. Run the below command to check the WSL list Create a new folder inside D Drive Run command  wsl --export Ubuntu D:\wsl\ubuntu.tar to export ubuntu as tar file to D drive Un register ubuntu, using command wsl --unregister Ubuntu Move the ubuntu from the tar file to D Drive Run the below command to set ubuntu as default distro Run the below command to view the list of wsl distro. Now, we can see the ext4 file is moved to the D Drive. Thank you!.

Remove existing repository association in GIT

Image
  Use command  git remote -v to check which git repository the project is associated with, it will give output like below Use command  git remote remove origin , to remove the existing git remote association Use again  git remote -v ,   now you can see that association will be removed.

Install NVM in WSL and Node

 You can install NVM (Node Version Manager) in WSL pretty easily. Here’s the step-by-step: 1. Open your WSL terminal (For example, Ubuntu). 2. Install required dependencies sudo apt update sudo apt install curl wget git -y 3. Download and install NVM Run the official install script: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash (Replace v0.39.7 with the latest version if needed: https://github.com/nvm-sh/nvm/releases ) 4. Load NVM into your shell After installation, add this to the end of your ~/.bashrc (or ~/.zshrc if you use Zsh): export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" Then reload your shell: source ~/.bashrc 5. Verify NVM installation nvm --version 6. Install Node.js using NVM Install latest LTS version: nvm install --lts Install a specific version:...

How to use Localxpose alternative to ngrox

Image
Hi,   lets see how to use localxpose in linux machine Install Localxpose using below command   Create a account in localxpose( https://localxpose.io/ ) and copy access token from ( https://localxpose.io/dashboard/access)   Run the below command and it will ask to provide the access token, paste it. Now, run the below command to access the localhost 4000 using public URL.   It will provide the public URL. with this public URL we can access the localhost 4000 site.

How to check the storage details of WSL

Image
Run the below command to view the WSL Storage details  # Show disk usage of root filesystem df -h / # Show usage of all mounted filesystems df -h # Check disk usage of home directory du -sh ~ Output is like below

In Linux how to restrict to show last 2 path in terminal

Image
  Open your .bashrc file by running command nano ~/.bashrc Add this line at the end:  e xport PROMPT_DIRTRIM=2 Save and exit ( Ctrl + O , Enter , then Ctrl + X ). Apply the changes by running below command source ~/.bashrc

How to copy folder from windows machine to wsl

  Hi, In this post, we will see how to copy folder from windows to wsl folder. Use comand like below. Using mnt in wsl, we can access windows files cp -r "/mnt/c/Users/YourName/Downloads/SourceFolder" /home/wslusername/TargetFolder/ Example: cp -r /mnt/c/Users/bharathan/Downloads/Temp/* /home/admin/practice/Automation/Credentials/

How to remove initial commit in Git

To revert the initial commit when it is the only commit in the repository: Remove the Git repository's history use below command rm -rf .git

List of common commit types in GIT

Image
Here’s a common list of commit types you can use:

How to forcedly remove a repository in Linux

 Hi, In this post, we will see how to remove the repository forcefully in Linux go to the repository that you wants to remove using cd command cd jsonResponseStreamableHttp Execute the below command to remove it rm -rf jsonResponseStreamableHttp Now, the folder will be removed

How to build MCP Server and use MCP Inspector in Node

Image
  Run the below 3 command to create a new node project Run the below command to add required dependencies npm install @modelcontextprotocol/sdk axios dotenv Run the below command to add dev dependencies npm install --save-dev typescript @types/node Create  tsconfig.json  file in the root of the repository and paste the below code { "compilerOptions": { "target": "ES2022", "module": "Node16", "moduleResolution": "Node16", "outDir": "./build", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, "include": ["src/**/*"], "exclude": ["node_modules"]  }  Create a new folder named src in project root repository and create a file named index.ts and paste the below code  #!/usr/bin/env node ...