Watkins Web 2: Blog

Intro to The Shell

The Mac’s Terminal.app program lets you control the system with text commands, sort of like DOS before Windows arrived. Technically you’re using this interface to interact with Mac OS X’s Unix underpinnings, bypassing the graphical user interface entirely. (Unix is an open-source operating system that dates back to the 1970s: many present-day operating systems are built on top of it, including Mac OS X and  the various kinds of Linux, some of which run on personal computers and others of which run on web servers). Apache is a web hosting program that runs on Linux. Windows is not Unix.

Terminal’s text-only environment is variously called “the terminal,” “the command line,” “the shell,” and bash (short for “Bourne-again shell” — don’t ask). In general, you can use the shell to run scary system-level scripts, monitor system processes, log into other computers or remote web servers, etc. Serious nerds even edit text files with shell programs like Vim, Vi, or Emacs.

The first thing you’ll notice about the shell is its limitations: you have to use the arrow keys to move around, you can’t select text and delete it, you can only clear a line you’re writing with [ctrl] c, etc. Try exploring with the commands below.

Important Commands

Command Description
pwd Path of working directory
Outputs the current folder you’re in
ls List files
Shows all files and folders in the current working directory
clear Clear
Clears the screen
cd foldername Change directory
Moves you into a different directory. Use cd.. to go up a level. You must “escape” spaces with a forward slash: cd My\ Folder. Note that you can drag a file or folder from the Finder right into Terminal and it will insert the corresponding file path instantly.
cp filename.txt filename2.txt Copy
Copy a file — you must provide both the original and new file names, separated by a space.
mv filename.txt path/to/folder/ Move
Move a file — you must provide the file name and a destination directory, separated by a space.
mkdir foldername Make directory
Creates a new folder
curl http://website.com Client for URLs
Scoops the HTML source of a webpage and outputs it
banner word Banner Text
Outputs ridiculous sideways ascii art of word
[ctrl] c Cancel
Clears the line that you’re writing
Up arrow
Shows previous commands. Keep hitting ↑ to go further back in your history and ↓ to go forward.

Further Reading