Updated: 2013-11-21 14:12 EST

1 Readings, Assignments, Labs, and ToDo

1.1 Assignments this week

Check the due date for each assignment and put a reminder in your agenda, calendar, and digital assistant.

1.2 Lab work this week

3 From the Classroom Whiteboard/Chalkboard

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

4 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 ***
----------------------------------------------------------------------------

5 Real Sysadmin Work

5.1 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.

5.2 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:

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

Author: 
| 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


Campaign for non-browser-specific HTML   Valid XHTML 1.0 Transitional   Valid CSS!   Creative Commons by nc sa 3.0   Hacker Ideals Emblem   Author Ian! D. Allen