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 panic if your "Free" memory looks low! Linux uses "Free" RAM for buff/cache to speed up your system. As soon as an app needs it, Linux will claw it back.

 

2. The "Deep Dive" Method: /proc/meminfo

For those who want to see exactly what the kernel sees, you can peek directly into the virtual file system.

cat /proc/meminfo

This provides a massive list of metrics, but you usually only need these three:

  1. MemTotal: Your hardware/instance limit (Max).

  2. MemAvailable: An estimate of how much memory is available for starting new applications (Current usable).

  3. SwapTotal: Your "emergency" memory on the disk.


3. The "Scripting" Method: One-Liners

If you are writing a script or just want a single number without the fluff, use these grep commands:

  • To see your Max RAM:

    grep MemTotal /proc/meminfo
    
  • To see current usage vs total:

    free -h | grep Mem
    

 

Comments

Popular posts from this blog

How to build MCP Server and use MCP Inspector in Node

How to install ngrok in wsl for activepieces