How to mimick the "free" command used in Linux in OS X.

Joined
Dec 22, 2010
Messages
5
Reaction score
0
Points
1
Location
Southern California
Your Mac's Specs
Model Name: iMac Model Identifier: iMac11,2 Processor Name: Intel Core i3 Processor Speed: 3
I have a lot of friends who started out learning about unix command line concepts using linux. And many of them are now migrating over to Mac OS X. They are used to using the "free" command to look up ram/memory statistics using terminal in linux.

I found a python script written for Mac OS X that sort of mimics this command. I normally just use "top", or "vmstat" command myself. However, this is a pretty cool little python script and might be handy in someones OS X terminal toolbox out there.

I have attached the script. Feel free to tweak it, modify it. Share with us any improvements you can muster. Have fun!

Just download the program attachment. I called it free.py.txt
Now be sure to "cd" into the directory that the new free.py file is at.
For example I placed the file in my Documents2 directory so to get there just enter at the terminal:

:$ cd /Documents2

Now you need to change the name to "free.py" to make it usable by the built in python interpreter by using the "mv" command in your terminal:
:$ sudo mv free.py.txt free.py

Then make it executable by entering:

:$ chmod +x free.py

Now type the following command in your terminal:

:$ python free.py

Below I put an example of what the output looks like on my terminal.

Enjoy!

raul-ruizs-imac:documents2 ruizfamily$ python free.py
Wired Memory: 311 MB
Active Memory: 555 MB
Inactive Memory: 387 MB
Free Memory: 2525 MB
Real Mem Total (ps): 596.910 MB

View attachment free.py.txt
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top