There are two really important things that first-timers should know about the command line:
- Pretty much everyone who didn’t start out doing command line “stuff” as a kid gets a little intimidated their first time, so if you are, you’re not alone.
- It’s really, REALLY not hard.
With those two notes out of the way, here’s a quick run-down of the basics:
The Command Line
The command line (or CLI) is just another interface for a computer program, but without all of the bells and whistles that you see in graphical interfaces. This interface is entirely text-based, and you use it to enter text commands from the keyboard in order to perform actions on the computer. Simple, right?
Accessing the Command Line
How you access the command line depends on your operating system.
- Windows users: Click Start, search for “command,” and click on Command Prompt.
- Mac users: Click Applications, open the Utilities folder, and click the Terminal application.
What everything looks like will depend on your specific computer’s settings, but you’re going to end up with a window that looks something like this:
More specifically, everything in this post uses Bash, a Unix shell, which is the default for Linux and in OSX. If you’re working on Windows, the specific commands or how they function may vary, but the concepts are roughly the same.
A Tour of the CLI
When you open it, your interface might show you the last time that you used the command line.
Most CLI interfaces are going to display the name of your current computer. Sometimes, this might instead display something like “localhost” to indicate that you’re running commands from the same computer that you’re actually working on. This is useful because it’s also possible to use the command line on one computer in order to access or run commands from another computer, a server, etc. If you regularly, for example, use SSH to log in to a server that you work with, it’s helpful to know which computer you’re on in a given window.
After the name of the computer, you’ll generally see information about your current working directory (in these examples, the tilde represents the base directory on the current computer.) The commands that you enter run in relation to the displayed location. This is especially important when you use the command line to work with files or directories.
Many CLI interfaces also display your username. The $ in these examples is an indicator of the beginning of the command entry area, and might be indicated by any number of other special characters depending on your system.
Running commands is as simple as entering the desired command and its options in the correct format, and then pressing Enter to cause it to run.
The “cd” command changes the current working directory on both Linux/Max and Windows machines. The example above moves into the “test” directory. We can see that the working directory changed because the tilde (~) in the prompt’s first line changed to the word “test” in the second line.
Resources for learning the command line
If you’re trying to get comfortable on the command line, the best thing you can do is to practice!
- If you use a Mac, or any other computer that runs Linux, I’m fond of NixTutor’s Linux Cheat Sheets list.
- For Windows users, SOPHOS’s Knowledge Base contains a nice chart of some basic commands to get started with.