The command line is the opposite of using something like OS X or Windows; no mouse, no icons, nothing but text.
You might remember the DOS prompt. You’d boot up your computer and find yourself looking at a black screen with
staring back at you. That’s an example of the command line! You might have been able to type “win” to start up Windows, but there’s plenty else you could do just from the command line, too.
‘Dir’ could list all of the files in a directory, while ‘fdisk’ would check your hard drives to make sure they didn’t have any errors on them. If you’d like to relive the olden days, you can find a a list of commands over on Wikipedia.
Macs have a command line, too, called Terminal. You might also hear it called the shell or bash. You’ll see how to fire it up in the Now Try This section!
Why would anyone ever use the command line? Many programs can only run from the command line, and don’t have a graphical version. For example, if I wanted to create a new Ruby on Rails site, I’d have to hop down to the command line and type ‘rails new project.’ It also has powerful ways for different programs to work together and send data back and forth.
Most web servers don’t have graphical interfaces, and developers can only interact with them using the command line. Copying files over, running programs, troubleshooting – all of it needs to be done by typing in commands.
This is one reason why so many developers use Macs. Underneath the pretty graphics in OS X is a powerful command line that’s very similar to the one that runs on web servers. This makes it a little easier to move a site between a Mac and a web server than if you’re starting from a Windows machine.
Now try this!
If you’re in Windows:
- Click the Start button. If you see “run,” click that, otherwise, type “cmd” and hit enter. That should open up the command line.
- Type ‘dir’ and hit enter, and you should see a list of directories and files scroll by. You’re using the command line!
If you’re on a MAC:
- Open up your Applications folder
- Scroll down until you find the ‘Utilities’ folder, then open that up.
- Double-click Terminal.
- Type ‘ls’ (that’s lowercase L, lowercase S) – you’ll see files and directories!
Cocktail Party Fact
rm is a powerful command that deletes (or removes) files. A popular prank on Macs and Linux-based machines is to convince people to type rm -rf * – rm usually doesn’t delete much, or asks before it does, but adding on the -rf makes it delete every file willy nilly. Tricking someone into deleting everything on their computer isn’t really the funniest thing in the world, so don’t try that at home!
It does make for some good stories, though – check out how this happened to Pixar when they were working on Toy Story 2.