Skip to content

Instantly share code, notes, and snippets.

@mikesjewett
Last active August 29, 2015 14:05
Show Gist options
  • Save mikesjewett/f235776b2cfdaed864bf to your computer and use it in GitHub Desktop.
Save mikesjewett/f235776b2cfdaed864bf to your computer and use it in GitHub Desktop.
A non-programmer's guide to the command line

Why would you want to use the command line?

  1. It's cool, and people will think you're smart.
  2. Once you learn some basic commands, you'll be more efficient in it than in a visual directory.
  3. If you ever want to learn to code, you'll need to be comfortable on the command line, so you might as well start now.

How do you open the command line?

  • Mac users can use the Terminal program, which comes with OSX. Open the Terminal by typing "Terminal" into Spotlight.

  • Windows users can use the command line by clicking Start, Run, then typing "cmd".

What are the commands I'm most likely to use?

This table is sorted based on the most common commands you're likely to need for basic tasks. The commands in the "Unix" and "Windows" columns are to be typed on the command line.

What it does Unix Windows Use Case
Tells you where you are in a directory tree pwd cd Sometimes you'll want to validate your location, before running another command. Just type the command and the command prompt will tell you where you are.
Moves you to a new directory cd cd You'll need to move around to different locations within a directory tree to view different folders and their contents (files), or run other commands. Use .. (that's space dot dot) to move up one level in the directory tree. e.g. cd ..
Deletes a file rm del When you want to permantly delete a file. Note that this deletes it from disk, and bypasses the recycle bin. Type the file name after the command. e.g. rm myfile.text or del myfile.doc
List the contents of a directory ls dir You'll need to see what's in a directory before taking action on a file or directory within it. Just type out the command and you'll see a list of all files and folders within the directory where you typed the command.
Creates a new folder mkdir mkdir Create a new folder from your current location in the directory tree. e.g. if you are in a folder named myFolder, then type mkdir newFolder, you will have a new folder (sub-folder) within the myfolder directory. This new folder will appear when you run dir or ls from myfolder.
Searches for a given character or string grep find It's like using the search "magnifying glass", only much faster. For example, to search for the word "hi" in a file named "myFile", in a directory named "myDir" you would type grep hi /myDir/myFile. More advanced grepping can be found here. For Windows, reference this guide on the Find command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment