This article is a piece in a series of upcoming articles.
Mac OS X isn’t just known for it’s fancy GUI. It’s known for it’s powerful underlying core OS, UNIX, and the Terminal is the way that you can access the UNIX base. For you new switchers, the Terminal is equivalent to the Command Prompt in Windows, or the Command Line/Shell/Terminal in Linux. Many Mac users never even open Terminal, however these users are missing out on some of the most powerful features.
To open Terminal, navigate to your Applications folder, open Utilities, and double click on Terminal. You will be greeted with a message similar to this:
Last login: Tue Mar 6 17:21:36 on console
Welcome to Darwin!
The last line you see is called the prompt. This will appear after every command you enter and this is where you type your commands. It consists of your computer name, your current directory, and your short username. When you first start Terminal, your current directory will be “~”, which is short for your home directory (/Users/Your username).
One of commands you will use most is ls. The ls command will show you the files and directories that are contained in your current directory. Here’s an example:
ibook:~/Desktop/mammoth Alex$ ls
final1.jpg final3.jpg final5.jpg final6.jpg final7.jpg
By typing ls and hitting enter, the terminal shows me all the files that are in my “mammoth” directory. If you want to see the contents of a directory besides the one you are in, just type ls followed by the directory.
You are probably wondering how to change your current directory. This is done with the cd (change directory) command. Just type cd followed by the directory you want to change to. Example:
ibook:~/Desktop/mammoth Alex$ cd /Users/Alex/Desktop
If you want to get to a directory that is inside of your current directory, just type cd followed by the directory name, as there is no need for a full path. To save time, the terminal has an autocomplete feature (most command lines have this). To use it, press tab when typing a file or directory and Terminal will guess what you are trying to type. Don’t forget about ~. Entering cd ~ will get you back to your home directory. A final, and very useful cd tip is that cd .., will navigate you to the directory above the one that you were in.
If you are experimenting with UNIX commands and need help with a certain command, it is always available. Either type:
command --help (quick help) or
man command (full manual) Typing q will get you out of a command’s man page.
Although cd and ls don’t do much, they are a good foundation for further command line adventures.