Preparation‎ > ‎

Command Line Help

Throughout this bootcamp (and the rest of your coding career) you'll need to be able to navigate on the command line. For Mac OSX and Linux, this means learning the basic UNIX commands.  For Windows, it means learning DOS. Here is a (very) quick guide to get you up on your feet for on Mac/Linux.  If you want more, or if you are a Windows user, check out the links at the bottom.

  • Opening the Terminal: On both Linux and Mac, the terminal is simply called "terminal."  You can find it through spotlight/launchpad/the start menu/etc. You can start a new instance by hitting cmd-n or cntrl-n.
  • File Directory: In UNIX, files shown with the "/" symbol separating them.  For example, the file /Users/Python/ is a Python script that lives in the Python folder, which is itself in the Users folder.
  • Moving Around: There are a few fundamental commands used to move around with the command line.
    • cd: Move to your home folder (i.e. "change directory")
    • cd XYZ: Move to the folder named XYZ
    • ls: Show everything in the current folder (i.e. "list")
    • pwd: Show which folder (i.e. "print working directory")
    • mkdir XYZ: Make a new folder and name it XYZ (i.e. "make directory")
  • Modifying Files: You'll have to create/edit text files directly.
    • cp Copy the Python file to a new file called (i.e. "copy")
    • mv Move the Python file to a new file called ZYX.pye (i.e. "move")
    • cat Print the entire contents of to the screen (i.e. "concatenate")
    • less Show the contents of on the screen, with the ability to scroll up/down
  • Tips/Tricks: Quick tips to make your life easier.
    • tab-complete: Hit tab while typing a command, and the terminal will attempt to fill in the rest.
    • cntrl-a: Move the cursor to the front of the line.
    • cntrl-e: Move the cursor to the end of the line.
    • man XYZ: Display the manual for program XYZ.
    • sudo XYZ: Run the command XYZ as the root user, in case you get a permissions error (you'll need to enter your password).
    • the .profile/.bashrc/etc. file: In your home directory, there lives a hidden file that runs every time you start a terminal. You can rename ("alias") commands and much, much more with this file.  Look for it by running ls -a in your home directory, feel free to edit it, and use your googlefu to learn more.
  • Text Editors: You'll want to have a good way to edit your code. These make your coding life easier through syntax highlighting, auto complete, and more.
    • Sublime Text: We recommend using Sublime Text as a text editor.  Free, and works on Mac/Linux/Windows; download it here.
    • TextMate: Another good text editor (Mac only), though it costs $$. Free downloads available for UCB students here.
    • vim/emacs/vi: For the hardcore. If you're using these editors, you don't need this guide.

Go here for a more thorough introduction to the UNIX command line.
Check out this page for an introduction to the Windows command line.