% CST8207 Week 07 Notes - quoting % Ian! D. Allen - - [www.idallen.com] % Fall 2013 - September to December 2013 - Updated Thu Nov 21 14:12:59 EST 2013 Readings, Assignments, Labs, and ToDo ===================================== - Read (at least) these things (All The Words): - [Week 07 Notes HTML] - this file - **Read All The Words** - [Quoting] - [List of Commands You Should Know] - Using your [lynda.com] account, watch [Unix for Mac OS X Users] - **3. Working with Files and Directories** - Naming files 5m 41s - use quotes to surround names with blanks or special characters Assignments this week --------------------- Check the due date for each assignment and put a reminder in your agenda, calendar, and digital assistant. - Read (All The Words), Do, and then Submit via Blackboard: - Optional BONUS assignment: [Assignment #04 HTML] – learning the VIM text editor. (Optional BONUS for extra marks.) - [Assignment #05 HTML] – review of Midterm #1 errors - [Assignment #06 HTML] – [Quoting] and [Startup Files] - Assignment #07 HTML (not ready) – installing and configuring CentOS in a VM, using [CentOS Installation and Configuration] Lab work this week ------------------ - [Worksheet #06 HTML] – *Optional* VIM Text Editor Practice - This is an *optional* worksheet for an optional BONUS [Assignment #04 HTML] using the `vim` text editor. - Optional Reading: [The VI (VIM) Text Editor] - Optional command-line VIM tutorial: the `vimtutor` program on the CLS. - [CentOS Installation and Configuration] - Assignment #7 will verify this installation. - Preliminary checking: see the notes below. From the Class Notes link on the Course Home Page ================================================= - Review last week. Did you do everything assigned last week? From the Classroom Whiteboard/Chalkboard ======================================== - Your in-class notes go here. - is this directory empty? `ls` - copying and moving files into existing directories: - *If the destination is an existing directory, the source is copied into that directory under the **basename** of the source.* - See [the `cp --no-target-directory` option] - See [my StackExchange article] - A tool for explaining shell command lines – [explainshell] - does not differentiate between `ps` Unix and BSD options correctly - For BASH built-in commands, try the `help` command, e.g. `help pwd`, `help help`, `help echo`, etc. Explain what is happening in this simple `find` shell command line: $ mkdir a $ touch a/bob a/bling a/boor a/blue a/bubba $ find a -name b* # 1. output: five lines (correct) a/bubba a/blue a/boor a/bling a/bob $ touch b $ find a -name b* # 2. output: zero lines - why not five? $ touch blue $ find a -name b* # 3. output: error message - why not five lines? find: paths must precede expression: blue $ rm b $ find a -name b* # 4. output: one line - why not five? a/blue $ 1. Explain exactly why the same `find` command, run four times on the same directory, gives four very different outputs. 2. How would you fix the command to always give the correct (first) output? [*Answer*] Preliminary CentOS checking =========================== The checking program is still being written. Here’s what you can do so far: On the CLS, create your `assignment07` directory in the usual place. Then log in to your CenOS machine (as `root`) and run these three commands on your CentOS machine, replacing *abcd0001* with your own CLS userid in the third one: # cd /tmp # curl -A mozilla http://teaching.idallen.com/cst8207/13f/notes/data/assignment07do.sh >do.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 112 560 112 560 0 0 9433 0 --:--:-- --:--:-- --:--:-- 1931 # USER=abcd0001 sh do.sh --------------------------------------------------------------------------- abcd0001: FETCH version 2. Connecting to CLS as USER='abcd0001' using ssh --------------------------------------------------------------------------- abcd0001: Use local Algonquin IP cst8207-alg.idallen.ca [y/N]? y abcd0001: Please wait; using ssh to connect to user 'abcd0001' on cst8207-alg.idallen.ca ... abcd0001@cst8207-alg.idallen.ca's password: *** COURSE LINUX SERVER *** --------------------------------------------------------------------------- idallen-ubuntu assignment07fetch_server.sh version 4 run by abcd0001. Please wait; collecting info from abcd0001 Virtual Machine --------------------------------------------------------------------------- VM files collected into CST8207-13F/Assignments/assignment07/abcd0001.tar.bz on CLS. Now running checking program for abcd0001 on CLS: ---------------------------------------------------------------------------- check: idallen-ubuntu Fri Oct 18 12:48:40 2013 check: CST8207 assignment07 check program version 37 *** Checking account for abcd0001 on idallen-ubuntu *** Going into HOME directory /home/abcd0001 on idallen-ubuntu GOOD(2): Found correct 'source' statement in .bash_profile GOOD(2): Found non-interactive return first line in .bashrc GOOD(1): Found PS1= line in .bashrc Going into directory CST8207-13F/Assignments/assignment07 on idallen-ubuntu *** 4.? CLS: Set Up Tasks in assignment07 on idallen-ubuntu *** On idallen-ubuntu: Using abcd0001.tar.bz dated Fri Oct 18 12:48:40 2013 Checking 'abcd0001.tar.bz' version 4 created Fri Oct 18 12:48:40 EDT 2013 *** 4.? CentOS 6.4 Installation Verify *** GOOD(2): Found correct hostname NOTE: Found correct kernel running GOOD(2): Found correct number of RPM packages (201) GOOD(2): Found correct memory size GOOD(2): Found correct Toronto time zone *** 4.? CentOS 6.4: Grub menu and time-out *** GOOD(2): Found correct time out line in CentOS 6.4 grub.conf GOOD(2): Found correct hidden menu line in CentOS 6.4 grub.conf *** All Done *** WARNING: Cannot find submission file 'assignment07.txt' on CLS ---------------------------------------------------------------------------- *** CHECK SCRIPT NOT FINISHED YET - SOON *** ---------------------------------------------------------------------------- Real Sysadmin Work ================== Find Identical Files -------------------- I needed to find all files named similarly to `save.sh` and see which ones had the same content. The `sum` command produces a unique number based on content, so I used: $ find ../.. -name '*save*.sh' | xargs sum | sort [...] 00153 1 ../../net2003/07w/t3unx/multi/save.sh 00153 1 ../../net2003/08w/t1unx/save.sh 00153 1 ../../net2003/08w/t2unx/save.sh 00153 1 ../../net2003/08w/t3unx/multi/save.sh 13967 1 ../../dat2333/00f/t4unx/save-file.sh 17009 1 ../../dat2343/00f/proj3/saveproj3.sh 17009 1 ../../dat2343/01f/proj3/saveproj3.sh 40014 1 ../../dat2333/00f/save-file.sh 40014 1 ../../dat2333/99f/oak1/save-file.sh 40014 1 ../../dat2333/99f/save-file.sh 51494 1 ../../net2003/05w/dosave.sh 64071 1 ../../dat2330/04f/dosave.sh The sums at the start of each line tell me which files have the same content. I can make sure these files are hard links to each other, rather than separate copies of the identical content. Compare Scanner Sheets ---------------------- I ran your scanner sheets through ITS a second time. I couldn’t simply run a difference of the two files, because the first three fields on each line were different. Below is the command line that strips the first three fields from each file using `sed` with *regular expressions*, sorts the files to make sure they are in the same order, and compares them with the `meld` graphical difference program. The line uses BASH named pipes (FIFOs) syntax to name the two arguments to `meld`: $ meld <(sed -e 's/^[^ ]* *[^ ]* *[^ ]* *N //' "$file1" | sort) \ <(sed -e 's/^[^ ]* *[^ ]* *[^ ]* *N //' "$file2" | sort) The result was: - One name got a missing letter scanned the second time. (This was the student who alerted me to the scanner problem.) - A second name got an extra letter scanned (not part of the name). - Six student numbers changed. Some got more digits; some fewer. (I ignore these. You were told *not* to put your student numbers on the sheets.) None of the 46 test score fields changed in any of the sheets. You will learn **Regular Expressions** next term in **GNU/Linux II**.  ![Take Notes in Class] -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/ [Plain Text] - plain text version of this page in [Pandoc Markdown] format [www.idallen.com]: http://www.idallen.com/ [Quoting]: 440_quotes.html [List of Commands You Should Know]: 900_unix_command_list.html [lynda.com]: https://lyceum.algonquincollege.com/Lynda [Unix for Mac OS X Users]: http://wwwlyndacom.rap.ocls.ca/Mac-OS-X-10-6-tutorials/Unix-for-Mac-OS-X-Users/78546-2.html [Startup Files]: 350_startup_files.html [CentOS Installation and Configuration]: 000_centos_install.html [Worksheet #06 HTML]: worksheet06.html [The VI (VIM) Text Editor]: 300_vi_text_editor.html [the `cp --no-target-directory` option]: https://gnu.org/software/coreutils/manual/html_node/Target-directory.html#Target-directory [my StackExchange article]: http://unix.stackexchange.com/questions/94831/cp-no-target-directory-explained/94838#94838 [explainshell]: http://www.explainshell.com/ [*Answer*]: 440_quotes.html#quote-all-grep-and-find-expressions [Take Notes in Class]: data/remember.jpg "Take Notes in Class" [Plain Text]: week07notes.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/