Table of Contents

Thomas Hakes's Opus

Where the magic happens…

Introduction

Hello everyone, my name is Tom and I enjoy unix. I chose to take this class because I have always wanted to learn more about Unix, and so far I have learned that I must learn alot more.

Part 1

Entries

Entry 1: February 17, 2012

Today I learned that the terminal screen can be split into multiple instances within one terminal. How crazy is that?! This will probably change how I will work within terminal for the rest of the class. I am currently using three instances at once for terminal, various manual pages, and the largest for my working terminal.

Entry 2: February 29th, 2012

Today I researched “beep” and found that the internal speaker of your computer can be manipulated by using some of the suffixes of beep. I will now spend time trying to write “funky town” in a script just to play for the nice people down at the Lair.

Entry 3: March 1st, 2012

Today I learned that there is a wait in bash. By issuing a sleep, I am able to wait before issuing several commands. This is helpful for creating multiple command scripts that will not overlap each other and will allow it to run exactly how I see it running. It also helps for issuing a command several times throughout the day, such as beep >;]

Entry 4: Almost March 2nd 2012

The beep command is strange indeed. The man page gives a detailed list of different frequencies that should match up with different tones similar to a piano. Unfortunately, They do not sound the same as the notes.

Keywords

unix Keywords

The Vi Editor

Identification of chosen keyword (unless you update the section heading above).

Definition

One of the more basic text editors in terminal. Primarily used with writing code.

Demonstration

By using a basic command, you are sent into the text editor. From there you can write whatever you want. You can either choose to save it or not upon exit by hitting escape then “:q”

What it looks like:

lab46:~$ vi newfile.txt
~
~
~
~
~
~
~
~
~
~
"newfile.txt" [New File]                              0,0-1                  All

Local Host

Definition

An alias for the network address “127.0.0.1” that always points to the local computer.

Demonstration

The local host is the name given to this network address “127.0.0.1” It is how the computer refers to itself.

When testing a web service on a server (such as apache) you use the local host address 127.0.0.1.

Home Directory

Definition

A directory in the system that contains the users files.

Demonstration

In lab46, the generic path to the home directory is /home/(enter your user name here)

There are several shortcuts to the home directory. The command “cd ~” has always been my favorite.

Here is an example of a home directory

lab46:~$ ls
Desktop    Folder   Templates  public_html
Documents  Maildir  Pictures  Videos     bin       src
Downloads  Music    Public    Workspace  src.bak
lab46:~$ 

Current Working Directory

Definition

The part of the hierarchy you currently reside in.

Demonstration

In the Directory system of linux, there are several files and folders. These folders are actually directories. The current directory is the directory that the terminal is in.

By casting the command “pwd” , it prints your current working directory and displays it in front of you.

lab46:~$ pwd
/home/thakes3
lab46:~$ 

Remote Host

Definition

A web server or database that you have access to via the internet.

Demonstration

A good demonstration of remote hosting would be Window's remote desktop. Remote Desktop is an application run on Windows that allows you to connect to another computer's screen remotely.

Shell Scripting

Definition

Script written for the shell of an operating system.

Demonstration

Shell scripts are mostly ascii text, with several commands in them , and are executable.

Shell scripts can be executed by using the “./”

File Manipulation

Definition

The process of changing, moving, adding, deleting, or allowing access to a file.

Demonstration

There are several ways files can be manipulated. I will show you some of the ways to manipulate a file.

By moving the file

lab46:~$ mv file.txt /folderhere
lab46:~$ cd /folderhere
lab46:/folderhere$ ls
file.txt
lab46:/folderhere$

By deleting the file

lab46:~$ rm file.txt
lab46:~$ ls

lab46:~$

By copying the file

lab46:~$ cp file.txt file2.txt
lab46:~$ ls
file.txt   file2.txt
lab46:~$

Job Control

Definition

The ability to work jobs in the background while you continue to work at the shell.

Demonstration

By using the bg command, you are able to send the job you are currently working on to the background while you continue to work.

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ bg
lab46:~/src$ 

unix Objective

unix Objective

State the course objective

Definition

In your own words, define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Is there room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

Experiments

Connect to Lab46 from Lab46

Question

Are you able to connect to Lab46 through ssh, from Lab46?

Hypothesis

I believe that you are able to connect to your ssh terminal (or another users) from an already existing terminal such as lab46.

Experiment

My experiment will be logging onto lab46 and attempting to connect to lab46 via ssh.

Data

I begin by connecting to lab46.

 __         _     _ _   __   . . . . . . . . . . . . . . . . . . . . . . . . .
|  |   __ _| |__ / | |_/ /   . Basic System Usage:  Type 'usage' at prompt   .
|  |__/ _` | '_ \\_  _/ _ \  . Events and News:     Type 'news' at prompt    .
|_____\__,_|_.__/  |_|\___/  . Broken E-mail?       Type 'fixmail' at prompt .
---------------------------  . Check Lab46 Mail:    Type 'alpine' at prompt  .
c o r n i n g - c c . e d u  . . . . . . . . . . . . . . . . . . . . . . . . .

 Lab46 is the Computer & Information Science Department's Student Development
 Server for Computer-related coursework, projects, and exploration.  For more
 information, please check out:
  .. .  .    .        .                .                .        .    .  . ..
 .  Lab46 Web Page:       http://lab46.corning-cc.edu/                       .
 .  Lab46 Help Form:      http://lab46.corning-cc.edu/help_request           .
 .  Help E-mail:          haas@corning-cc.edu or wedge@lab46.corning-cc.edu  .
  .. .  .    .        .                .                .        .    .  . ..
You have old mail.

From here I attempt to connect to lab46 (ssh lab46.corning-cc.edu -l thakes3)

thakes3@lab46.corning-cc.edu's password: 

And viola! A beautiful inception-like lab46 terminal!

thakes3@lab46.corning-cc.edu's password: 
 __         _     _ _   __   . . . . . . . . . . . . . . . . . . . . . . . . .
|  |   __ _| |__ / | |_/ /   . Basic System Usage:  Type 'usage' at prompt   .
|  |__/ _` | '_ \\_  _/ _ \  . Events and News:     Type 'news' at prompt    .
|_____\__,_|_.__/  |_|\___/  . Broken E-mail?       Type 'fixmail' at prompt .
---------------------------  . Check Lab46 Mail:    Type 'alpine' at prompt  .
c o r n i n g - c c . e d u  . . . . . . . . . . . . . . . . . . . . . . . . .

 Lab46 is the Computer & Information Science Department's Student Development
 Server for Computer-related coursework, projects, and exploration.  For more
 information, please check out:
  .. .  .    .        .                .                .        .    .  . ..
 .  Lab46 Web Page:       http://lab46.corning-cc.edu/                       .
 .  Lab46 Help Form:      http://lab46.corning-cc.edu/help_request           .
 .  Help E-mail:          haas@corning-cc.edu or wedge@lab46.corning-cc.edu  .
  .. .  .    .        .                .                .        .    .  . ..
You have old mail.

Analysis

Based on the data collected:

  • My hypothesis was correct.
  • There are many other ways that this can be applied, as in connecting to a machine on the network.
  • This also shows that you can have multiple people on the same account running at the same time

Conclusions

My conclusion is that the experiment worked exactly as I thought, and this brings up many topics to be learned regarding ssh.

Remote Beeping

Question

Can you remotely use a pc speaker via an ssh connection?

Hypothesis

I believe that by connecting to my pc (foxtrot) from lab46, I will be able to use the beep command and make the internal pc speaker on foxtrot beep.

Experiment

I will attempt to connect to foxtrot from lab46, and then use the beep command to see if the pc speaker beeps.

Data

I start by connecting to lab46.

lab46:~$

From here I will connect to foxtrot. I have a script written so that I would not have to type the ip in repetively.

lab46:~$ ./foxtrot
thakes3@foxtrot:~$

And then from here, I will now use beep to see if the pc speaker beeps.

thakes3@foxtrot:~$ beep
thakes3@foxtrot:~$ 

The pc speaker beeped, thus success.

Analysis

I was able to connect successfully and remotely beep the machine.

  • This shows me that several functions of the computer can be accessed remotely and used.
  • This also shows that by connecting to foxtrot via ssh, you are completely engulfed in the computer, and thus all functions are of that computer and do not relate to the computer you are currently on.

Melodies with Beep

Question

By manipulating the beep command, are you able to play melodies?

Resources

Hypothesis

I believe that by using the varias manipulations of beep, you are able to play songs from the pc speaker

Experiment

I will attempt to use a script I found on ubuntu forums on foxtrot to try and play a melody.

Data

I start by connecting to lab46 and then connecting to foxtrot.

thakes3@foxtrot:~$

From here I copy and paste the several lines of code into a new file i named louder.sh by using the text editor nano. Now I must use the chmod command to make it able to run

thakes3@foxtrot:~$ chmod 744 louder.sh
thakes3@foxtrot:~$

And now lastly, I must execute the program.

thakes3@foxtrot:~$ ./louder.sh
thakes3@foxtrot:~$

The pc speaker was able to play a fine tuned melody perfectly.

Analysis

I was correct that the pc speaker can play a melody.

A short coming I came across: I had to modprobe pcspkr. This allows me to use the beep command. Without it I could not. Also, you must install the beep command. It does not come automatically as a command.

Part 2

Entries

Entry 5: March 2, 2012

Today using the lab46 net boot, I installed debian on 5 different machines. I am beginning my journey to create an orchistra of pc speakers using the beep command. All the names of the computers are of similar style as foxtrot.

Entry 6: April 4, 2012

Today I researched the different modifications to vim, from line numbers to syntax coloring. As I researched, I had found that there are several themes to choose instead of the default syntax coloring. Right now I'm using the desert theme.

Entry 7: March Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 8: March Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Keywords

unix Keywords

Types of files (UNIX)

Definition

There are several types of files in the unix environment.

Demonstration

Regular Files: These are a common file within unix. It is a plain collection of bytes of data. Directory: These are a special type of file as they only contain other files. You do not work on a directory directly. Special Files: These are commonly known as the device files on unix. They are usually only owned by root and cannot be modified by the user.

File Manipulation (Unix)

There are several ways to manipulate files in an Unix system. Manipulation ranges from removing, creating, sharing, storing, copying, and editing.

Demonstration

Removing a file:

lab46:~$ rm file.txt
lab46:~$

Creating a file:

lab46:~$ touch file.txt
lab46:~$

Changing sharing settings on a file:

lab46:~$ chmod 777 file.txt
lab46:~$

Copying a file:

lab46:~$ cp file.txt file2.txt
lab46:~$

Editing a file (using vim):

lab46:~$ vim file.txt
~
~
~
~
~
~
~
~
~
~
~
~
Default                 0,0-1   All

Saving a file (with vim):

Random Text Here
~
~
~
~
~
~
~
~
~
~
:save file.txt

Text Processing

There are many commands for processing text within unix. Text Processing is the manipulation of text within the unix system.

Demonstration

grep, sort, tail, less, more, and echo.

Echo

Echo is a text manipulation tool that reads text back to the user. It is very useful for editing files without opening them in a text editor.

lab46:~$ echo hello
hello
lab46:~$
Sort

Sort is a nifty little tool that allows you to sort a file of random values and sort them by different means. Using -d will sort them by the dictionary, -n numerically, ect.

thakes3@lab46:~$ ls | sort -d
Backups
Cprog
Desktop
Documents
Downloads
Foxtrot
Maildir
Source_Code
Universe
Unix
bin
file.pie
pop
public_html
src
thakes3@lab46:~$ 
Tail

Tail is a neat little tool that allows you to read the last 10 lines of a file (by default). Several invocations allow you to manipulate and change what the tool does.

thakes3@lab46:~/Source_Code/ed_editor_vineeth$ tail GNU\ Public\ License.txt 

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS
thakes3@lab46:~/Source_Code/ed_editor_vineeth$ 
Less

less is a filter for paging through text, based on the more command. It is different to more because it does not need to read in the entire file before editing

The GNU General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
GNU\ Public\ License.txt 
:q
thakes3@lab46~$:
More

More is a more primitive version of less that reads in the entire file before opening it for editing.

The GNU General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to sh
are and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any 
other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your
 programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free 
software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free progr
ams; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain respo
nsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, r
eceive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someo
ne else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' re
putations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, i
n effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public Licen
se. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, 
a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limita
tion in the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the o
utput from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends 
on what the Program does.
--More--(26%)
:q
thakes3@lab46:~$
Grep

grep is an amazing tool that allows you to search for patterns in both files and folders. You can also search for a string or certain cases.

thakes3@lab46:~$ who | grep thakes3
thakes3  + pts/23       2012-04-27 22:47 00:39        2264 (172.16.198.142:S.0)
thakes3  + pts/32       2012-04-27 22:48   .          2569 (172.16.198.142:S.1)
thakes3@lab46:~$

The Unix Shell

The Unix Shell refers to the command programming language that speaks directly to the operating system in order to complete several tasks.

Different Shells

There are many different types of Unix Shells. A few important ones include:

Bourne shell (sh) - Was written by Steve Bourne of Bell labs and is available on every unix operating system C shell (csh) - Was written in the University of California, and is a shell written in C code that uses C code to execute scripts and such. TC shell (tcsh) - Is a public domain shell, and it has all of the functionality of the C shell with the emac's style editing of command line Korn shell (ksh) - This shell is also a public domain shell that uses both the c and the tc shell's features but with a shell programming language similar to the bourne shell. Bourne Again SHell (bash) - Is a public domain shell under the GNU project and has features from both the c shell and the ksh shell, yet directly programmable like the bourne shell.

Job Control

The ability to multitask on a Unix command line interface is very important. Having such abilities allows us to work on several things at once and allows us to be more versatile and efficient with whatever we are working on. For this we have such tools that allow us to switch easily between jobs.

Demonstration

Backgrounding and Foregrounding are a very nice way to run things in the background while working on the console at hand. Let's say I want to download a large file, like the iso file for Ubuntu (12.04 just came out). By adding a '&' to the end of the command, it is able to start in the background while I continue on other things.

lab46:~$ wget ubuntu* &
lab46:~$

Now I have my prompt back I am able to continue working. To resume that task all I need to do is type 'fg'.

lab46:~$ fg

[ =========>              ] 26%

Screen is another amazing multitasking tool that allows us to have multiple cli's open at once. It allows us to switch between screens and work on multiple files at once by splitting the terminal down. To open a screen just type in 'screen', as an alias in lab46 is already in place. This will open a new cli with a completely different .bash_history.

The Unix Programming Environment

The Unix interface is a special one in that it was designed by programmers for programmers. It holds several tools in it's system to both create and maintain code and provide an environment for others to do the same. From text editors to compilers, the Unix environment is designed for programming.

Demonstration

The Unix programming environment has tools created by those beautiful folks over at GNU, that allow compiling upon the installation of the os. This is very useful as in some instances people cannot access the internet or do not have the means to get another compiler.

The GNU Compiler Collection (GCC) contains front ends for C, C++, Objective-C, Fortran, Java, Ada, and Go, as well as many other languages.

The native text editors such as pico or vi, are very powerful tools. They allow easy editing, quick saving, and several helpful tools such as syntax highlighting, finding, over riding, and other great tools that systems such as a windows platform may not come with.

In most platforms of unix, there are easy to use tools to download and install applications written by other peoples in repositories. Such tools include apt-get, aptitude, yum, ect.

Compiler, Assembler, Linker , Loader

These are some of the stages of compilation in the C programming language. They all provide a specific roll in creating programs that run on the computer.

Demonstration

Compiler - Does the lexical analysis by breaking the code into pieces and then checks them for correctness. It then generates a lower level code from the code written. It then looks for possible flaws in the programs logic, and then generates assembly code.

Assembler - Translate the assembly code given from the compiler into the system specific object code.

Linker - Links the object code with some other libraries to make it run-able

Loader - Executes the program on a system specific platform

Pattern Matching

Pattern matching is a neat little process that allows us to decipher text from either files or other processes outputting text. We can choose to display what we want to display.

Demonstration

Pattern matching in unix is quite fun really. We can look for common identifiers between files, such as the tailing file type or the use of vowels.

For this example I have created a file named file.txt that holds several words.

This is the inside of the document

Puppy
Kitty
Cow
sheep
elephant
alligator

Now I will make use of the command “grep” and it's ability to match certain patterns within words. I will grep for the vowel 'o' and what words contain them

lab46:~$ grep [o] file.txt
Cow
alligator
lab46:~$

unix Objective

unix Objective

State the course objective

Definition

In your own words, define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Is there room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

Experiments

Experiment 4

Question

Can I remove the beep from the terminal so that it can stop annoying me?

Resources

http://www.thinkwiki.org/wiki/How_to_disable_the_pc_speaker_(beep!) the man page for modprobe the man page for beep

Hypothesis

I believe that if the pcspkr is disabled, then it cannot beep any longer and it would prevent angering me beyond belief. By backspacing in terminal

Experiment

I will attempt to remove the probe in pcspkr disabling it from beeping anymore when I backspace in terminal

Data

I begin by logging into Foxtrot. From here I use the -r appendage to the modprobe command.

thakes3@foxtrot:~$ sudo modprobe -r pcspkr
password:
thakes3@foxtrot:~$

from here I will try to backspace to see if the terminal will beep

lab46:~$

Analysis

Based on the data collected:

  • Was your hypothesis correct? - yes
  • Was your hypothesis not applicable? - no
  • Is there more going on than you originally thought? (shortcomings in hypothesis) - nope
  • What shortcomings might there be in your experiment? - when i reboot, it will revert back to normal
  • What shortcomings might there be in your data? - I don't know of any so far

Conclusions

Now the beep will not bother me, as it is long gone.

Tripple Screening with X

Question

Is it possible to create multiple monitors without the need of an external graphics card in linux?

Hypothesis

By attempting to configure X to my needs, I should be able to make my computer be able to handle three heads at once.

Experiment

By editing my X11 configuration file

Data

I started off by running X -configure in root user mode with no GUI present.

bravo:~$ cd /etc/X11/
bravo:~$ X -configure

I then began looking for the xorg.conf file.

lab46:~$ find / -name 'xorg.conf' 2> /dev/null
/etc/X11/xorg.conf
lab46:~$

I added a third entry for the monitor I am trying to use and assigned it to the second graphics card.

Analysis

Based on the data collected:

  • Was your hypothesis correct? - I would assume so, but I cannot get it to work.
  • Was your hypothesis not applicable? - It's not applicable in the sense that I would only need to edit that one file. There are other files linked that I do not have enough information about
  • Is there more going on than you originally thought? (shortcomings in hypothesis) - Yes there is
  • What shortcomings might there be in your experiment? - the X server isn't built for three screens on pci hardware
  • What shortcomings might there be in your data? - possibly I would need a third party application to get it to work

Conclusions

Multiscreening is hard!

Retest 2

Perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • If you find a deviation in opinion, state why you think this might exist.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • Can you explain any deviations?
  • How about any sources of error?
  • Is the stated hypothesis adequate?

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • Does the original author appear to have gotten some value out of performing the experiment?
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).

Part 3

Entries

Entry 9: April Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 10: April Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 11: April Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 12: April Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

unix Keywords

Regular Expressions

Like pattern matching, regular expressions involve text manipulation and other commands like grep.

Definition

By definition, a regular expression is a formula for matching strings that follow some pattern.

Demonstration
Networking, Unix tools

There are several important commands in unix for networking. Whether it's checking your IP address or seeing if a website is up, these simple networking tools are very important.

Demonstration

ping - it sends packets to the address you give it, and tells you whether or not it received them.

lab46:~$ ping cnn.com
PING cnn.com (157.166.255.19) 56(84) bytes of data.

ifconfig - device interface config. These are your networking devices and what they are currently up too. It will list a bit of information reguarding the network it is connected too.

[sudo] password for thakes3: 
eth0      Link encap:Ethernet  HWaddr 00:30:84:0e:88:c1  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16 Base address:0x1400 

eth1      Link encap:Ethernet  HWaddr 00:11:0a:36:64:4d  
          inet addr:10.80.2.180  Bcast:10.80.2.255  Mask:255.255.255.0
          inet6 addr: fe80::211:aff:fe36:644d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4832 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2954 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4155503 (3.9 MiB)  TX bytes:526011 (513.6 KiB)
          Interrupt:20 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:660 (660.0 B)  TX bytes:660 (660.0 B)

Telnet - a protocol that allows you to remote to computers and both receive and send ascii text.

one of my favorite Telnets would be the star wars movie in ascii.

telnet towel.blinkenlights.nl
Shell Scripting

Shell scripting in unix is very important as it accomplishes repetitive tasks simply and provides an easy method of executing a command that takes rather long to type over and over again.

Demonstration

Shell scripting is very useful for writing a long command that sometimes is forgotten.

For this demonstration I will reveal my ssh shell script within my home folder

lab46:~$ cat Universe
ssh thakes3@69.207.208.154
lab46:~$

by changing the permissions to allow it to be executed (chmod a+x Universe) all I would need to do is execute that file and it would ssh me to that address.

lab46:~$ ./Universe
thakes3@69.207.208.154's password:
Security

The security environment in unix is rather unique as it relies on permissions and users to block out the information that should not be accessed by others.

Demonstration

Permissions are important in unix as they are needed for the current user to access the file. If your permissions are low for other users, such as read only, then they are not able to edit the file or make amends to it.

to view your permissions, use the -l appendage to the command 'ls'

lab46:~$ ls -l
total 3
drwxr-xr-x 4 thakes3 lab46 46 Feb 29 11:41 Backups
drwxr-xr-x 2 thakes3 lab46 28 Feb 25 15:06 Desktop
-rwxr--r-- 1 thakes3 lab46 27 Mar 2  14:43 Foxtrot
lab46:~$

to edit your permissions, see the chmod command.

Users in Unix often are put within a group of other users often referred to as a User Group. They are often given certain permissions to the entire group so that the group can accomplish a task together. every user must be a member of at least one group, which is identified in /etc/passwd. This group is referred to as the primary group ID. A user may be listed as member of additional groups in the relevant entries in the /etc/group; the IDs of these groups are referred to as supplementary group IDs.

results given by cat'ing /etc/group :

lab46:~$ cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
tty:x:5:wedge
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:
floppy:x:25:
tape:x:26:
sudo:x:27:
audio:x:29:
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:
plugdev:x:46:
staff:x:50:wedge
games:x:60:
users:x:100:
nogroup:x:65534:
libuuid:x:101:
crontab:x:102:
ssh:x:103:
ntp:x:104:
tss:x:105:
scanner:x:106:
nvram:x:107:
fuse:x:108:
kvm:x:109:
rdma:x:110:
messagebus:x:111:
utempter:x:112:
avahi:x:113:
netdev:x:114:
cl-builder:x:115:
$PATH

The path variable in unix is used for finding files that are executable instead of having to go to those locations specified inorder to execute a program.

Demonstration

By echo'ing the $PATH variable, you are given each directory that the cli searches for on the system.

lab46:~$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
lab46:~$

without these listed, when you attempt to use a program it will return a “command not found”

lab46:~$ PATH = null
lab46:~$ man dd
man: command not found
lab46:~$
Tab Completion

Tab completion in unix refers to the utility that allows you to automatically fill out the rest of the command you are attempting to type out, as well as directories that exist.

Demonstration

By using Tab completion your computer will guess as to what you are attempting to type. Let's say I want it to auto complete for file.

lab46:~$ fli
file               filebyproc.d       filecoordinationd  filtercalltree
lab46:~$ fli

Now I would like to edit a file with a very long file name. lets say treehuggersarefriendly.txt . Since there are no other commands or files that have any characters beyond tree, it will auto complete the name for you.

lab46:~$ vi treehuggersarefriendly.txt
lab46:~$
Environment Variables

Environment Variables are sets of dynamically named values that affect how programs run.

Demonstration

By using the command 'set', you are able to see all of the environment variables that are currently in place on the system.

lab46:~$ set 

Apple_PubSub_Socket_Render=/tmp/launch-zxcVFC/Render
Apple_Ubiquity_Message=/tmp/launch-h4tdQI/Apple_Ubiquity_Message
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="48" [3]="1" [4]="release" [5]="x86_64-apple-darwin11")
BASH_VERSION='3.2.48(1)-release'
COLUMNS=80
COMMAND_MODE=unix2003
DIRSTACK=()
DISPLAY=/tmp/launch-nlv4HI/org.x:0
EUID=501
GROUPS=()
HISTFILE=/Users/Thomas/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/Users/Thomas
HOSTNAME=Thomass-MacBook-Pro.local
HOSTTYPE=x86_64
IFS=$' \t\n'
LANG=en_US.UTF-8
LINES=24
LOGNAME=Thomas
MACHTYPE=x86_64-apple-darwin11
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=darwin11
PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PIPESTATUS=([0]="0")
PPID=649
PROMPT_COMMAND='update_terminal_cwd; '
PS1='\h:\W \u\$ '
PS2='> '
PS4='+ '
PWD=/Users/Thomas
SECURITYSESSIONID=186a5
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SSH_AUTH_SOCK=/tmp/launch-3MwPil/Listeners
TERM=xterm-color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=303
TERM_SESSION_ID=C4D3E870-C900-43E5-8C99-DD82C82ED39A
TMPDIR=/var/folders/s_/4x3d698174b8cn1l1c0m1mkm0000gn/T/
UID=501
USER=Thomas
_=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
__CF_USER_TEXT_ENCODING=0x1F5:0:0
update_terminal_cwd () 
{ 
    local SEARCH=' ';
    local REPLACE='%20';
    local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}";
    printf '\e]7;%s\a' "$PWD_URL"
}

You are able to change an environment variable by setting it equal to some value

lab46:~$ echo $TERM
xterm-color
lab46:~$ TERM=xterm
lab46:~$ echo $TERM
xterm
lab46:~$
Wildcards

Wildcards are a magical operator that allows the unix system to search for the beginning characters + 0 or more characters. They are very useful for searching for a very long file or searching for one that you do not know the rest of the name.

Demonstration

In this example I will be searching for a file named 'diablo3looksprettygood.jpg' within my home directory of /home/thakes3.

lab46:~$ find /home/thakes3 --name 'diablo*' 2> /dev/null
diablo3looksprettygood.jpg
lab46:~$

Note that it found the exact file even though we did not specify the rest of it.

I can also use vi on a different file 'lulzjkidkroflhahanoob.txt'

lab46:~$ vi lulz*

unix Objective

unix Objective

State the course objective

Definition

In your own words, define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Is there room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

Experiments

Experiment 7

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • Was your hypothesis correct?
  • Was your hypothesis not applicable?
  • Is there more going on than you originally thought? (shortcomings in hypothesis)
  • What shortcomings might there be in your experiment?
  • What shortcomings might there be in your data?

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Experiment 8

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • Was your hypothesis correct?
  • Was your hypothesis not applicable?
  • Is there more going on than you originally thought? (shortcomings in hypothesis)
  • What shortcomings might there be in your experiment?
  • What shortcomings might there be in your data?

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Retest 3

Perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • If you find a deviation in opinion, state why you think this might exist.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • Can you explain any deviations?
  • How about any sources of error?
  • Is the stated hypothesis adequate?

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • Does the original author appear to have gotten some value out of performing the experiment?
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).