Corning Community College

UNIX/Linux Fundamentals


End of Course Experience (For Great Justice)




Objective

To assess the skills you have acquired in the course on your journey to enlightenment this semester.

Rules

Presented within will be various questions testing your knowledge and experience gained this semester. In places where you are able, the more you write and explain topics the better the chance you will have of receiving full credit (and alternatively, the more partial credit you will receive should something be incorrect.)

The questions on this experience are open resource with the exception of other individuals. In that respect, it is CLOSED PERSON. This means you are not to communicate with other people (either in the class or otherwise), in real life or electronically. Use your own knowledge, use your skills, and use your ability to access the allowed resources to aid you in coming up with your well thought out answers to each question.

You are allowed, and expected, to ask me questions, so that the problem can be better clarified.

There are three parts to this experience:

Additionally, if you do some additional scripting questions they could count for unaccounted-for labs. So.. if you'd like to take advantage of this.. here's the breakdown:

Be sure to clearly state your intentions for any question/lab tradeoffs so I am aware of them. And if you're not sure on a valid tradeoff, be sure to ask me so I can tell you yes or no.

You have until 11:59:59pm (that's 23:59:59 in 24-hour time) Thursday, December 17th, 2009 to complete and submit this to me electronically. If desired, our scheduled finals week meeting time is: Wednesday, December 16th, 2009 from 02:30pm-05:30pm in B003 (our regular room). If you desire to submit in a non-electronic format, have it in my hands before 05:30pm Wednesday, December 16th, 2009 in B003.

Good luck!


Questions (Part I)

Be sure to read each question and work logic out on paper. Don't get frustrated- ask questions if you need clarification!

Note that, by default, you must do ALL 15 questions in this part.

1

Given the following command-line:

cat < spoonful_of_sugar | sort -r > fly_a_kite
	a. What is the input file. How do you know this?
	b. What is the output file. How do you know this?
	c. How is the data in the output file changed from the input file?
2

The file /usr/games/pom (-rwxr-xr-x) is what type of file? (regular, directory, special).

Why isn't it the other two types? Explain.

3

Create regular expressions to match the following patterns (which you can check against the /usr/share/dict/words file)

	a. All the five letter words that start and end with a
	   lowercase or uppercase vowel.
	b. Three letter words that do not contain the letters
	   i, j, k anywhere in the word.
	c. All words containing the substring "gree".
	d. All words that start with m and M, and have a 'g'
	   somewhere in the middle.
	e. All words that contain the substring "bb" and end
	   with a vowel.
	f. Only words that do not contain: r, s, t, l, n, or e.

NOTE: Where appropriate, don't forget to specify start of line and end of line indicators.

4

What is the UNIX philosophy? And how does that philosophy play a part in various places on a UNIX system, and even in various ideals behind coming up with solutions and computing in general?

5

Provide octal permissions for the following criteria. Explain your reasoning:

	a. User can read and write; group can execute; everyone
	   else can just read.
	b. User can do everything; group can read; everyone else
	   can do nothing.
	c. User can read but can't delete or execute; group can
	   execute; the world can read.
	d. User can only modify; ditto for group; world is left
	   out cold - it can't do anything.
6

Let's say we wanted to play a really fun game, but the executable is in /var/public/unix/eoce/ (under the UNIX Public Directory) by the name of "game", which is NOT in our default $PATH. Or is it?

a. Verify whether or not the path to game is in your PATH.

b. From your home directory, specify a relative path to run this game.

c. Specify an absolute path.

d. How would you modify your PATH variable to include the path to game?

7

What facilities do we have at our disposal for securing data? Explain how it can both enable us to access our data, as well as to restrict its access by undesired individuals.

8

In the /var/public/unix/eoce directory is an executable named mystery. Run this program and do the following:

a. Does the program output to STDOUT or STDERR?

b. How can you prove this?

Be sure to justify your answer and provide proof that backs up your claims.

9

Create Regular Expressions to match the following (inclusive):

a. boat, boot, poet, somethinglikethat

b. how, now, brown, cow

NOTE: When I say "inclusive", I want you to come up with a Regular Expression that will match all the specified words in that line item.

10

If you had the following text in a file:

We've got a banjo, and we've got a band, and we've got a banjo in the band.
	a. Using the cut(1) utility, how would you logically divide
	   this into 3 parts?
	
	b. Display "and we've got a band" to STDOUT. Show me how you
	   did this.
11

Let's say we have the following:

myvar="something"
youvar="$myvar is nothing"
myvar="everything"
	a. If you were to execute these three commands in the order
	   given, what are the final values of $myvar and $youvar?
	b. How would you determine the contents of each variable?
	c. How does $youvar get the way it is? Explain.
	d. If you had used single quotes instead of double quotes
	   in the above commands, what would have happened and why?
12

Given the following text files:

first_of_three second_of_three third_of_three
	a. How would you concatenate (ie combine) all three files into
	   one big file called "the_whole_shabang"?
	b. Show you command-line and give your reasoning.
13

Directory separators play a vital role in allowing us to visually see the organization and layout of our data. In UNIX, the "/" (forward slash) is used to separate directories in a path. Other systems may make use of other symbols (DOS/Windows, for example, uses the "\" (backslash), and the older HFS filesystems on MacOS use ":").

However, it is important to realize that symbols can have different meaning on different systems. The "\" may be a directory separator under DOS/Windows, but it carries a completely separate meaning under UNIX.

If I were to give you the following command-line:

lab46:~$ cd \usr\local\lib

And if I originally wished to end up in the "lib" subdirectory of the "local" subdirectory of the "usr" directory, answer me the following questions:

What will happen?

Where will I go?

How many directories/files am I specifying?

Why is this happening? Explain.

14

The first UNIX filesystems allowed for filenames to be up to 14 characters in length. As time went by, this limit increased to 255 characters, and even larger (around 10,000 characters). In UNIX, there is no concept of an extension (ie in MS-DOS you have 8 characters followed by a 3 letter extention-- known as 8.3 notation). However, the concept of the file extension is still in common use but used to help the user distinguish files (just as with the --color=auto option to ls(1), files are colorized). The underlying operating system doesn't care what extension or color the file is, but it can be useful to the user.

In DOS, a common wildcard to specify all files is: *.*

In UNIX, why is * better than: *.*

Explain your answer.

15

The /etc/shadow file contains account password information for certain users on the system.

A. How would you show me the encrypted password for one of the accounts?

B. If you try it, are you able to accomplish the task? Why or why not?

C. Why do you suppose that is?

D. What would be the benefit of doing something like this?

Be sure to answer ALL four parts.


Scripting (Part II)

Be sure to read each question and work logic out on paper. Don't get frustrated- ask questions if you need clarification!

For the purposes of the experience, you are only required to do two (2) scripting questions. Any additional questions can be used to count towards questions in part 1, or past due labs/case studies. See the rules section above for details.

NOTE: All shell scripts must be very well documented, very readable, and organized to receive full credit.

16

Palindrome

A palindrome is a word that, when reversed, spells the same word backwards as it does forward.

I would like you to write me a script that does the following:

  • Prompts the user to input a word. Store it in a variable.
  • Come up with logic and script magic to reverse the word. Store it in another variable.
  • Display the word both before and after to STDOUT. So the user can see the result of any processing.
  • Perform a check to see if the word is a palindrome (ie same backwards as it is forward).
  • Display a message indicating its status as a palindrome.
17

Total Time On-Line

The last command displays user logins back to the start of the reporting period (typically the start of the month).

I would like for you to write me a script that will display, in ASCII text bar graph/histogram form, each detected user's time (in units of hours)

Also, keep track of the user with the greatest amount of time and display that information at the end of your output.

18

Word Jumble Assistant

Each morning, after you scour through glancing at the pictures, filtering out the propaganda and lies, you settle down to read the daily comics and to do the various word puzzles.

Usually, you spend a few minutes hacking away at the word jumble, trying a few different combinations in your head, and if successful at a few, you keep going until it seems like you are getting nowhere, and then you move on to something else.

However, after taking a semester's worth of UNIX, the thought dawns on you one day that, especially after doing text manipulation and pattern matching, might there be some facility you could take advantage of to assist you in solving these word puzzles?

Obviously, I wouldn't be presenting you with this question if I didn't think it was possible. Additionally, it would allow you the opportunity to think about thinking how you could get the computer to help you come up with the solution.

So, I'd like you to write for me, a script that does the following:

  • Prompt the user to enter, one at a time, the available letters with which is can search. Terminate input by checking for the string "done".
  • Assemble all the input (minus the "done") into a concatenated string that you can use in the construction of a regular expression.
  • Create a regular expression that will search the dictionary file (/usr/share/dict/words) for all occurrences of words that contain (and only contain) the user-specified letters.
  • If the resulting number of words is greater than 20, display the results as a set of comma separated values (ie word1, word2, word3, word4, ...) 6 words per line, then wrap and start another line.
  • Otherwise, display the resulting matched word list to the screen one word per line (ie just as you'd see when we did searches in class).

Remember to look at the component parts of this problem, otherwise you might feel it is quite overwhelming and think I'm asking the impossible.

Be sure to ask questions, and also to accomplish pieces of the problem-- make sure you've got one step down before proceeding to the next. And have captive experiments, so you can judge for yourself whether or not your logic is working.

19

Class Listing

You may recall our attempts a few weeks back where we threw some regular expressions at the CCC Class Scheduling HTML file containing ALL classes being taught in the Spring 2010 semester.

We had a considerable amount of luck locating patterns that allowed us to filter out unnecessary information and to display pertinent data to the screen for our viewing consumption.

What we didn't do (and which I hinted at may well become some sort of scripting project-- and voila!) was further process this information to let us do more advanced class searches for scheduling purposes.

So, guess what I want you to undertake for this problem.

I've downloaded an updated course listing, including only those courses offered at the official campus locations (ie excluding ACE courses and minor locations like high schools). There's a copy in the UNIX Public Directory (/var/public/unix/eoce/spring2010-20091201.html.gz) for your uses.

Create a script that accomplishes the following:

  • Filters spring2010-20091201.html for only the useful course title and detailed information, as we did in class.
  • How many courses is CCC offering in the Spring 2010 semester?
  • How many CSCS courses are being offered? How many CSIT courses?
  • How many sections of MATH0960 are offered MWF mornings between 8:30AM and 1:55PM?
  • What are the CRNs for the ENGL1020 courses that are offered T-Th between 9AM and 12:35PM (inclusive)
20

Word Jumble Assistant - Part II

For those up for more fun, try your hands at implementing the following additional features to the Word Jumble Assistant script:

  • Implement a menu that gives the user additional choices for word match selection.
  • Allow the user to specify words that start with certain characters.
  • Allow the user to specify words that end with certain characters.
  • Allow the user to specify words of a fixed length.
  • Allow the user to specify words that have a certain character at a specific position.
  • Implement a loop allowing the user running the script to perform a search for multiple words (ask the user if they'd like to go again).

You may have to make some assumptions about certain things during your implementation. This is okay. State your assumptions at the beginning of your script in comments so that I know why you're doing things the way you are.

21

Palindrome, Part II

To do this one, I'd like you to solve the palindrome problem again, but you must use an entirely different approach to the way you reversed the word, and also how you checked to see if it is a palindrome.

That is, the two scripts should look entirely different, your strategy and tools used for doing the task should not be related. This is an attempt to get you to look at a problem in entirely different ways.

22

Total Time On-Line, Part II

Taking the script you wrote in "Total Time On-Line", extend it to do the following:

  • Rank time results from greatest to lowest for all reported users.
  • Display the user who has logged in the most.
  • Display the user who has logged in the least.
  • If given an argument on the command-line, assume it is a username, and report only that user's time and login frequency on execution of the script.

NOTE: To determine if a username is valid or not, the id command can be utilized.

HINT: You may wish to make use of temporary output files to assist you in solving this problem.


Documentation on the Wiki (Part III)

You are to do this question.

23

Documentation on the Course Notes Wiki

As part of your experience in the course, you were to have contributed to the creation of a wiki (course notes) documentation pertaining to and detailing some of the knowledge learned and experienced this semester in UNIX.

What I would like to see are unique sections pertaining to each of the major course topics we covered, along with any pertinent subsections describing important sub-topics. Informative descriptions, mini-howto's (a command-line or two), and other useful bits of information can be helpful in making a document that is quite useful. Additional sections also welcome.

This question creates a unique exception to the overall rules to the end of course experience. I will allow collaboration to take place in order to accomplish this task. But you must not abuse it and participate in communications involving the other questions. Performing such communications on the class IRC or the class mailing list are more than acceptable, and encouraged (and would also help any participation assessments).

In the end, I expect to see submissions from EACH member of the class, with modification dates taking place during this month of December, 2009. Those that have already participated are not exempt, although you may have considerably less work to perform for this question than others.

I would like to see, at a minimum, ~500 words of content contributed by EACH class member.


More Questions (Part IV)

Be sure to read each question and work logic out on paper. Don't get frustrated- ask questions if you need clarification!

You are to do all three (3) questions in this section.

24

Of all the work you've done this semester in this course, identify something that was meaningful to you.

	a. What is it?
	b. Why does it stick out in your mind? Explain
25

As is my usual exercise, I love asking your opinion of things, hoping for your honest and thought-provoking response, regardless of its positivity or negativity. As such, this question is pretty much a "gimme" (as in, the only way you could possibly lose points is if you leave it blank)

So, I'd like for you to answer me the following:

	a. How did you feel about the course?
	b. Was it useful/interesting to you?
	c. What was your least favorite aspect, and why?
	d. Any comments, suggestions?
26

After an exciting and intellectually challenging run, we're arriving at the end of this semester's journey. Some will be moving on, others sticking around for more. I make it a practice to listen to your thoughts and suggestions. The course, as we all experienced it, unfolds in a manner pertaining, in part, to how you respond to concepts and topics (do we need more time, can I crank it up a couple notches, etc.) so each semester and each class is entirely different from any other- because of each of you, and all of us, working together and learning together.

So, searching deep down within your soul- balancing reason with emotion, and considering attendance and timeliness; what grade do you feel you deserve for this course, and why? Justify your answer based on your own perceived performance, not on need.

When Finished

All questions in this assignment require an action or response. Please organize your answers into an easily readable format and be prepared to submit the final results to your instructor.

Your assignment is expected to be performed and submitted in a clear and organized fashion- messy or unorganized assignments may have points deducted. Be sure to adhere to the submission policy.

When complete, submit your assignment to the appropriate instructor- be sure to identify your e-mail submission with an appropriate subject line.

As always, the class mailing list is available for assistance, but not answers.

Last Updated: December 01, 2009