- It's cool, and people will think you're smart.
- Once you learn some basic commands, you'll be more efficient in it than in a visual directory.
- 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.
-
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".
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. |