Useful Terminal Commands & Tips For Mac OS X

Mac OS X is built to be so user-friendly that anyone can use it, regardless of their level of experience when dealing with computers. However, delve beneath OS X’s shimmering surface by launching Terminal and you will find it possible to unlock hidden features, perform advanced tasks, tweak and troubleshoot your Mac.

This tutorial will discuss some of the best and most popular beginner-friendly Terminal tricks and tips to be found on the Internet.

Usually it takes destructive behaviour or terrible luck to ruin your Mac’s OS X installation beyond repair, but using the Terminal could potentially bypass such safety and enable a user to cause themselves serious headaches, or even (in extreme cases) a completely ruined operating system. This is very unlikely and as long as you steer clear from “sudo” commands which require you to enter your password, you should be perfectly safe. However, I strongly advise you to back up your Mac fully and proceed at your own risk!

Some tips may only work for a particular OS, though I’ve taken care to only select Terminal commands which should mostly work on Leopard, Snow Leopard and Lion.

Though OS X doesn’t really place much emphasis on hidden files and folders, some files and folders are hidden by default. This is usually for good reason and deleting the wrong thing can cause issues, but if you wish to show the hidden files, then enter the following code:

defaults write com.apple.finder AppleShowAllFiles true

To undo this command, replace true with false.

osxterminal-2ddock

If you’ve ever moved your Dock to the left or right of screen (depending on which OS X version you’re running), you may have seen the 2D Dock shown above. If you’d like to enable the 2D Dock in all positions, enter the following into Terminal:

defaults write com.apple.dock no-glass -boolean YES

Now restart your Dock to make the changes take effect by entering

killall Dock

To put your Dock back to normal, replace the “YES”‘ in the above code to “NO” and restart the Dock once again by entering the above killall command.

I’ve never been a big fan of the Dashboard as it’s something of a RAM hog and I like it to be completely disabled in case I accidentally launch it. If you would like to do so too, enter this into Terminal and hit return:

defaults write com.apple.dashboard mcx-disabled -boolean YES

Once again restart Dock to make the changes take effect.

killall Dock

To undo this command and bring back Dashboard, just change “YES” to “NO” and restart your Dock by entering the killall command once again (note: the killall command can actually be inserted into the same line of code to save time, I’m making it separate here to give you a sense of what exactly is happening).

OS X Lion comes with the Library folder hidden by default but this can make troubleshooting any issues with your Mac, deleting the cache or just plain “tinkering” very difficult. In order to bring back the Library folder permanently, enter this command into Terminal:

chflags nohidden ~/Library/

terminalcommands_desktop

A nice clean Desktop looks great but sometimes it’s not practical to keep all your files organised. If you’d like to hide all the icons on your Desktop through a Terminal command, enter the following:

defaults write com.apple.finder CreateDesktop -bool false

Then our friend the killall command once again

killall Finder

When you wish to bring your Desktop clutter back, copy and paste the following:

defaults write com.apple.finder CreateDesktop -bool true

Then enter the killall command.

In order to launch applications from the Terminal, just follow this template, replacing Twitter with the name of whichever program you’d like to launch:

open -a Twitter

If you need to quickly kill a process or application, type the following into Terminal, replacing Twitter with whichever process you’d like to kill.

killall Twitter

To quickly open a Finder window in whichever directory you’re currently in, enter the following into Terminal

open .

OS X’s built-in screenshot utility Grab is very useful but if you’d like it to save files as JPG, enter the following into Terminal:

defaults write com.apple.screencapture type jpg

(note: You can also change jpg to png if preferred).

I hope that you’ve found some usefulness from these Terminal commands and that it encourages you to learn more about the power which can be unlocked from within the command-line. You can usually find an application which takes care of each of the commands posted above, but that’s a lot less informative and a lot less fun!

For the command-line veterans amongst our readers; if you’ve got any Terminal commands or tips which I’ve missed (and I’m sure there are several), please let us know about them in the comments below.