Skip to content

Latest commit

 

History

History
120 lines (106 loc) · 3.89 KB

0a-setup.md

File metadata and controls

120 lines (106 loc) · 3.89 KB

Good practices

Name your files well

  • Use lower case as much as possible.
  • Do NOT use space.
  • Do NOT use special characters expect for hyphen -.
    • underscore _ is acceptable when you are not using SQL.
  • Be concise.
    • Bad: excerpts-draft2-final1-approved.txt
    • Better: excerpts-2016-02.txt
  • Be descriptive.
    • Bad: myfilefromclass-example02.html
    • Better: example-from-class.html

Tab completion

It's very easy to typo commands, which can lead to errors and unintended consequences. One way of helping to avoid that problem is using tab completion, which allows the computer to finish typing a command that you have begun. Say you're in your home directory and want to go to the Desktop -- you'd type cd Desktop, right? You could also type cd Des <tab> and the computer would fill out the remaining text to spell "Desktop". This is a huge time-saver, especially when you're typing long directory paths (think something like cd Desktop/projects/apps/django/test-app/test/apps/models.py). Here's a demo of tab completion in action.

Go straight home

Your home directory is sort of like True North in command line world. It's a great way to orient yourself if you end up lost in the file system. In OSX, no matter where you are in the directory structure, you can immediately get back home by typing cd.

Guides and cheat sheets

Here's a useful guide for simple command line syntax on OSX and Linux. And here's another one for Windows.

List of common commands

If you are using OSX:

Command Example What it does Notes
pwd pwd Shows your present working directory Useful for keeping track of where you are
ls ls Shows the contents of the current directory Can also use ls -a or ls -l to show more information about files
cd cd Desktop Changes directories Use cd ..``` to move backwards
mkdir mkdir new-directory Creates a new directory
touch touch test.py Creates a new file
mv mv test.py ./Desktop This isn't covered above, but mv moves or renames a file.
rm rm test.py Deletes a file Use with extreme caution. Once a file is deleted this way, you can't get it back.

If you are using Windows:

OSX command Windows equivalent
pwd cd (with no arguments)
ls dir or dir -p
cd cd followed by the directory name (ex. cd Desktop)
mkdir md
touch None (sorry!)
mv move
rm del

Kudos to Sisi Wei (who is a journalist at Propublica and will be teaching the Data Scraping class at CUNY-J in April) for synthesizing some of the materials.