Giter Site home page Giter Site logo

shell_week2's Introduction

Paths, Terminal, and Bash commands

Practicing with GitHub

  • Have you created a GitHub username and sent it to me? If not, please do!
Practice Exercise - Copying and Editing a GitHub Repository

(1) Log into GitHub
(2) Go to class page
  - If you've accepted the invitation, you should see a link to the class page on your profile
(3) Go to this week's repository
(4) Click the "Fork" button in the upper right
(5) Find your copy of the repository in your profile and select it
(6) Once in the repository, click the "Create new file" button
(7) Give the file your name and in the body of the file, write your favorite biology fact.
(8) Scroll to the bottom and type an informative commit message
(9) Click the "Commit new file" button
(10) Once back on your repository page, click the "New pull request" button
- ** Now wait here until everyone is ready, and we'll discuss **

This is the general workflow for collaborative coding using GitHub.

Paths to files and folders

  • Relative and absolute paths

  • Compare your answers to the practice exercise about paths with someone next to you. If your answers were different, discuss why.

Practical Computing tips

Your remote Linux computer

Practice Exercise 

(1) Log on to HPC OnDemand (any problems?)
(2) Go to Files -> Home Directory
(3) Look at the header bar at the top. What is the path to your home directory?
(4) Using the "New File" and "New Dir" buttons at the top, create these 
    directories and files in your home folder:
  - /home/<yourUserName>/myBiologyClasses
  - /home/<yourUserName>/myBiologyClasses/CellBiology
  - /home/<yourUserName>/myBiologyClasses/CellBiology/CellBioImportantNotes.txt
  - /home/<yourUserName>/myBiologyClasses/Ecology
  - /home/<yourUserName>/myBiologyClasses/Ecology/EcologyImportantNotes.txt
  - /home/<yourUserName>/myBiologyClasses/Evolution
  - /home/<yourUserName>/myBiologyClasses/Evolution/EvolutionImportantNotes.txt
(5) For each of your `.txt` files, click the "Edit" button, add some relevant text,
    and save your changes.

Introduction to the Command Line

Terminal

  • Built in to Linux (and Mac OS X)
  • By default,usually uses the bash shell (interpreter)
  • The command prompt
  • Tab completion
    • Double tapping tab will list all files with that beginning
  • Scrolling through history

Commands related to navigating the filesystem

  • touch filename.txt will create file
  • pwd - print working directory - or - "where am I?"
  • ls - list directory contents
  • ls -l - long list
    • Everything has three types of permissions
      • Read
      • Write
      • Execute
    • And three groups whose permissions can be controlled
      • Owner
      • Group
      • Others
  • Wikipedia on Unix Permissions
  • la - list with hidden files
  • cd - change directory
    • will accept absolute or relative paths
  • chmod - change permissions - specify who (ugo), how (+ or -), and what (rwx)
  • man <command> - gives us the manual page and options for any Unix command (q will get out of manual page)
  • Notes about command-line navigation

Commands related to files and folders

  • cp - copies a file
    • cp originalFile.txt newFile.txt
  • mv - moves or renames a file
    • To change location, use paths: mv myFile.txt ./folder/myFile.txt
    • To change name, just use different names: mv myFile.txt newName.txt
  • cat filename.txt - view file contents - can be called on multiple files and will conCATenate their contents
    • cat file1.txt file2.txt file3.txt will show all files in command line
    • cat *.txt shows all text in files with the file ending .txt
  • ls *.txt show all files that end in .txt
    • ls ../*.txt go up one directory then tell me the txt files there (still within the same directory)
  • head -n # - view the first # of lines of a file
  • tail -n # - view the last # of lines of a file
  • less - view the contents of a file a little at a time nice way to scroll through
  • touch filename.txt - quickly create a new file
  • nano filename.txt - this is actually an entire text editing program (type text like normal)
    • write out is save and ^=control (^O) exit (^X)
  • wc - print out the length of a file in lines, words, and characters
  • >> - appends to file
    • echo "some text here" >> myTextFile.txt
  • > - writes to (or over!) file
    • echo "more text here" > myTextFile.txt
  • WARNING - BIG WARNING - PAY ATTENTION - rm permanently removes a file
    • No going back - always use this VERY carefully
    • I know people who've accidentally erased their entire computers using this command
    • rm -r recursively removes a directory and everything inside it - even more dangerous than just rm!
    • This is the reason permissions are so important. If someone doesn't have write permissions on a file or folder, they shouldn't be able to delete it.
  • mkdir MyDirectory - create a new (empty) directory (folder)
  • rmdir MyDirectory - remove an empty directory !!WARNING!!
  • wildcards - * is especially useful - matches anything
  • grep - find only lines matching some particular string
  • cp filename.txt filename2.txt will copy contents
  • mv filename filename will change name of file
  • mv filename ./Biology/ will move file name into folder that is in current working directory or without ./ will work too
  • Notes about editing files and folders from the command line

Commands related to the Unix environment

  • Can create a variable and assign value using =
    • myVariable=2
  • Can print value of variable using echo and starting name with $
    • echo $myVariable
  • | - the Unix pipe can be used to send the output of one command into the input of another
    • history | tail -n 20 >> endOfHistory.txt
Assignment 2

* Will be posted after class, Tuesday, Jan. 21 *

Complete by 5 PM, next Monday, January 27th.

shell_week2's People

Contributors

azkabanescapee avatar jembrown avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.