The Windows Command Prompt is an example of a command-line interface, meaning it allows access to computer files and executables with text only (no graphics). Cmd, unlike terminal, is not case sensitive.
Accessing the Command Prompt
There are several ways to open the command prompt:
- Start > Windows System > Command Prompt (This is only confirmed on Windows 10)
- [Windows Key] + R > type cmd > hit return
- [Windows Key] + X > press C (or A for an administrative prompt)
At any given moment, you are inside exactly one folder per session (just like in a generic file explorer). The prompt is in the following format:
To run a command, just type it out and press enter. When you see the prompt again, the interface is ready to receive another command. If you happen to get stuck (a command is taking too long to run), pressing Ctrl-C will stop the command.
On that note, if you want to copy something from the window, use Shift-Ctrl-C. To paste, simply right click. Note that left clicking at all will clear out your clip tray, so be careful.
- DIR: This will list the contents of your current directory. By specifying a folder (like DIR PATH\TO\FOLDER\, you can list the contents of an arbitrary directory.
- Note: you will always see at least two listings (except in rare circumstances):
- "." is your current directory
- ".." is the parent directory
- CD PATH\TO\FOLDER\: This will change your current directory to whichever one is specified. Note that folder paths can be absolute (CD C:\Users\Stephen\Desktop) or relative (CD Documents). Note that you can also use CD .. to navigate to the parent directory.
- NOTEPAD: This opens an instance of notepad (not notepad++, unfortunately). If a file path is specified, the file will be opened.
- FOOBAR.exe: If your directory contains an executable, you can run it just by typing the full file name. Additionally, if you are in the wrong directory, you can run the file by specifying either a relative or absolute path to the file.
- ECHO FOOBAR: This will print whatever follows it (replace FOOBAR with anything). ECHO is escpecially useful when trying to see things like the path, which can be accessed as ECHO %PATH%.
Sometimes, you might have downloaded a program (such as PuTTY) and want to run it from the command line. Unfortunately, you may find that you have to specify the entire path, which is tedious. Luckily, you can tell command prompt to look in certain places for programs, which would allow you to just give the program name instead of the path.
Go to Control Panel > System and Security > System > Advanced System Settings > Environment Variables. Choose, under System Variables, Path. Add to it the directory in which your command is found. For example, I added C:\Program Files (x86)\PuTTY. Press okay a bunch. Now, when you open up command prompt and want to run PuTTY, you can just say
C:\Program Files (x86)\PUTTY