courses-compsci/gen/missing_semester_2020/_subsections/lesson-01.org

5.5 KiB

Lesson 01 | Course Overview + Shell

Notes

why

  • there are many tools that make life easier for programmers
  • lecture notes and recordings are available online

the shell

  • programs are meant to be integrates with each other through the shell
  • most common shell is Bourne Again Shell (bash)

shell prompt

  • typical shell prompt:

    file:../_share/media/img/lecture01/ex01.png

  • shells can be customized extensibly
  • arguments are seperated by whitespace
  • multiple words can be passed as a single argument via:

    • quotes

      echo "Hello world"
    • escapes

      echo Hello\ world

how does the shell know where programs are

  • via environment variable

    • things that are set whenever you start your shell

      • where is your home directory
      • what is your username
      • what are the PATHs to your programs
  • shells, and bash in particular, are programming languages

paths

PATH environment variable

  • a list seperated by colons (:)
  • when bash is asked to run a program bash will search through the directories in path until it finds the program

absolute vs relative path

  • pwd: print working directory
  • all relative paths are relative to your current working directory
  • absolute path starts with '/'

special directories

  • '.' current directory
  • '..' parent directory

tilde (~)

  • always expands to your home directory

dash (-)

  • toggles to the previous directory you were at

    cd /home/ronny/programs/notes/courses
    cd ../../
    cd -
    pwd

the output will be /home/ronny/programs/notes/courses

permissions

groups of three

  • read
  • write
  • execute

directories

  • read: are you allowed to see the files
  • write: can you rename the files in the directory
  • execute: "search" are you allowed to enter this directory

    • to access a file in a directory, you need execute permissions on all directories in the path

piping

  • every program has two streams

    • input stream
    • output stream
  • shell allows you to change streams

    • angle brackets
    • left angle < : rewire input
    • right angle > : rewire output
  • example

     echo hello > hello.txt
     cat < hello.txt