+46 768 333 234 contact@creativit.se

Okay, so we had our introduction to the Terminal in OS X, let’s dig a bit deeper into what we can do with it and step up our game a bit. Apple is an awesome company and they have created this operating system that is very, very user friendly. But it comes with quite a large expense. When you are designing something user-friendly, you need to remove advanced options and settings. This is why you sometimes hear tech-savvy people say “ohh i don’t use apple and OS X since it doesn’t allow you to do stuff. It’s too dumbed down and I need to configure my machine to become a spaceship.”

Those people will probably not configure their machines to become spaceships simply because they missed out that almost everything in OS X is configurable if you know the right commands and they don’t know how to use terminal..
So let’s start of with some very basic things that Apple is doing over and over again.
Almost every service running in your OS X distribution is configured by a command called defaults.

Defaults let you write new settings to services and alter the configuration options that is not exposed on the surface of the panes.

Let’s go for a real world example of defaults.

terminal, OS XThe Time Machine that OS X is using is set to backup your computer once every hour. That is awesome news for most people sitting on the latest and greatest powerhouses from Apple, but for some like me that could have some severely performance penalties on my daily operations. The preference pane of TM is only allowing me to “turn off” or “turn on” the backup and not let me decide how many times a day this happens. I know the functionality is there, but it’s not exposed to me. This is a perfect time to fire up and use the terminal, write a single line and change it’s behaviour.

The following command will change the TM to backup every 2 hours instead:
sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 7200
The value TM wants is specified in seconds alas 7200 is number of seconds in two hours (3600 in one remember?)

Let’s break down what just happened on the line above. First, to alter something system related, we need to have some superpowers. We get that from the sudo command. If you don’t know what sudo means read my previous article explaining it. Then we issue the defaults command as superman and give it the parameter of write. This tells the defaults command that we want to write some new configuration to what comes next, the path to what service we want to alter. In this case, it’s the Time Machine located in /System/Library/LaunchDaemons/com.apple.backupd-auto.

Success to that is even more parameters telling the Time Machine to alter the configuration of StartInterval with an Integer (numeric) value of 7200 and save.

Easy right? Don’t be scared. As long as you understand the fundamental process that is going on here; superman wants to change com.apple.backupd-auto altering StartInterval and give it a new value. This is often where I ask myself like: How the heck am I supposed to know that command by heart? How does people know this stuff? How? Why? *insert-crumbeling-feeling-here*.
Well, you don’t. You search the internet for these things or read thru Apples documentation about the subject. Then you learn from trying it out or writing them a couple of times, or if you are more like me, remember the keywords to search for it again and be like “ahh that’s right, now I remember” whenever you need it.

Okay, so what more is there that we could want to alter in the operating system? Here is a couple of goodies that is tend to use every now and then.

sudo defaults write com.apple.finder AppleShowAllFiles TRUE
This will allow you to view all the hidden files that apple is trying to keep from you.

sudo defaults write /System/Library/LaunchAgents/com.apple.notificationcenterui KeepAlive -bool false

That will disable notification center popups in Mountain Lion and forward. Don’t forget to restart the Notification Center by issuing the command killall NotificationCenter
Did you make a mistake turning it off? Re-enable:

sudo defaults write /System/Library/LaunchAgents/com.apple.notificationcenterui KeepAlive -bool true
And so forth. If you want to learn more of the defaults this is a good place to go:
http://www.defaults-write.com/ It has a quite large stock of commands to use and configure OS X to the way you want it to behave.

This is just the tip of the iceberg when using the Terminal. OS X is jam-packed with these hidden configuration possibilities.
Thats all for this time! Keep on experimenting!