Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine values of several system variables in the terminal in a Mac

I'm on a Mac. In the terminal, how would you figure out each of the following values?

  • Word size (64 bit vs. 32 bit)
  • L1/L2 cache size
  • Determine how much memory is being used (like df, but for RAM)

Thanks! I know you can find these in Activity Monitor, System Profiler etc. but I am trying to boost my knowledge of the terminal, and UNIX.

like image 630
Kevin Burke Avatar asked Mar 26 '11 23:03

Kevin Burke


People also ask

How do I find system variables on a Mac?

On Mac or LinuxLaunch Terminal or a shell. Enter printenv. A list of all the environment variables that are set is displayed in the Terminal or shell window.

How do I find system information on Mac Terminal?

System Information can also be accessed by using the "system_profiler" command through macOS's Terminal application.

How do I find the value of an environment variable in Terminal?

To display the values of environment variables, use the printenv command. If you specify the Name parameter, the system only prints the value associated with the variable you requested.


1 Answers

System Profiler is a GUI wrapper around /usr/sbin/system_profiler.

mress:10008 Z$ system_profiler -listDataTypes 
Available Datatypes:
SPHardwareDataType
SPNetworkDataType
SPSoftwareDataType
SPParallelATADataType
SPAudioDataType
SPBluetoothDataType
SPCardReaderDataType
SPDiagnosticsDataType
SPDiscBurningDataType
SPEthernetDataType
SPFibreChannelDataType
SPFireWireDataType
SPDisplaysDataType
SPHardwareRAIDDataType
SPMemoryDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrintersDataType
SPSASDataType
SPSerialATADataType
SPUSBDataType
SPAirPortDataType
SPFirewallDataType
SPNetworkLocationDataType
SPModemDataType
SPNetworkVolumeDataType
SPWWANDataType
SPApplicationsDataType
SPDeveloperToolsDataType
SPExtensionsDataType
SPFontsDataType
SPFrameworksDataType
SPLogsDataType
SPManagedClientDataType
SPPrefPaneDataType
SPStartupItemDataType
SPSyncServicesDataType
SPUniversalAccessDataType
mress:10009 Z$ system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: iMac
      Model Identifier: iMac10,1
      Processor Name: Intel Core 2 Duo
      Processor Speed: 3.33 GHz
      Number Of Processors: 1
      Total Number Of Cores: 2
      L2 Cache: 6 MB
      Memory: 16 GB
      Bus Speed: 1.33 GHz
      Boot ROM Version: IM101.00CC.B00
      SMC Version (system): 1.52f9
      Serial Number (system): QP0241DXB9S
      Hardware UUID: 01C6B9E9-B0CB-5249-8AC7-069A3E44A188

You can also get some useful information from /usr/sbin/sysctl (try sysctl -a).

mress:10014 Z$ sudo sysctl -a | grep cache
Password:
hw.cachelinesize = 64
hw.l1icachesize = 32768
hw.l1dcachesize = 32768
hw.l2cachesize = 6291456
kern.flush_cache_on_write: 0
vfs.generic.nfs.client.access_cache_timeout: 60
vfs.generic.nfs.server.reqcache_size: 64
net.inet.ip.rtmaxcache: 128
net.inet6.ip6.rtmaxcache: 128
hw.cacheconfig: 2 1 2 0 0 0 0 0 0 0
hw.cachesize: 17179869184 32768 6291456 0 0 0 0 0 0 0
hw.cachelinesize: 64
hw.l1icachesize: 32768
hw.l1dcachesize: 32768
hw.l2cachesize: 6291456
machdep.cpu.cache.linesize: 64
machdep.cpu.cache.L2_associativity: 8
machdep.cpu.cache.size: 6144
like image 168
geekosaur Avatar answered Sep 24 '22 08:09

geekosaur