Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.7: Handy command-line network traffic utility System 10.7
Ever wonder what's using your internet connection? If you have LittleSnitch you're already there with a nice GUI, but if you're logged on to the system remotely or prefer CLI commands check out 'nettop' in OS X Lion. I noticed this when I was looking for any new network utilities in Lion. This command wasn't there in Snow Leopard or before.

I usually compile and install mtr, ntop, trafshow and other networking tools, but it's not always the safest thing to compile and install executables as root downloaded from the Internet.

Open a Terminal window, and then type nettop. You can also type:

man nettop or nettop --help for more command options.

The nice thing about this vs. other utilities is that it works as a normal user. If you put your Terminal session into fullscreen mode and have a large display (1920x1200 for me) you can see a ton of info about network connections, traffic from to, ipv4 and ipv6, tcp or udp and routing changes.

[crarko adds: As the name of the command implies, this is like top for network activity instead of CPU usage for local processes. I also checked in Snow Leopard and it wasn't included there. I think it's like 'nethogs' for Linux.]
  Post a comment  •  Comments (9)  
  • Currently 3.67 / 5
  You rated: 4 / 5 (6 votes cast)
[31,299 views]  View Printable Version
10.7: Using two Time Machine backups System 10.7
Rotating Time Machine backups has never been easier as of 10.7. Apple included in Lion a command-line interface for Time Machine which makes it completely scriptable. For the complete details on the command-line interface take a look at the man page for tmutil.

I use two Time Machine backups (see my backup strategy below for my complete backup solution) one at home and one at work. Using MarcoPolo you can set triggers and actions to automatically switch your Time Machine destination.

At home, and at work, I have 10.7 Server setup running the Time Machine service. Using MarcoPolo my laptop can determine its location, work or home, and set the IP address for my server appropriately. The following are the details on how to set this up for a Time Machine destination of an AFP share point. With small changes, this will also work for a Time Machine destination of an external hard drive.

Note: To alter these instructions to use a local external hard drive, change the following tmutil commands to this format:

tmutil setdestination mount_point

where mount_point is the path to your external hard drive.

Time Machine Setup

First we need to create two scripts. I have stored mine in /usr/local/bin. I used the nano editor in Terminal to create the scripts; you could also do this with BBEdit or TextWrangler if you're more comfortable with those editors. The two scripts will use the tmutil command to switch the destination. To create your first script enter this command into Terminal:

sudo nano /usr/local/bin/

Paste the following into the nano editor:
#This will change your Time Machine setting the backup to your home server
sleep 5
tmutil setdestination afp://username:password@
sleep 5
tmutil startbackup
The important line here is the tmutil command which is new as of 10.7 Lion. You will have to change the username, password, IP address, and AFP share point name to match your specifics for your home setup. Once you have those altered press Control+o to save the changes and then Control+x to exit nano. Next we need to create the second script:

sudo nano /usr/local/bin/

Paste the following into the nano editor:
#This will change your Time Machine setting sot backup to your work server
sleep 5
tmutil setdestination afp://username:password@
sleep 5
tmutil startbackup
Once again save the changes for your script and quit nano. Now we will make these scripts executable with the following commands:

sudo chmod +x /usr/local/bin/
sudo chmod +x /usr/local/bin/

You can test that these work by issuing this command:

sudo /usr/local/bin/


sudo /usr/local/bin/

In System Preferences » Time Machine you should now see that your destination has changed.

MarcoPolo Setup

MarcoPolo development has stopped but it is currently working for me in 10.7.1. Once you have MarcoPolo downloaded and installed you will need to setup at a minimum two Contexts. I have Work and Home.

For Evidence Sources, I use WiFi which I have very high confidence in because I have never seen another WiFi network with the same MAC address as mine. For rules, you have to create one for Home and one Work (using the plus (+) button in the lower left) using the WiFi evidence. And under Actions, again using the plus (+) button, you can add a Shell Script Action for Home and Work. When you select the Shell Script Action, an open dialog box opens and you will need to select the shell script we created earlier. If you placed yours in /usr/local/bin like I did, you will not be able to browse there because /usr is an invisible directory. But you can press Command+Shift+G while the Open dialog box is open and it will allow you to type in the directory you want to browse.

Once the two actions are enabled, your Time Machine destinations should change dynamically based on your location. You can always verify what your current settings are by looking in System Preferences » Time Machine.

If you have trouble setting this up or questions please post a comment.

This post inspired me to figure out how to create rotating backups in 10.7 Lion.

[crarko adds: I haven't tested this one. There was another use for the tmutil command mentioned in this hint.]
  Post a comment  •  Comments (14)  
  • Currently 3.43 / 5
  You rated: 1 / 5 (7 votes cast)
[18,829 views]  View Printable Version
10.7: Re-install from restore partition in a manual IP environment System 10.7
This small hint may be of some help when you have to reinstall Lion from a recovery partition in a network environment that does not have an active DHCP server. In this case, a small intervention in the Terminal is required.

Once you've booted into the Recovery partition, open Terminal by clicking its icon in the Utilities menu. Then:
  • Get a list of the network interfaces for the Mac you are installing Lion on:

    networksetup -listallnetworkservices

  • Set up the network interface, as listed by the output of the command mentioned above (Ethernet or otherwise):

    networksetup -setmanual {INTERFACE NAME} {IP ADDRESS} {SUBNET MASK} {ROUTER}

  • Set the name (DNS) servers:

    networksetup -setdnsservers {YOUR DNS SERVER}

  • Verify that the changes have been correctly saved:


    Examine all the entries and find the one you have actually worked on (ex. en0 is generally, but not always Ethernet).
  • Quit Terminal and continue with your installation by following the onscreen steps.
  • Wait for the download to finish.
  • Enjoy your freshly downloaded Lion!

[crarko adds: I haven't tested this one. The man page for networksetup provides more information on the available options.]
  Post a comment  •  Comments (1)  
  • Currently 3.57 / 5
  You rated: 3 / 5 (7 votes cast)
[6,477 views]  View Printable Version
10.7: Customize System Preferences System 10.7
In Lion you can customize which preference panels are shown in System Preferences.

Open System Preferences. Click and hold on the 'Show All' button and a list of preferences appears. At the bottom of the list, there is a 'Customize...' item that allows you to hide System Preferences using check boxes. This didn't exist in Snow Leopard.

[crarko adds: Yup, it's there. It's easy to turn visibility off and on, but curiously, it doesn't look like you need to authenticate to make those changes.]
  Post a comment  •  Comments (7)  
  • Currently 4.14 / 5
  You rated: 3 / 5 (7 votes cast)
[7,017 views]  View Printable Version
10.7: Using FileVault2 to encrypt a second hard drive with user folders System 10.7
FileVault2 is an excellent addition to Lion. Amusingly though, Apple has done exactly the same thing as Microsoft did when it introduced Bitlocker in Vista (which it corrected with Windows 7). Apple has made it easy to encrypt the system drive, and difficult to encrypt other drives.

This hint describes how to place a user home directory on a FileVault2 encrypted partition on a second hard drive and have that partition load automatically on boot.

The primary issue is that when the user home directory is on a secondary encrypted drive it will not automatically unlock when the user logs on, thus resulting in a logon error for that user. Once unlocked the partition with the user home directory will automatically mount.

Note: Once these operations have been performed, Disk Utility cannot be used to modify the second disk. Terminal and diskutil need to be used instead.

  • An OS X Lion installation with a FileVault2 encrypted system disk (System Preferences » Security & Privacy » FileVault).
  • A second hard drive using a GUID Partition Table and a Mac OS Extended partition. We will assume in the examples that the partition is named 'Data HD.'
  • An admin user in the /Users folder on the system drive.
  • A standard user with their home directory in the /Volumes/Data HD/Users directory and advanced user properties specifying that location as their home folder. There are hints about how to do that; search if you need to find them.
Once you have all that, here are the instructions for setting up the encryption:
  • Logoff all users.
  • Login as the admin user.
  • Start Terminal.
  • Use diskutil to determine the IDENTIFIER of the Data HD partition:

    diskutil list

  • Using diskutil and the following command convert Data HD to be an encrypted volume. Ensure you keep a copy of the passphrase in a safe place. If you lose it you will not be able to get your data from the partition.

    diskutil coreStorage convert [IDENTIFIER] -passphrase [passphrase]

  • Reboot.
  • Try to Logon as the normal user. You should see an error that you cannot logon. Note: I only tested after the disk fully encrypted, so the behaviour on a partially encrypted drive is not tested. I am assuming it has the same behaviour as an encrypted drive.
  • Logon as the admin user.
  • When asked for the password to unlock Data HD enter your password and save it to your Keychain.
  • Open the admin user's Keychain using /Applications/Utilities/Keychain Access.
  • Unlock the System Keychain
  • Copy the Keychain password from the admin user Keychain to the System Keychain.
  • Create a plist to automatically unlock Data HD (see below).
  • Using diskutil note the UUID of the encrypted partition.

    diskutil coreStorage list

  • Create the file /Library/LaunchDaemons/filevault2.unlock.plist using the contents below. Replace [UUID] and [passphrase] with your values. Saving the [passphrase] in the plist is the reason the system disk must also be encrypted. If it were not, a malicious user could simply read your passphrase from the system disk.
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
      <plist version="1.0">
  • 16. Reboot and logon as the normal user. Logon should now work.

[crarko adds: I haven't tested this one. I'd suggest trying this one with a test system and user to get comfortable with the process before trying it on a production machine. At minimum, have a known good backup of everything.]
  Post a comment  •  Comments (5)  
  • Currently 4.00 / 5
  You rated: 4 / 5 (5 votes cast)
[15,199 views]  View Printable Version
10.7: How to get a full Lion install disc for a new MacBook Air or Pro System 10.7
I've found a way to get a full Lion installer by capturing the installer files that the recovery partition downloads. This seems to work on my 2008 MBP machine with the App Store version of Lion installed on it, but it should be of particular interest to users of the new MacBook Airs and MacBook Pros which don't come with an install disk, but can't install the App Store version of Lion. By following this hint, it should be possible to get a full Lion install disk for those machines that won't require network access to install.

To avoid messing up your one and only good Lion installation, I recommend getting an external drive big enough to install Lion on. An external hard drive or separate partition is great. A large USB flash drive might work, but I haven't tried it.

As we all know, the Recovery HD lets you reinstall Lion by downloading it from Apple's servers. Unfortunately, it deletes itself after installation, so it doesn't give you a chance to make a boot disk that doesn't involve network access. However, it is possible to capture the installer and interrupt the install, so that it doesn't get a chance to delete itself.

Here's what to do:
  • Open the Terminal, and type this command to list all partitions on your hard drive or SSD:

    diskutil list

  • Look for 'Recovery HD' in the list, and note its identifier. It will be something of the form diskXsY, where X and Y are numeric digits. (On my machine, it's disk0s3).
  • Type the following command to mount the recovery HD:

    diskutil mount readOnly /dev/[identifier]

  • Replace [identifier] above with the identifier from step 2. So on my machine, I typed:

    diskutil mount readOnly /dev/disk0s3

  • The disk image inside the recovery HD is invisible, so use the Terminal to mount that too:

    hdiutil attach "/Volumes/Recovery HD/"

  • Now, from the newly mounted Mac OS X Base System image, double-click the 'Install Mac OS X' application at the root of the disk. Surprisingly, it launches, even when booted into a standard Mac OS X user account from the hard drive!
  • Go through the license agreement. Once it asks you for a disk to install on, choose the external drive or spare partition. (Or the boot partition if you're feeling gutsy. As long as you don't let the installer reboot, it shouldn't be able to install anything, but I like to err on the side of caution.)
  • Enter your admin password when prompted, and the installer will start downloading.
  • Open an old-style (non-autosaving) application that still uses the traditional Save, Save As..., etc. commands in the File menu (I used TextWrangler) and make a new unsaved document, and type a few things in it. This will give you a little insurance against the installer rebooting the system, since the app won't let the system reboot until you respond to its message asking whether you want to save the document or not.
  • The installer will start downloading some packages into a folder called Mac OS X Install Data on the root of the drive you're installing onto. Of the files it puts in there, the interesting item is a package with a funky name (on my system, it was 'mzm.stuhjljp.pkg'). It will be the file in the folder with the largest file size. Once the file finishes downloading, the installer will extract the InstallESD.dmg image from it and delete the package. This will be fine as long as you don't let the app restart your machine.
  • Wait for the download to finish. This will probably take a while, as it's a very large download.
  • Once the installer finishes download and prompts you to restart your Mac, force-quit it. Do this quickly, as it may automatically reboot for you after a timeout period (although if you've got an unsaved document open, you should be able to prevent that).
  • You should now have a file called InstallESD.dmg in the Mac OS X Install Data folder. You can burn this to a DVD, or image it to a USB flash drive to create a boot disk.

[crarko adds: I second the recommendation to try this with an external drive first while perfecting the execution of the process.]
  Post a comment  •  Comments (37)  
  • Currently 3.67 / 5
  You rated: 3 / 5 (12 votes cast)
[121,260 views]  View Printable Version
10.7: Go back and forward on Pictures screen savers System 10.7
I was so excited to stumble across in Lion that Apple has implemented the ability to go backward (and forward) in at least the MobileMe Pictures screen saver.

When the screen saver is displaying pictures simply press the Left arrow key to go back and Right arrow key to go forward.

[crarko adds: It looks like this works with all the Picture modules. On Snow Leopard hitting the arrow key just dismisses the screen saver.]
  Post a comment  •  Comments (3)  
  • Currently 3.25 / 5
  You rated: 3 / 5 (4 votes cast)
[3,811 views]  View Printable Version
10.7: Restore Tap-Drag System 10.7
It appears that Lion got rid of the Tap-Drag function, where you tap your trackpad, release, tap again and hold to drag around items.

Fortunately, Apple just moved the setting to an obscure place in System Preferences. Just head to Universal Access » Mouse & Trackpad » Trackpad Options and enable 'Dragging (with/without) Drag Lock' (the second checkbox) to restore the old behavior.

[crarko adds: It also shows an iOS-like badge with the number of items that you are dragging.]
  Post a comment  •  Comments (4)  
  • Currently 3.14 / 5
  You rated: 1 / 5 (7 votes cast)
[16,581 views]  View Printable Version
10.7: Keyboard Shortcut for Fast User Switching System 10.7
I have been using this hint until it broke in Lion. (See the last comment in that hint.)

After not being able to find a complete solution, I came up with this:

*Please note that this is not a secure solution. Your account password is stored in plain text, just as in the original hint.*

There is a way to collect the password from the keychain (see the above link and read through the comments), but I don't quite understand that just yet.

Also, this comes with the usual use at your own risk and I am not responsible if your computer explodes warnings.
  • Open Automator
  • Select Application
  • In the left column select Utilities
  • In the centre column drag Run AppleScript to the area on the right
  • Copy and Paste this code, changing USERNAME and PASSWORD accordingly:
      on run {input, parameters}
      set theUser to "USERNAME"
        set theUser to do shell script "/usr/bin/id -u " & theUser
        do shell script "/System/Library/CoreServices/Menu\\ Extras/ -switchToUserID " & theUser
        tell application "System Events"
          set token to "1"
          repeat while token = "1"
            if exists process "SecurityAgent" then
              delay 1
              keystroke "PASSWORD"
              keystroke return
              set token to "0"
            end if
          end repeat
        end tell
        return input
      end run
  • Go to the File menu and select Save...
  • Make sure the File Format is Application
  • Type in the name you select where you wish to save the App.
  • Assign a keyboard short cut in your favourite launcher App. In my case, I have assigned Control+Option+a with Quicksilver.

[crarko adds: This does work, but pay attention to the caveat about storing the plain text password. If you extend this to get the password from the Keychain please post your addition in the comments.]
  Post a comment  •  Comments (9)  
  • Currently 3.25 / 5
  You rated: 4 / 5 (4 votes cast)
[16,422 views]  View Printable Version
10.7: Exposť with Mouse Pointer over Dock icon System 10.7
Here's an easy way to check other app windows without really leaving the app you are in.

If you have your mouse pointer hovering over an application icon in the dock and you invoke App Exposť with a four-finger downward swipe, 10.7 will show the application windows open in that app and not for the app that is currently in focus. A four-finger up swipe will return you to the focused app.

For example, if you are in Mail and your pointer is sitting on the Safari icon in the dock, all of the Safari windows will be exposed.

[crarko adds: This took me a few tries to get working successfully, but as with many gestures practice makes it go fairly smoothly.]
  Post a comment  •  Comments (2)  
  • Currently 2.40 / 5
  You rated: 1 / 5 (5 votes cast)
[4,052 views]  View Printable Version