User Tools

Site Tools


opus:fall2011:swilli31:start

Stephanie Raesel's Opus

Fall 2011

Introduction

I am a computer science major with ambitions to become a systems analyst or a software engineer. Upon graduation from Corning Community College I plan to enroll in SUNY IT in the Computer Science and Information combined bachelor and masters degree program. This is not the first time I have attended a college. I attended Howard University in Washington, D.C. as a mechanical engineering student from 2007-2009. I also intend to attain a Masters degree in aerospace engineering. My end goal is to obtain a job in the aerospace industry or government.

Part 1

Entries

September 15, 2011

Today in the class we played more with the VI Editor. We also did more with the control keys and learned of tab completion.

Things have finally really started to click for me in the class. Everything is mostly logic based and isn't some strange mythical thing that appears to do magic. This is significant because I am gaining valuable understanding and insight into the course. Some concepts that I am struggling with are some of the commands and the new things gone over in class today. With proper fiddling, I should, and will, be able to master this material. The challenges I am facing this week is the time to sit down and play with the Unix environment and VI editor.

September 20, 2011

Today we learned shell scripting in the class. I understood most of what we talked about. The few issues I have with shell scripting is knowing precisely what it is that I want to do and how I want to do it. I know that I can gain better knowledge and understanding as I become more familiar and comfortable with the Unix environment. I plan to try and practice more scripts in the coming weeks of my own accord.

September 27, 2011

Today in class we wrote a shell script to convert a decimal number into a binary number. This is very relevant to me because of the topics covered in other classes. In two of my other classes we have been driving at converting decimal to binary. I am capable of converting these numbers by hand but was not to confident about a program. One class in particular asked students to write pseudocode for this process.

This is relevant not only to this class but all classes as it bridged all of them together and showed the relevance of the material. This is especially relevant to this class because we used shell scripting and delved deeper into the syntax and how bash operates as well as learned the program bc.

September 30, 2011

As we end September, some valuable commands were learned during classes and through investigations of my own. I learned that I can copy files and directories into my home directory and sub-directories. I also started the filesystem safari project to learn more about the directories and different file types in Unix. We also did shell scripting and made bots.

This is all relevant to the course due to the learning that has taken place over the month. All things that we have learned will be built upon in the coming weeks. Without these fundamental basics, the coming weeks will most likely be even more difficult than necessary.

Topics

Home directory

The home directory is where all of your specific files and data is located. Anything that the user has created will be saved here. Everything that the user created can be accessed from here. It is the default directory you sign into.

lab46:~$ pwd
lab46:~$ /home/swilli31

Listing

This is a function that can be typed into the command prompt that will show what is located in a directory

lab46:~$ ls
lab46:~$ **Maildir** bin closet **data** public_html src src.bak

Note: The starred directories are symbolic link directories

Current Working Directory

This is the directory that you are located in. Whatever is located in that directory is accessible.

The command prompt will show what directory you are currently working in. The “~” sign after lab46: shows you are in the home directory.

lab46:~$ pwd
 /home/swilli31

This shows I'm in my home directory.

lab46:~$ cd ..
lab46:/home$ pwd
/home

This shows I'm outside my home directory.

lab46:~$ cd ..
lab46:/home$ pwd
/

This shows I'm in the / directory.

Killing a process

this is when you terminate a command using the kill command. kill -9 is the ultimate kill signal

lab46:~$ kill -1 process

Permissions

This sets the parameters for who can read, write, or execute a file or directory that has been created. The permission blocks are split into three categories: user, group, and world. Each block can be given separate permissions.

lab46~/closet$: ls -l
total 12
-rw------- 1 swilli31 lab46 117 Sep 6 16:20 cake
-rw-r--r-- 1 swilli31 lab46 73 Sep 13 15:57 limerick
-rw------- 1 swilli31 lab46 53 Sep 8 16:16 skeleton  

The -rw——- is the permission block for cake and skeleton which is readable and writable by me only. limerick has a permission block which can be read by the group and by the world but can only be written by me.

The VI Editor

This is a moded text editor. It can be used to write shell scripts and other comments and notes and the like.

lab46:~$ vi

This will take the user into the vi environment.

Regular file

A regular file is any type of file that you would expect to see. These are similar to files that maybe created in a GUI system. In the Unix environment they appear gray in color and can be read.

lab46:~$ nano cake

This will bring up another text editor to edit this file

Directory

This is another type of file that has other file located within. They are the storage places of various files and also other directories. Directories are also the work spaces the user works from. They are usually dark blue or cyan in color.

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

This demonstrates a program executed from the src directory.

Special file

These are files of things that one would not usually consider a file. They are more like things than an actual file. Special files can be yellow in color or purple. Yellow files are device files and purple files are sockets.

lab46:~$ cd /dev
lab46:/dev$

This directory contains most of the device files that are useful for exploring Unix.

Tab Completion

This is a type of shortcut to bring up files and directories or previous commands without typing the whole word. It can come in handy when you can't remember the entire name you are looking for.

lab46:~$ touch iamthewalrusandyouareallmonkeys
lab46:~$ cat iam (press TAB) thewalrusandyouareallmonkeys
lab46:~$ 

Ownership

This tells the user who wons files in that directory.

lab46:~/closet$ ls -l
total 12
-rw------- 1 swilli31 lab46 117 Sep 6 16:20 cake
-rw-r--r-- 1 swilli31 lab46 73 Sep 13 15:57 limerick
-rw------- 1 swilli31 lab46 53 Sep 8 16:16 skeleton
lab46:~/closet$ 

The third column shows that swilli31 is the owner of these files

Removing a file

If the user no longer wants to have a certain file in their directory, than can choose to remove that file. In other words, erase the file from existence.

lab46:~$ rm iamthewlrusandyouareallmonkeys
rm: remove regular empty file `iamthewalrusandyouareallmonkeys`? yes
lab46:~$ 

If you run ls again the file is no longer there.

Objectives

Objective 1

Become familiar with Unix Environment

Method

Look up manual pages in Unix environment and try some things. Read various books about Unix. Do filesystem safari project

Measurement

I followed my method and now have a better feel for the Unix environment. I can now look at information output screen and understand what they are saying more comfortably. I can also navigate commands with relative ease. It is just a matter of memory.

Analysis

I did fairly well at achieving my goal. There is still much room for improvement. I need to practice the commands a little more so that I have them committed to memory where it is all second nature.The measurement process could be enhanced by setting specifics of things that I want to become better at in the Unix environment. It would be effective to employ as I would be able to focus on something and once mastered move on the the next thing on my list to fully understand. The objective could also be altered to reflect this method by breaking the main Unix environment into smaller subsets to make it easier to understand and learn.

Experiments

Experiment 1

Question

What will happen if I input a negative number into the number conversion script we wrote in class?

Resources

A negative binary number is expressed as having a leading bit value of 1. This I learned in Computer essentials.

Hypothesis

The program will not return a value.

Rationale: The program wasn't written with negative numbers in mind.

Experiment

I will test my hypothesis by picking a negative number and entering it into the program.

Data

I input the number -42 into the script. When enter was pressed, nothing happened. I then tried -23 and got the same result. I had to use ctrl-c to exit. I then input a positive number, 33, to verify the program was still working and received an answer of 100001.

Analysis

Based on the data collected:

My hypothesis was correct. The value 100001 in binary is not necessarily a negative number as would be indicated by resources.

Conclusions

I have found that the program is only valid for a positive integer entered at the prompt. The program may be modified to calculate a negative binary number if not for the rule that there are no negative signs and therefore no negative numbers in binary. Some form of two's compliment may be integrated into script to fix this problem.

Experiment 2

Question

Will I be able to copy the games into a directory under my personal home directory?

Resources

I read the section on copying files from the book Learning the Unix Operating System.

Hypothesis

I will be able to create a symbolic link to the games in a directory in my home directory.

Rationale: I have permissions to these files

Experiment

I will test my hypothesis by using the cp -R command to copy the directory games into my home directory

Data

I was able to copy the games directory into my home directory while still maintaining the original copy in its original location under the /usr directory.

Analysis

Based on the data collected:

My hypothesis was almost correct. Instead of a symbolic link I was able to just copy the entire directory into my home directory.

Conclusions

Based on this experiment, I can conclude that, so long as I have permission, I can copy an existing file into one of my own directories. This does also include full directory trees.

Experiment 3

Question

Can you make ls list programs in chronological order?

Resources

The manual page for ls will be useful.

Hypothesis

I will be able to list programs and files chronologically.

Rationale: ls is a listing file and you should be able to say how you would like your list to be formed.

Experiment

I will look up the man page and then type the proper commands to do what I want.

Data

I first typed the ls command to get an alphabetical list of directories and files. I then looked up the man page and found the commands –sort=time and –time=atime. I tried both of these and the –time=atime provided my files in the order I most recently accessed.

Analysis

Based on the data collected:

My hypothesis was correct; I was able to list the most recently accessed or modified files. The ls program was simply taking the time and date of the long function and sorting them by that parameter.

Conclusions

This argument to ls can be very useful if looking for a file that was recently modified and you weren't sure of the name. It can also be useful in looking up something someone else on the system may have modified and you need information from that file.

Part 2

Entries

October 4, 2011

Today we went over regular expressions in class. We reviewed and played with basic regular expressions that one may encounter. I am starting to get a good feel for the regular expressions and with a little more practice, I should be fairly comfortable with using them. The biggest difficulty i can foresee with this is knowing precisely what I want to do with them but this is common for all new tools.

October 13, 2011

Today we looked a little bit at C programming. Although we do not need to know much detail about the C language, I found today's lecture quite useful. I vaguely remember doing something in C about 4 years ago for another class but had all but forgotten what I learned. The class today reawakened some of those memories and I remember, at the very least, what some of the symbols and syntax means.

October 18, 2011

Today we talke a little about wildcards and how to use them. I had read about them in in one of the books but had not played with them on my own. Today's class allowed me to see them in action. I see that they are very similar to regular expressions but with minor differences. The same basic principles applied to regular expressions can be applied to wildcards keeping in mind what symbols are used for what and when they can be used appropriatetly.

OCtober 27, 2011

Today I completed the archive handling project. It was a bit of a challenge for me due to the fact that I had not fully read beforhand anything related to archiving. Now that the project is completed, I have a little better of a grasp on archives but am not completely comfortable with them. This can be remedied by more playing and reading.

unix Topics

Regular expression

This allows for shortcuts to be taken when trying to specify what is wanted when searching for something specific in a file.

lab46:/usr/share/dict$ cat words|grep '^[aeiouy]*$'|less|wc -l
15

This shows that there are 15 words in the dictionary file that contain 0 or more of the letters enclosed in the brackets.

Copying

Copying a file is creating an exact replica of a file to another location

lab46:~$ cd /usr
lab46:/usr$ cp -R games /home/swilli31/games
lab46:/usr$

This command copied the games directory into my home directory while still preserving the games directory in the /usr directory.

Moving/Renaming

You can move a file to a diffrent location by using the move command. You can also change the name of a file without losing data by using the move command.

lab46:~$ touch script7
lab46:~$ mv script7 opus.results.sh
lab46:~$

This shows that the file script7 was renamed as opus.results.sh

lab46:~$ mv script7 bin
lab46:~$

This shows that script7 was moved to bin directory.

VI insert mode

The insert mode in vi allows the user to input text or write scripts in the vi editor.

lab46:~$ vi space ghost
~
~
~
~
~
~
~
~
~
~
INSERT

To enter insert mode press i while in command mode.

VI command mode

This mode allows for keys to be used to move the cursor quickly around the screen for easy access to quick edits to the text

~
~
~
~
~
~
~
vi space ghost

To get from insert mode to command mode press the ESC key

VI extended command mode

The extended command mode allows for the user to save and quit the vi editor

~
~
~
~
~
:q!

To enter extended command mode, press the : key. The command shown is quit without saving.

Wildcards

Another form of regular expression that is used where regular expressions aren't recognized.

lab46:~$ cd /usr/bin
lab46:~/usr/bin$ ls -d *[aeiouy]|wc -l
231

This shows that in the directory /usr/bin has 231 files that end in a,e,i,o,u, or y

Compiler

A compiler takes a program and formats it to be read in machine language and can also make a C program executable in bash.

lab46:~$ cd bin
lab46:~/bin$ gcc -o culpepper command.c
lab46:~/bin$ culpepper
culpepper was called with 1 arguments
argv[0]: culpepper
lab46:~/bin$ 

C

lower level Programming language

#include <stdio.h>
 
int main(int argc, char **argv)
{
    int i
    printf(" %s was called with %d arguments\n," argv[0], argc)
    for (i=1; i<argc; i++)
    {
         printf("argv[%d]: %s\n", i, argv[i]);
    }    
    return(0);
}

This is a C program code.

Creating a file

This is simply making a file and bringing it into existance. This can be done using any text editor of choice or simply by they touch command

lab46:~$ touch robot chicken
lab46:~$ ls
lab46:~$ robot chicken space ghost futurama

The file robot chicken was created and was added in the directory with the other files space ghost and futurama.

Archiving/Unarchiving a file

This is a form of compression. Most commonly a tape archive,tar, is used.

lab46:~$ tar -cf archive6.tar futurama
lab46:~$

The archive archive6 was created as a tar file.

Compressing/decompressing a file

This takes a tar file or a zip file and streches it out so that it can be read.

lab46:~$ tar -jcvf archive9.tar.bz2 american horror story
american horror story
lab46:~$ ls
archive6.tar archive9.tar.bz2

The archive9.tar.bz2 was compressed by tar and then compressed to bzip2 format containg the file american horror story.

unix Objective

Objective

Become comfortable with the vi editor

Method

To obtain this objective I will read some material on the vi editor and practice writing scripts

Measurement

After much reading and familiarizing, I am finally able to comfortably write scripts.

Analysis

The vi editor is a useful tool to know and use. Although it is not the only text editor available, it has commands and options that make learning unix easier. My method seems to have been effective due to the fact that I have started dreaming about writing scripts using vi while I slumber.

Experiments

Experiment 1

Question

Can bash handle a multiplication function using decimal and change that number into binary?

Resources

The resources used for this experiment came from other class' notes taken and my previous knowledge about bash. I also tried to combine two scripts previously written

Hypothesis

I will be able to take a number gathered from multiplication.sh and pipe it to script5.

Rationale: The groundwork has been laid it just needs to be written.

Experiment

I will test my hypothesis by writing the new script and running it. The numbers should then be binary

Data

The code is written in binarymultiply.sh. The final output on the screen is below.

lab46:~$ binarymultiply.sh
Please enter multiplicand:5789
Please enter multiplier:22
The product is 127358
The binary value is 11111000101111110
lab46:~$

Analysis

My hypothesis was correct although I could not do it the way I thought I could. I had figured that I could cat in one program to another but because no actual values are stored in either program this created an empty function. The way I fixed this was to set the variable number equal to the product taken from the multiplication and then proceeded to run through the conversion script. It still has the same issues as before in which it doesn't work once the number becomes to large and it no longer out puts to binary.

Conclusions

Based on this experiment there are still some bugs that need to be fixed in converting large numbers into binary as well as multiplying by negative numbers and taking that negative number into a binary value.

Experiment 2

Question

Can I create a dual operating system on my computer with windows and linux?

Resources

I will follow instructions from computer essentials class to download ubuntu and then go from there to create dual OS system.

Hypothesis

I can run my computer with both windows and ubuntu Rationale: The hard drive can be partitioned to handle a dual OS

Experiment

I will test by installing Ubuntu first on a flash drive and then installing to my computer

Data

After a long installation time, I was able to create a dual operating system on my computer. Upon the start I can choose whether or not I wan to run the Windows OS or the Ubuntu OS. The one downside is that files are not shared between the two operating systems.

Analysis

Based on the data collected: My hypothesis was correct but not necessarily applicable. I was able to create a dual OS system but I could also just as easily have overwritten the Windows OS and used Ubuntu solely on its own. A better experiment would be to see if I can transfer files from one OS to another automatically.

Conclusions

I didn't really make any new discoveries nor did I achieve a groundbreaking experiment. I was able to do what I set out to do but not much more than that.

Experiment 3

Does a child process die when the parent is killed?

Resources

This is a look at killing processes and possibly the creation of zombies on the system. The code being used in this experiment was found on http://snippets.dzone.com/posts/show/6233

I also referenced a unix forum on the following website: http://www.unix.com/unix-dummies-questions-answers/100737-how-do-you-create-zombie-process.html

Hypothesis

If the parent process dies, the child will not die with it and become a zombie.

Experiment

I will take the code from the above mentioned website and run it. I will then run the top command to see if there are any zombies in the system

Data

I did not use the code provided on the first resource sit and instead followed the example on the unix forum.

Analysis

I did not follow the experiment the exact was as planned but I was not able to run the check process to see if it actually created a zombie. I did run the top command and there are no zombies reported on the system so my assumption is that I did not successfully create a zombie.

Conclusions

My hypothesis was never tested because I did not create a zombie in the system. If I had a more proven way to create a zombie so that I can at least understand how they work then I may have more to conclude.

Part 3

Entries

November 3, 2011

Today was an interesting class. We played with regular expressions and dewebified an html document. Simply put, we were data mining a a web page from its html format to a format that was much easier to read and understand. We took the information gathered and also rearranged it to the format we would have preferred to see it in. This was good as it was more play with regular expressions as well as unzipping a gzipped archive. This is very useful as a future refernce to a problem that may be encountered.

November 15, 2011

Today we looked at IP addressing in Unix. This was a great tie-in to all the IP configuration that I just finished learning about in Network Fundamentals. I see that it is all the same thing just under a different name and settings.

Novemeber 17, 2011

Today I worked on the webpage project. I have never worked with html before so I had to look up how to actually write the code. I will say that it is not as difficult as it may seem but at the same time it is a bit of a challenge. I am still struggling with the images but in time I should be able to get it worked out.

November 30, 2011

Today is the last day for the Opus Part 3. I haven't been working on it as studiously as the other parts. It's getting down to the end of the semester and the class is winding down. I think I am more in shock over how fast the semester flew by and the fact that all that is left is the end of course experience.

unix Topics

Links are special files that share resources and direct the user to another location where other types of files may be located. In Unix they are typically symbolic links.

lab46:~$ ls
lab46:~$ **Maildir** bin closet **data** public_html src src.bak

Note: The starred directories are symbolic link directories

The Maildir and data directories provide links to files located in other directories in the Unix system. The lib directory in Unix is also a link that provides access to other files.

Multitasking

Multitasking is the process of working on or accomplishing more than one task at one time.

lab46:~$ ps

This command will show the user all the processes they are running

Pattern Matching

Finding a similarity in a file and using tools such as grep and sed to find the pattern that is specified. it is a quick way to find all the needed information in a large file when only a tiny fraction is needed and also trim off the excess.

lab46:~$ cat spring2012-20111103.html|sed 's/ddtitle/dddefault/g'|grep 'dddefault'

This snippet of code is looking for the patterns of ddtitle and dddefault in the file spring2012-20111103.html. Both sed and grep are searching for and will match the given patterns so that only the lines containing them will be given.

Backgrounding a Process

Taking a process and running it in the background while working on something else.

lab46:~$ sort bigfile > bigfile.sort &
[1] 29890
lab46:~$

The ampersand, &, places the process in the background to free up the terminal

Foregrounding a process

Taking a process that is in the background and bringing it to the front, foreground, so that you can actively work on it.

lab46:~$ sort bigfile > bigfile.sort fg
lab46:~$

This brings the previously backgrounded process to the foreground

Signals

The electronic impulse that lets the system know a process has been done or is being done.

lab46:~$ kill -9 54896

The above shows that the process 54896 is being sent a kill signal.

Local Host

The computer that you are currently using. It can be reached by using the loopback.

lab46:~$ ping 127.0.0.1

This contacts the local host to make sure it is sending and receiving packets properly.

Remote Host

A computer that is a distance away from the computer being used to access it.

A x-window system works somewhat like a remote host. When we used the video wall in class that was a remote host.

X Window System

Similar to unix and utilizes a graphical interface. It allows for processes to be run and is also capable of multitasking.

gazelle: xeyes

This is a command prompt in the x window system that will output a pair of eyes to the screen.

Extended Regular Expressions

An extension to regular expressions that allows more pattern matching and grouping

lab46:/usr/share/dict$ cat words|grep '^[aeiouy]|[731089]$'

This should look for words that contain the vowels OR the numbers indicated. The | is an extended regular expression meaning or.

Shell Scripting

writing a program that will execute within the unix environment

#!/bin/bash
echo "please enter password: "
done

this is a script that should prompt the user to enter a password.

$Path

Shows the absolute path that something will take while traversing unix.

lab46:~$ echo $PATH
/home/swilli31/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

unix Objective

Objective

Understanding and implementing pattern matching

Method

Read books and follow html example from class. Try to do some matching on my own. Use grep and sed to obtain information I am looking for.

Measurement

I was able to match some patterns but I need to work more on grep, sed, and regular expressions

Analysis

The class example was a good jumping off point to learn pattern matching. It had many entries that could easily be narrowed down to what was most important. I am now able to recognize patterns when given a a file but I still need to work more with using grep and sed to become more comfortable with using them.

Experiments

Experiment 1

Question

Can I create an x-window client from within the Unix shell

Resources

Using knowledge from class and some reading

Hypothesis

I will not be able to create an x-window host from within Unix

Rationale: We used a separate terminal from the drop menu to get an x-window client

Experiment

Find a command that can create x-window within unix and execute

Data

I tried to use the command DISPLAY=unix/ :0.0 ./test nad the ./test command which should have at least brought up a netstat page for x-window but instead nothing cam up. When I tried lsof I got a bunch of permission denied for various users.

Analysis

There was no manual page for x-window. I was not able to do what I wanted.

Conclusions

While I was not able to create an x-window from within the unix shell but I also do not think that this failed experiment can count as proving my hypothesis correct due to the lack of proper information.

Experiment 2

Question

How can I redirect STDOUT and STDERR?

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

If you're doing an experiment instead of a retest, delete this section.

If you've opted to test the experiment of someone else, delete the experiment section and steps above; perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Prove 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).
opus/fall2011/swilli31/start.txt · Last modified: 2014/01/19 09:20 by 127.0.0.1