======UNIX/Linux Fundamentals Course Notes====== For help with wiki syntax: * [[http://lab46.corning-cc.edu/wiki/syntax|Wiki Syntax]] * [[https://www.dokuwiki.org/_media/plugin:wrap_plugin_example6.png|Wrap Plugin Syntax]] **__Class Notes__** **Important Idea** There are two modes of operation that can be observed when using a text editor:\\ - Issuing a command\\ - Inserting text\\ __Insert Commands__\\ i: enter insert mode before cursor\\ a (append): enterinsert mode after cursor\\ I: enter insert mode at the beginning of the line that the cursor is currently on\\ A: enter insert mode at the end of the current line\\ o: append a new line below the current line\\ O: append a new line above the current line\\ __Navigation Commands__\\ //"Arrow Keys"// - Cursor Movement (navigation by character)\\ k: up, l: right, j: down, h: left\\ Note: Adding a number before any of the commands allows movement by that many characters:\\ Ex.) 8h\\ w: navigates forward by word\\ W: navigates forward by space\\ b: navigates backwards by word\\ B: navigates backwards by space\\ G, gg: go to line (with a number placed in front of the command)\\ __Manipulation Commands__\\ x: delete (cutting)\\ xxx: delete "3"\\ X: akin to a backspace\\ dw,dW: see above syntax for w,W (deletes by...)\\ db, dB: see above syntax for b,B (deletes by...)\\ dd: deletes the current line\\ d^: deletes backwards from cursor\\ d$: deletes forwards from cursor\\ .: repeats the last used manipulation command\\ { , }: movement backwards/forwards by paragraph\\ (Shift)~: toggles case of letter that the cursor is on (if held then will proceed through rest of document)\\ /: Allows for the user to search the document\\ n, N (while in a search): Moves the cursor to the next and previous result respectively\\ r: redo\\ u: undo\\ p: paste below cursor\\ P: paste above cursor\\ cc: cut into insert mode\\ cw, cW: see above syntax for w,W (cuts by...)\\ cb, cB: see above syntax for b,B (cuts by...)\\ yy: paste into insert mode\\ yw, yW: see above syntax for w,W (paste by...)\\ yb, yB: see above syntax for b,B (paste by...)\\ y{, y}: see above syntax for {,} (paste by...)\\ __Extended VI Commands__\\ To enter press colon while in command mode(:)\\ :w :save\\ :w! :force save\\ :wq :save and exit\\ :q :quit\\ :q! :force quit\\ :co0 :copy to current line (line #, example 0)\\ :%s/(pattern 1)/(pattern 2)g :replaces any example of (pattern 1) with (pattern 2)\\ __Customization Commands__\\ All examples of the number sign represent any number to apply\\ :set tabstop= #\\ :set shiftwidth=#\\ :set number :toggles side numbering in VI\\ :syntax on\\ :set cursorline\\ :set cursorcolumn\\ :colorscheme (example) :Turns the default color scheme to another (press tab after command to see choices)\\ (Created 9/16/2017) - Robin Lash\\ **__Advanced Scripting__**\\ (Basic scripting can be found in the example scripts created for reference in class)\\ **Vertical Operators**\\ - Unary: if exists (performs one operation)\\ - Binary: if "name"/"number" is greater than ..... (two operations)\\ __Operators__\\ - eq: is equal to\\ - ne: is not equal to\\ - le: is less than or equal to\\ - lt: is less than\\ - gt: is greater than\\ - gr: is greater than or equal to\\ - !: invert logic\\ &&: and and\\ "||": or or\\ (Edited 9/23/17 Robin Lash) __Example HTML__\\ (for wpa0)\\ - Tells the type of document\\ \\ - Start of the page\\ Title of the Webpage\\ \\ \\ - Main content of the page\\

Main Header of the Document

\\

\\ - Bold the words\\ \\ u\\
- Create a space in the document\\

\\
\\ Example:\\
\\ Name of the Link\\
\\

- Create a new paragraph\\
    - Create a new list\\
  • List item
  • \\
\\ \\ \\ **__Regular Expressions__** Basic:\\ . : match to any single symbol\\ * : match 0 or more of the previous\\ []: (character class) - match any of the enclosed\\ [^]: (inverted character class) - do not match any of the enclosed\\ “^” : match start of line\\ “$” : match end of line\\ \< : match start of word\\ \> : match end of word\\ Extended:\\ - Recommended to use egrep\\ + : match 1 or more of the previous\\ () : perform grouping\\ “|” : or\\ ? : match 0 or 1 of the previous\\ (Robin Lash - 10/21/2017)\\ Mouse Movement:\\ xte : xte 'option 'parameter''\\ xte 'mousemove x y' : Moves mouse to x,y. Positive values mean moving right, down. Negative values mean moving left, up.\\ xte 'mousermove x y': Moves the mouse x,y, relative to where it already was.\\ xwininfo: command that allows for a specific window to be selected for cursor movement, -root means the size of the desktop/window manger.\\ (James vanDright - 10/28/2017)\\ **__Useful tools for icp0__**\\ scp\\ Tool to transfer items between the pod and the lab46 account:\\ Syntax:\\ [command][filename][user]:[location] - (Use a colon for home directory)\\ scp icp0-0.sh pod57: src/unix/icp0\\ scp icp0-1.sh user@pod57:\\ scp 1cp0-2.sh user@lab46:\\ (Robin Lash - 10/28/2017) **__Helpful Tools in lab46__**\\ **du -hs**\\ - Displays your disk usage\\ (h - “human readable”)\\ (s - summary)\\ **quota**\\ - Shows how much data we are using, and how much we have left to use.\\ Example of the output:\\ [blocks][quota][limit]\\ [blocks]: (how much data we are using)\\ [quota]: (how much we can use before we approach a soft wall)\\ [limit]: (the hard limit we cannot go past)\\ [files][quota][limit]\\ [files] : (how many unique files there are)\\ [quota] : (how much we can use before we approach a soft wall)\\ [limit]: (the hard limit we cannot go past)\\ (Robin Lash - 11/4/2017)\\ **__More useful items/good reminders__** & : enables a program to work in the background, which is useful for mtPaint in icp\\ bc : Bench Calculator: a nice program that can do math in the terminal. Some useful things to note are: Echo works with bc, and if a file has say, "3+10+9+5" in it, Echo can actually do the math. Otherwise, bc can do the complicated stuff. the usual format I use is: var= $(bc <<< Mathstuff)\\ A general note: be careful of for loops: just one extra zero can cause a lot more processes than desired. Think about what the extra iterations will do ahead of time to save you the headache of what it will actually do.\\ (James vanDright - 11/4/2017)\\ ** vim shortcut which comes in handy ** \\ For those interested in copying and pasting large chunks of text, use visual mode by pressing ESC, then press V, highlight all your text, press Y to yank (copy), and P to paste anywhere you want. \\ -Andrei \\ 11/14/17 \\ Not much I can say here now that the eoce is coming up. Good luck to all. Helpful hints: don't forget to use the man pages and read all the way through the specification :D. __**Refresher on File Permissions**__\\ r w x\\ _ _ _ (Addition of the places to get value (Octal))\\ 4 2 1\\ - read bit\\ - write bit\\ - execute bit\\ Example:\\ r-x rwx rwx\\ 5 7 7\\ Good information in case you accidentally let everyone else edit your file. Happy UNIXing!\\ (Robin Lash - 11/18/2017)\\