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.

Disclaimer

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.

Show Hidden Files

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.

Enable 2D Dock

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.

Disable Dashboard

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).

Show The Library Folder In OS X Lion

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/

Hide Desktop Icons

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 -boolfalse

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 -booltrue

Then enter the killall command.

Launch An Application

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

Kill A Process

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

Open A Finder Window In Current Directory

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

open .

Change Grab’s Default Image Format

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).

Conclusion

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.

Do you like what you read here?

Receive the latest update in your inbox.

Or connect with us:

Similar Articles

2 comments

Jorge Diazsays

Thanks … Your command list helped me to find a folder and a file that the finder says it doesn’t exist. I am installing a program (Roambi ES4) that needs tomcat and mysql as prerequisites… I installed everything following instructions but when I try to access the program interface trough localhost i get an error message :

“A failure occurred connecting to the database. Please ensure a database exists for the given host and name of the connection string or correct the connection string in the “db” entry in the configuration file located at: /Users/jorgediaz/.roambi/config.json”

I had 1 week looking for the file… or at least trying to find the .roambi folder …. I also need to find a folder called “usr” in the root directory and the finder says it doesn’t exist…. When I tried to “make visible” the folder trough the terminal it says that the folder doesn’t exists…. Thanks to your command list I get the correct directory and open in the text editor the config.json file with the terminal using the open -e command that you explain in your page…

I almost made a complete backup of the files and erase the hard disk to reinstall osx lion thinking that I had accidentally erased the usr folder …Thanks to your commands i managed to know that the .roambi folder and the usr folder still actually exist and the config.json is either in the computer…

Thanks again but I want to know why is this nonsense behavior of the finder … Is my 2,800 US $ new macbook pro crashed ? or it is simply that I don’t know how to operate the finder… ???

I’m a switcher (my first computers were mac from 1985 to 1993 but after that I had to switch to windows because nobody was using mac at that time in my business area) … Now I came back to mac and really don’t understand yet the finder … it’s not intuitive … I’m not a moron neither a border liner…. although I am not a technician guy, but I consider myself a blackbelt user … nobody I know could do things I do with computers … (99% willing – 1% knowledge) and I don’t understand how could this be so hard to understand …

Now I see that everything in windows is easy… everything in windows have a wizard installer but for mac everything is a hard work … and worst .. a confusing one…. mostly because there is “n” folders located at different places called the same …. (library is one example of system duplicated name of folders) … nothing works with ordinary logic …. if you installs a program and then you type the program name in finder maybe you get no answers or get 1 million folders but no one can be easily identified as an executable application … so you never be able to know where is installed the application.. For example .. I installed mysql …. but I cannot know where is installed … it doesn’t appears in the application folder … there are 53 thouthand folders named mysql in the computer but no one contains nothing that you could say it is an executable application… if you download a file from internet to install a program it is downloaded to the DOWNLOADS folder.. but after you double click it the download is erased without getting your permission… so .. if you want to reinstall it you have to redownload it … in some cases …. and in other cases the new file you download doesn’t overwrites the older … but downloads a new one in the same folder with a sequential number putted in the middle of the name …. IN THE MIDDLE OF THE NAME???? that is crazy … sometimes you redownload the application and you say install… so you think the folder of the application will be substituted with the new one… but after you tell the installer to run… nothing happens in the older folder (you previously made a modification in the name of a folder inside the app folder) … Another thing is that I cannot be wise enough to make the finder to show the path of the files it is showing … that is somehow a critic info … and you don’t have it … well … I am almost start crying …

I have always had the feeling that I was pushed to switch to windows by circumstances but that the real thing was mac …

Now I am not sure that switching again to mac was the right decision….

If you are not aware, in Linux and Unix system (including Mac), any file with a ‘.’ in front is a hidden file and is not displayed by default. Mac doesn’t come with a quick and easy way to show the hidden file as Apple didn’t want you to tamper with it in the first place. Once you know how it works, it will be easy. The initial process of discovering the trick is the most difficult process though.

In addition, the latest version of Mac (Lion) does hide the root folder and your User folder from the finder too. You have to go to the Preferences to set the options for it to display.