Delete Time Machine backups from the command line

You may know that you can enter Time Machine through the GUI and delete a backup. In some cases, under Mountain Lion, this results in an error, with a message saying "The operation can't be completed because backup items can't be modified." In some cases, deleting backups from the Finder won't work; you also may not be able to use the rm command to delete these backups, because they are handled in a special way. Finally, even if all goes well, you may want to delete backups on a remote Mac's Time Machine disk. There is an executable accessible from the command line that lets you delete these backups. To use this with Mountain Lion, run the following command: sudo /System/Library/Extensions/TMS​afetyNet.kext/Helpers/bypass rm -rfv /Volumes/[disk]/Backups.backup​db/[path] This command works with Lion: sudo /System/Library/Extensions/TMS​afetyNet.kext/Contents/MacOS/b​ypass rm -rfv /Volumes/[disk]/Backups.backup​db/[ ...

published on Friday, the 5. April 2013, macosxhints

Create "sticky" Time Machine exclusions

You can exclude certain files and folders from your Time Machine backups from the Time Machine pane in System Preferences; you can also do this from the command line. Run this command: sudo tmutil addexclusion [path] where [path] is a file or folder. For example, if I want to exclude my Downloads folder from Time Machine backups, I would run the following: sudo tmutil addexclusion ~/Downloads The tmutil addexclusion command has an interesting property: it's sticky. When you do this, the item you exclude remains in the Time Machine exclusion list even if you move it, which is not the case when you exclude items from the Time Machine preference pane. If you use the above command with the -p flag, then it will not be sticky, and will be the same as an exclusion you add from the GUI. [kirkmc adds: Updated to correct an error in the post. I've removed the comments that pointed out the error. Sorry!]

published on Wednesday, the 3. April 2013, macosxhints

Turn on hidden Siri feature in OS X 10.8.3 Stickies

Apparently Apple has included a pre-release version of Siri in 10.8.3. While I've gotten Siri to work in Stickies, it doesn't seem to be accessible from any other OS X apps. This may be a mistake; it may be testing code that was not removed from the final release, and this may explain why 10.8.3 went through so many betas. To turn on Siri in Stickies, run the following Terminal command: defau1ts write com.apple.stickies personalAssistant -bool true After you run this command, launch Stickies, and, while pressing the Option key, press the fn key twice. A small popup will appear in the current note with an icon similar to the Siri icon on iOS. Speak into your Mac's microphone - either an internal or external mike - and Siri will do your bidding.

published on Monday, the 1. April 2013, macosxhints

Change the Notification Center sound

I have to agree with Erica Sadun, at TUAW, who writes that Basso, the sound used by Notification Center, is horrid. It makes me cringe, and, because of this, I don't use sounds with Notification Center. But Sadun found that you can change the Notification Center sound with a bit of a hack. If you go to ~/Library/Sounds and place a sound in AIFF format there, and name it Basso.aiff, Notification Center will use that sound. You'll need to run the following Terminal command to relaunch Notification Center (or restart your Mac): killall NotificationCenter You'll have a much better sound for notifications. I really think Notification Center should not only allow users to change the default sound, but also choose specific sounds for different applications, the same way you can choose a specific ringtone for different callers on iOS.

published on Thursday, the 7. March 2013, macosxhints

Schedule "Do Not Disturb" for Notification Center

If you like Notification Center, in Mountain Lion, you may also like its "Do Not Disturb," feature, where you can turn off notifications if you're busy and they get to be a bother. There are a couple of ways you can do this: you can Option-click the Notification Center menu bar icon, or you can scroll down when Notification Center is visible, and toggle the slider to OFF. On iOS, you can schedule this action, but not on OS X. Ben Waldie, writing at TUAW, posted an interesting AppleScript/Automator solution to this. You can create an Automator workflow, and set it to run in Calendar, so you can have the Do Not Disturb feature turned on and off at specific times. It's a bit ham-fisted, to be sure; it uses a defaults write or defaults delete command, then a killall Notific ...

published on Tuesday, the 12. February 2013, macosxhints

Create default printer presets for multiple users

I was tasked with setting up a company's new printers and had to struggle with creating a default set presets that also used a PIN number login for accounting. This needed to be pushed out to the current user base, in real time, and without interrupting anyone's ability to print. Here's how I did it. Tools: CUPS server web interface to set the printer defaults ARD to install the drivers lpadmin to add the printer (We're using LPD on a Windows 2008 R2 server) ARD to copy the cups PPDs 1. Create the default settings: In Terminal, run this command: sudo cupsctl WebInterface=yes In a web browser, go to: http://localhost:631/admin 2. Install the drivers (.pkg files via ARD) 3. Add the printer using lpadmin: lpadmin -p SweetNewPrinter-7535-clr -L "Department" -E -v lpd://WindowsServer/SweetNewPr​inter-7535-clr -P /Library/Printers ...

published on Thursday, the 7. February 2013, macosxhints

Keep Yahoo IM Messsages accounts online

If you use a Yahoo IM account in Messages and have a MacBook, you'll find your Yahoo account won't go back online whenever the Mac awakes from sleep mode. Apparently, AOL IM accounts are affected in this way too. Here's one simple solution to the problem that uses crontab to run a simple Applescript that periodically takes all the accounts online. I write more about this on my blog, including a couple of caveats, but here are the basic steps: 1. Ensure Messages starts at login by right-clicking its Dock icon and Options > Open at Login. Remember that, in OS X Mountain Lion, apps not used for a while will appear to quit automatically, but don’t worry — these steps take that into account. 2. Open a Terminal window. You’ll find Terminal in the Utilities folder of the Applications list within Finder. 3. At the command-line prompt, type crontab -e 4. This ...

published on Wednesday, the 19. December 2012, macosxhints

Enable AFP Server Activity log on OS X Server

Apple has published a technical note explaining how to enable the AFP Server Activity log on OS X Server; this log is not enabled by default. Run the following command to enable this log: sudo serveradmin settings afp:activityLog=yes To disable the log, run this command: sudo serveradmin settings afp:activityLog=no

published on Monday, the 29. October 2012, macosxhints

See details of an app's virtual size

If you use top in Terminal, you may occasionally see apps with huge VSIZE values. I know this because Witch, one of our apps, is an example of such—it's VSIZE can exceed 11GB. In trying to figure out why this was so (short answer seems to be: we can't control it, but it's not a problem), I ran across an interesting command, vmmap. This command will spew out a ton of detail about virtual memory usage. Stringing a couple Unix commands together, though, you can extract just the summary portion of the report. In Terminal, run this command: vmmap -resident PID# | grep "Summary for" -A 999 Replace PID# with the process ID you're interested in observing, and you'll get a nice summary of its virtual memory state. You can see what's virtual, and what's actually resident. Here's a bit of the output for Witch, for example: ... REGION TYPE VIRTUAL RESIDENT ====== ...

published on Friday, the 19. October 2012, macosxhints

Send SMS to Messages and run commands with AppleScript

It is possible to send an SMS command to your Mac using an AppleScript. I've made one which takes a picture when I send the command /photo to iMessages on my Mac. The script is very simple; it must be set up Messages' Alerts preferences. Choose Event > Message Received, then check Run an Apple Script. This will check each message you get for the command; in this case, /photo. The script will turn the volume all the way down (and up again) before taking a picture with PhotoBooth so it does not make any noise. Then you can make a symbolic link from the PhotoBooth folder to your Dropbox so you can check the photos from your mobile device. Here's the script: using terms from application "Messages" on message received theMessage from theBuddy for theChat if (the ...

published on Tuesday, the 16. October 2012, macosxhints