Command Prompt

The following is basic guide and tutorial to the command prompt. Windows and Linux are explained. Mac OS is not covered explicitly, but it will be very similar to Linux. If you're on a Mac, assume the Linux instructions will work and if they don't, use Google to find and tweak the command for Mac.

Official class videos...
[ Tutorial Part 1 ]
[ Tutorial Part 2 ]


What Is It?

The command prompt is a text interface to your computer. You are likely used to a graphical interface. You point-and-click at icons and menus and that's how you start applications and make things work. A text interface presents you with only a cursor, and you have to type commands to make things work.


Why Do I Need It?

The command prompt is an absolutely essential tool for any computer technologist. It is not a "nice to have" skill. It is a "must have" skill. As a technology professional, you will be required to be an expert at the command prompt. Some things can only be done at the command prompt. Some things are just easier and more efficient at the command prompt. Most good programmers are faster at the command prompt than they are with a Graphical User Interface (GUI)

The GUI you are used to is not the computer and is notT the operating system. It is an interface, a layer of convenience placed on top of the operating system to make common and non-technical tasks easier. The GUI is an abstraction of what is going on behind the scenes. It's also important to realize that what you can do in the GUI is only what the makers of the GUI let you do.

The command prompt, by contrast, is closer to the computer and the actual operating system. As such, it's far less constrained and a potentially more powerful way to interact with the operating system. At the command prompt, you decide what is possible, not the makers of the GUI.


Operating System Differences

Each of the three major operating systems will behave differently in the GUI and the command prompt. This is owing to the target market and purpose of the operating system. Consider...

  • Windows: A relatively insecure, hybrid home and business operating system. The jack-of-all-trades and master-of-none operating system (except gaming, Windows leads in gaming).
  • MacOS: A relatively secure, almost exclusively consumer personal-use operating system that has been adapted to niche creative applications and business applications. The master of it-just-works and too bad if you don't like the way it works.
  • Linux: An inherently and highly secure server and industrial-strength operating system that has been adapted to personal use. The master-of-servers, computer science, and research, and too bad if you don't understand it because we're not telling you how it works. It's open source, you figure it out.

Keeping in mind who each OS is made for, here is a breakdown of the power and flexibility between systems.

  • Windows GUI: Powerful and flexible. Arguably the best blend of power and ease of use with flexibility in mind.
  • Windows Command Prompt: Little power or flexibility. Almost useless. However, Windows has a better command prompts (based on Linux) which you can install such as powershell, MinGW, Cygwin.

  • MacOS GUI: Very Powerful but with almost no flexibility. Don't like it? Too bad.
  • MacOS Command Prompt: Very powerful. Like Linux, built on Unix, so has many similarities and is as challenging to use.

  • Linux GUI: It's a barrel of monkeys. Rabid, insane monkeys. Don't like it? Too bad. Here is the source code, you fix it.
  • Linux Command Prompt: Ultra powerful. Very complex. This is where the magic happens. Good luck, you'll need it.

Whatever your choice of operating systems, you're not escaping the command prompt if you intend to be a computer technologist. If you do not master the command prompt your career is over before it begins. So best get to it...

Getting Started

On Windows go to the start menu, search for "command" and you will get an item called "command prompt." Click it and it will start something like this:

Windows command prompt

On Linux and Mac, start the Terminal, and it will look something like this:

Linux command prompt

In both cases you have a prompt where you can now type commands. First thing to note is both prompts tell you where you are in your computer. The Windows prompt tells you that you are on the C drive and in the Windows directory. The Linux prompt tells you that you are in the home directory (that's the ~ character) for the user named "alex" on a computer named "alex-laptop".

To interact with the terminal type commands and press Enter. For example to list the contents of a directory type dir on Windows and ls on Linux and Mac. You will then see a listing of the files in the directory showing at the command prompt. This will show you the same thing as if you opened a file explorer window and clicked on a folder.


Parameters and Switches

Most commands allow you to give them extra information (parameters) or turn features on and off (switches). For example, the simple dir or ls command only list basic file information for the current directory.

Windows Example: Suppose you are on C:\Windows but you want to list the contents of C:\temp without changing the current directory. Type dir c:\temp and you will see the contents of C:\temp. In this case, the c:\temp part of the command is a parameter.

Suppose you want to list hidden files that might be there but are not normally visible. Type dir /a and you will see the hidden files. The /a part is a switch. It turns on the "all" feature.

You can also combine these like so dir c:\temp /a

Linux/Mac Example: Suppose you are on ~ (your user directory) but you want to list the contents of /tmp (a directory called tmp on the root of the drive) without changing the current directory. Type ls /tmp and you will see the contents of /tmp. In this case, the /tmp part of the command is a parameter.

Suppose you want to list hidden files that might be there but are not normally visible and also you want to see file details not normally presented. Type ls -al and you will see the hidden files along with detailed files information. The -al part is actually two switches. The -a turns on the "all" feature to see hidden files and the The -l turns on the listing details. When you use multiple switches its common to put them together like so -al

You can also combine all that like so ls -al /tmp


Basic Commands You Will Need

The following is an excellent basic tutorial: Django Girs Intro To The Command Line. For all programming classes you will be expected to know and be able to use the commands in the Summary section of that tutorial. You will also be expected to know and use all several more commands, switches, and parameters which will be covered in lectures.

In addition, you will use Git which has an extensive command line interface. Git and this tutorial will be covered in lectures.

Here are a few more general resources to get started: