The Missing Semester of Your CS Education
class one
About Ubuntu
- press super to search on this computer
- press super and tap tab to switch between tasks
- press super and up/down/left/right arrow to move the current window
- press super and pgup/pgdn to nevigate between windows
About Shell
- echo is a program
- echo $PATH will tell you all of the paths the computer will look for when execute the echo program
- which echo tells you which program it will run if you were to run echo
- absolute path
- pwd : present workinng directory
- . means the current directory
- .. means the parent directory
- cd ~ means cd /home/vincent (tilde)
- cd - will nevigate to the previous directory - is called dash
- ls –help
- ls -l gives you more information
- mv [OPTIONS] SOURCE… DESTINATION
When multiple files or directories are given as a SOURCE, the DESTINATION must be a directory. In this case, the SOURCE files are moved to the target directory.
If you specify a single file as SOURCE, and the DESTINATION target is an existing directory, then the file is moved to the specified directory.
If you specify a single file as SOURCE, and a single file as DESTINATION target then you’re renaming the file .
When the SOURCE is a directory and DESTINATION doesn’t exist, SOURCE will be renamed to DESTINATION. Otherwise if DESTINATION exist, it be moved inside the DESTINATION directory - cp [OPTIONS] SOURCE… DESTINATION
When the SOURCE and DESTINATION arguments are both files, the cp command copies the first file to the second one. If the file doesn’t exist, the command creates it.
When the SOURCE has multiple files or directories as arguments, the DESTINATION argument must be a directory. In this situation, the SOURCE files and directories are moved to the DESTINATION directory.
When the SOURCE and DESTINATION arguments are both directories, the cp command copies the first directory into the second one. - rm remove a file
- rmdir remove a directory when it’s empty
- mkdir make a directory
- man ls gives you the manual of ls
- use echo command > filename to rewire the output to a file (this will overwrite everything in the file)
- cat filename gives you the content of the file
- use echo command >> filename to append things in the file
- tail -n1 output the last line
- ls -l / | tail -n1 (“|” is called pipe, the left will become the input of the right)
- sudo : do the following things as the super user
- sudo su : run the floowing command as the super user (type exit to exit)
- echo 100 > sudo tee brightness (tee means write things into the file and displat it )
while sudo echo 100 > brightness will not work (because brightness didn’t get the sudo access) - xdg-open filename : open a file using the proper program
- sh filename/string executes commands read from a command line string, the standard input, or a specified file.
- chmod see https://www.computerhope.com/unix/uchmod.htm
class two
- To assign variables in bash, use the syntax foo=bar (no space in between)
- echo $foo : print out the value of variable foo
- in double quote(“”),the $ sign will be excuted(print out the value), while single quote(‘’) present literal strings