Junior — Middle
How can you determine the amount of available RAM in the system using command line?
sobes.tech AI
Answer from AI
The amount of available RAM in the system can be determined using various commands in the command line, depending on the operating system.
For Linux:
free -h— displays the total, used, and free memory in a human-readable format.cat /proc/meminfo— provides detailed information about memory.
Example output of free -h:
total used free shared buff/cache available
Mem: 7.7G 2.1G 3.5G 150M 2.1G 5.1G
Swap: 2.0G 0B 2.0G
For Windows:
systeminfo— displays system information, including physical memory.wmic MEMORYCHIP get Capacity— shows the capacity of each memory stick in bytes.
For macOS:
vm_stat— displays virtual memory statistics.sysctl hw.memsize— outputs the total amount of RAM in bytes.
Thus, the command depends on the OS, but generally, free -h (Linux) and systeminfo (Windows) are the simplest methods.