Notes: Week 01

Week 01: Hand-on the Terminal

1. Open terminal on MAC

Terminal is a shell which receive/send input and output for command-line program.

  • command+space to open spotlight
  • search "terminal" to open terminal.

2. Shell commands

Following are some commands you can input in terminal.

1. Directory: Where you are

Please type often pwd and ls to make sure where you are.

  • ls means listing, showing the files in current folder.

  • cd means change directory, or change to a folder. eg: cd desktop to go to "desktop".

    cd ~ or cdto return to home.

    cd desktop/17444519

    cd . to go to current diretory.

    cd .. to return back to the upper directory.

  • pwd means print what directory, or show where you are.

2. Creat/delete/rename files and folders

Space separates the arguments and commands. So be careful.You can ls to check the new file or folder. (Make sure it exists.)

  • touch means creat a file
  • rm means delete a file eg: At first, ls to see files in current folder.

    touch ex1.py to creat a file called "ex1.py",then ls.

    rm ex1.py to remove a file called "ex1.py".

  • mkdir means creat a folder
  • rmdir means delete a folder eg: lsto see files in current folder.

    mkdir Big_data to creat a new directory, or a folder.

    rmdir Big_data to remove the directory.

  • mv means rename eg: mv ex1.py exercise.py to rename "ex1.py" as "exercise.py". mv 123 456to rename "123" as "456".

3. Execute .py file
  • python exercise.py to execute python scripts.

3. Edit Python file:

You can open .py by double clicking the file. (If it doesn't work, you can download some third party editors,such as sublime, visual studio code. You can edit .py file by these editors.)

  • print is a python language, which means print, or show, in the terminal. eg: print "hello" on sublime to print the string hello.

    command+S to save the file as "ex1.py" on desktop.

    python ex1.pyon terminal to execute the file.

results for ""

    No results matching ""