Flux»Tech


Mac OS X Tips

Useful bits and bobs for Mac users. Last updated 2013-07-20.

Introduction

These are a few of the Mac OS X commands I’ve found useful over the years. They have been tested on OS X 10.8 (Mountain Lion), but use them at your own risk.

2D Dock

If you prefer a simple 2D dock use the following command:

$ defaults write com.apple.dock no-glass -boolean true; killall Dock

To turn the 3D glass look back on:

$ defaults write com.apple.dock no-glass -boolean false; killall Dock

Make Library Visible

The Library directory within your home directory is hidden by default. You can make it visible with (replace username as appropriate):

$ chflags nohidden ~/Library

To hide it again:

$ chflags hidden ~/Library

Create an ISO Disk Image

You can make cross-platform UDF ISO disk image with the hdiutil command:

$ hdiutil makehybrid -udf -udf-volume-name <volname> -o <filename.iso> <src>

Spotlight Indexing

You can control Spotlight indexing with the mdutil command. The following examples disable indexing:

# turn off indexing a specific filesystem (replace <name> as appropriate)
$ sudo mdutil -v -i off /Volumes/<name>

# turn off indexing all filesystems
$ sudo mdutil -a -v -i off

It can easily be turned back on with the following commands, but the reindexing process may take some time:

# turn on indexing a specific filesystem (replace <name> as appropriate)
$ sudo mdutil -v -i on /Volumes/<name>

# turn on indexing all filesystems
$ sudo mdutil -a -v -i on

Local TimeMachine Backups

TimeMachine can store backups on your local disk, you can disable this with:

$ sudo tmutil disablelocal

You can re-enable local backups with:

$ sudo tmutil enablelocal

Compact Sparse Bundle Disk Images

Over time it’s likely a sparse bundle disk images will use more disk space than it needs to. You can compact a sparse bundle, even on battery power, with the following command (replace bundlename as appropriate):

$ hdiutil compact -batteryallowed <bundlename>

Mac Model and CPU

You can identify your exact model and CPU using the sysctl command:

$ sysctl hw.model
hw.model: MacBookAir4,1

$ sysctl machdep.cpu.brand_string
machdep.cpu.brand_string: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz

You can look up the details of the CPU on Intel ARK.

Filesystem Calls

The fs_usage reports system calls related to the filesystem. For example:

$ sudo fs_usage
18:53:41  getattrlist                                    0.000041   Finder      
18:53:41  lstat64           tlight/schema.501.scratch    0.000021   fseventsd   
18:53:41  lstat64           tlight/schema.501.scratch    0.000021   fseventsd   
...

Flush DNS Cache

You can clear your DNS cache by sending the DNS responder a HUP. You can confirm the cache purge by looking for a mDNSResponder entry in system.log.

$ sudo killall -HUP mDNSResponder
$ grep mDNSResponder /var/log/system.log
...
Dec 31 11:57:08 eider.local mDNSResponder[53]: SIGHUP: Purge cache

Update the Locate Database

To force an immediate update of the locate database, use:

$ sudo /usr/libexec/locate.updatedb

Scan for Wi-Fi Networks

You can scan for wi-fi from the shell with the airport command:

$ airport -s
            SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
 BTWiFi-with-FON 32:6b:d3:59:da:d2 -62  11      Y  -- NONE
          BTWiFi 32:6b:d3:59:da:d1 -62  11      Y  -- NONE
...

List Loaded Kernel Extensions

You can see the list of loaded kexts with the kextstat command:

$ kextstat 
Index Refs Address            Size       Wired      Name (Version) <Linked Against>
    1   67 0xffffff7f8074c000 0x686c     0x686c     com.apple.kpi.bsd (12.4.0)
    2    6 0xffffff7f80737000 0x46c      0x46c      com.apple.kpi.dsep (12.4.0)
...

Tags: Mac, OSX