Table of Contents

Shane's C/C++ and Unix Spring 2012 Opus

Introduction

Hello!

My name is Shane Kinney. I am 33 years old with a full family and full time job. I attend classes from the comfort of my couch and really miss the in class experience. I highly enjoy all aspects of computers and have them as my main hobby. I am also really into music. I play drums and have a Yamaha Ryden kit. Mostly, i focus on guitar. I just recently acquired a Fender Telecaster. She is beautiful and has the new pickups that allow you to get a wide range of sounds.

Thanks for taking the time to read my page.

Part 1

Entries

Entry 1: February 25, 2012

UNIX

It is amazing to think about the amount of specialized systems out there that are actually UNIX based. My old perception was the Windows runs the world when in all actuality they only have the PC OS market. The systems that actually control most everything is UNIX. For example, UNIX sends the space shuttle into orbit, communicates with satellites, runs our database systems and processes your bank requests. Fun to have that reality open your eyes to the importance of knowing how to have fun on a command line.

C/C++

I have found that learning a language is more application then it is reading. I felt for a while that until i read it all and new what all was there that actually sitting down to right code was impossible. How do you paint a picture without know what colors you have, or how can you build anything without have an idea of the materials needed. This logic still holds true but really, it is the application that sticks it into my memory so it can be used in the next “painting”. The shift project was not something that did not make sense… it was just really the grey area of how the computer would actual shift the information with the commands that are needed.

Entry 2: February 27, 2012

C/C++

For me the hardest part about getting your first language under your skin using it. I have read, watched and studied so much material… but until i get to sit down and just right code… and more code. I am not sure who well i am coming along. I grab code to look at and can tell that i understand more of it. The nice part is that i am almost done with a few of the resources i have found. I seem to think that completing them will at least let me know where the walls are so i can start framing things in.

UNIX

Stopped at Barnes & Nobles for a coffee and ad quick flip through the newest 2600. When i got to the rack, coffee in hand… priorities ya know, I was amazed at the amount of Linux based magazines could be found. The now have an Ubuntu magazine that give a walk through on what is new with a live install CD in the back. Another magazine going into detail on four Linux developments along with live installs. i looked further to many Mac/Unix flavors.

I noticed others has made a map of their home director and thought I would add this to my post…. I need to do some cleaning.

Definition



Lab46:/$
   |
 Home
   |
skinney1
   |
lab46:~%
   |                      
Maildir - archives - bin - devel - file - phenny - shell  - src  -  public_html
   |         |        |      |      |        |       |       |           |
   /         |        |      |      |        |       |       |           |
   cur              dovecot-uidvalidity           dovecot.index.cache  new
   dovecot-uidlist  dovecot-uidvalidity.4f20b790  dovecot.index.log    tmp
             |        |      |      |        |       |       |           |
             /        |      |      |        |       |       |           |
             arc.tar  def.text  dir1  filea  fileb.gz  filec.gz  filez
                      |      |      |        |       |       |           |  
                      /      |      |        |       |       |           | 
                       e login ping tcsh zsh  gz24043  mod ps touch
                             |      |        |       |       |           |
                             /      |        |       |       |           |
                             a.out       hC.out    helloASM.S   helloJAVA.class  ltypes.c.save
                             dtypes.c    hCPP.out  helloC.c     helloJAVA.java   ltypes.c.save.1
                             dtypes.out  hello     helloC.s     link.sh          ltypes.out
                             hASM.o      hello.o   helloCPP.cc  ltypes.c         multifile
                                    |        |       |       |           |
                                    /        |       |       |           |
                                    abcd.txt  file.txt  submit                             
                                             |       |       |           | 
                                             /       |       |           |
                                              README.txt    bot.py   icao.pyc  modules  project    web.py
                                              __init__.py   bot.pyc  irc.py    opt      tools.py   web.pyc
                                              __init__.pyc  icao.py  irc.pyc   phenny   tools.pyc
                                                     |       |           |
                                                     /       |           |
                                                    file   file1234  file3  file41   fileZZZ  wc
                                                    file1  file2     file4  file555  filea
                                                             |           |
                                                             /           | 
                                                             cprog  helloC.c  submit  unix
                                                                         |
                                                                         /
                                                                         Empty

Entry 3: March 3, 2012

UNIX

just realized that the opus has a section for each month… so more work to do then I thought. Hope i can recover from my oversight. Having fun messing with the bash scripting… but the actual use of some of the commands are a pain. Trying thing 50 different ways… so i am also learning to research more vs. hacking things correct.

Entry 4: March 3.5, 2012

UNIX

Finished up this weeks assignment. The lab was tough stuff, more so the last script. I actually could not believe that i was able to do the first one. I did have issues with the getting the bash script to save the file vs prompting the used to hit ^d. i attempted the terminator “;” and the done call out. Google was not my friend on this one ether. I ended up leaving the script a bit messy, but it did do the desired act.

C++

Working on catching up the opus for the class. I have been watching videos from wibit.net this week and making note cards along with practicing writing.

Keywords

cprog Keywords

The following is a list of the major topics being covered in this course:

  1. Standard I/O (STDIO, STDOUT, STDERR) (done)
  2. Header Files (Local and System), C Standard Library (Libc), Libraries (done)
  3. arithmetic (equations, operators) (done)
  4. logic and operators (and, or, not, xor) (done)
  5. Variables (types, ranges, sizes) (done)
  6. Scope (Block, Local, Global, File)
  7. Pointers (address of, assignment, dereferencing)(done)
  8. Type Casting (done)

cprog Keyword 1

Standard I/O

Definition

Standard I/O covers a the broad range of standard input, standard output and standard error. With a Standard I/O all data is treated and read the same way without having to compile sources of data. STDIO is what is typed or fed to the machine. For example, you enter a command at the prompt and run the program. Another example, the standard allows the flexibility of shell scripting to be entered and treated the same as input from the keyboard. The standard format is what gives the system flexibility.

The two general ways to print or output data are Standard Output (STDOUT) and Standard Error (STDERR). The result of STDIO is that once data is entered it is then output (STDOUT) to the screen or file. Simple in meaning; however, there are many ways to direct the output depending on your needs. The last output form is the error handling STDIN. This sub group allows standard message and handling of errors that are imputed to the terminal.

Demonstration

An example of standard error output is shown bellow. Here a program was written to add two numbers. The compiler has gone through and looked at the code and then presented this output to the console. Giving the results of incompatibility within the written structure.

lab46:~/junk$ gcc dem1.c -o dem1.out
dem1.c:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
dem1.c:11: error: stray '\' in program

cprog Keyword 2

Header Files (Local and System), C Standard Library (Libc), Libraries

Definition

Header files contain functions that can be used within the program. Each header file is called out in the following manner within the code.

#include <stdio.h>
#include <math.h>
Demonstration

There are many macros, functions and variables that are included in header files. The following example is a list of what is the stdio.h header file.

Macros:

NULL _IOFBF _IOLBF _IONBF BUFSIZ EOF FOPEN_MAX FILENAME_MAX L_tmpnam SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr stdin stdout

Functions:

clearerr(); fclose(); feof(); ferror(); fflush(); fgetpos(); fopen(); fread(); freopen(); fseek(); fsetpos(); ftell(); fwrite(); remove(); rename(); rewind(); setbuf(); setvbuf(); tmpfile(); tmpnam(); fprintf(); fscanf(); printf(); scanf(); sprintf(); sscanf(); vfprintf(); vprintf(); vsprintf(); fgetc(); fgets(); fputc(); fputs(); getc(); getchar(); gets(); putc(); putchar(); puts(); ungetc(); perror();

Variables:

typedef size_t typedef FILE typedef fpos_t

Header files start with a Copyright declaration of the GNU license.

/* Define ISO C stdio on top of C++ iostreams.
   Copyright (C) 1991, 1994-2007, 2008, 2009 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

This example is a declaration of the if statement syntax and usage from stdio.h

#if (defined __USE_POSIX2 || defined __USE_SVID  || defined __USE_BSD || \
     defined __USE_MISC)
/* Create a new stream connected to a pipe running the given command.

   This function is a possible cancellation point and therefore not
   marked with __THROW.  */
extern FILE *popen (__const char *__command, __const char *__modes) __wur;

/* Close a stream opened by popen and return the status of its child.

   This function is a possible cancellation point and therefore not
   marked with __THROW.  */
extern int pclose (FILE *__stream);
#endif

cprog Keyword 3

Arithmetic (equations, operators)

Definition

There are many simple statements and functions in C that allow for easy use of arithmetic. The C environment uses the math.h header file to present the additional functions needed.

Math Functions

acos(); asin(); atan(); atan2(); ceil(); cos(); cosh(); exp(); fabs(); floor(); fmod(); frexp(); ldexp(); log(); log10(); modf(); pow(); sin(); sinh(); sqrt(); tan(); tanh();

Demonstration

This is an exercise in using basic math functions comparing values. There are many more called out in the <math.h> file. For example, the trig functions of sin(x), cos(x) and tan(x).

#include <stdio.h>
#include <math.h>
 
int main()
{
 
        int a = 2 == 2;
        int b = 2 != 3;
        int c = 4 < 5;
        int d = 4 > 9;
        int e = 3 >= 3;
        int x = 11;
        int y = 33;
//basic math statements
       printf("basic math expressions\n");
       printf("%d\n", x - y);
       printf("%d\n", x + y);
       printf("%d\n", x * y);
       printf("%d\n", y / x);
       printf("%d\n", (x*y)/2);
       printf("%d\n", ((y-x)/20)*100);
 
 
//compare represetned vaule
        printf("compare held values\n");
        printf("%d\n", a);
        printf("%d\n", b);
        printf("%d\n", c);
        printf("%d\n", d);
        printf("%d\n", e);
        return 0;
}
basic math expressions
-22
44
363
3
181
100
compare held values
1
1
1
0
1

cprog Keyword 4

Logic and Operators (and, or, not, xor)

Definition

A Logical Operators are symbols that are used to do some level of logic check within a statement. They can tie together the results of several comparison expressions into one logical expression. There are many different types of operators that meet the needs of many situations.

List of different operators

  1. Unary Operators
  2. Prefix Incrementation Operators
  3. Address Operators
  4. Shift Operators
  5. Relational Operators
  6. Equality Operators
  7. Bitwise AND Operators
  8. Bitwise Exclusive OR Operators
  9. Bitwise Inclusive OR Operators
  10. Logical AND Operators
  11. Logical OR Operators
  12. Conditional Operators
  13. Assignemnt Expresssion Operators
  14. Comma Operator
  15. Constant Expression Operators

The Logical Operators for and, or, not, and xor are very common (and a part of this assignment).

  • The and operator is &&.

This double ampersand is used to put two comparisons together.

  • The or operator is ||.

The double pipes are use to represent one or the other.

  • The not operator is !.

The exclamation point represents the not operator.

  • The xnor operator is

The xnor is a symbolic constant that represents not.

Demonstration

The Following code shows and example of the Operators in action.

int main()
{
 
        int a = 2;
        int b = 3;
        int c = 4;
        int d = 5;
 
//comparision operators
        printf("compare held values\n");
        if (a != 0)
          {
           printf("the value is not equal to zero %d\n", a );
          }
        if ((b > c) || (a > d))
          {
          printf("b and a are less then d. the values are %d %d\n ", b,a);
          }
        if ((a && b && c) < 2)
          {
         printf("vaule for a, b and c are larger then 2\n");
          }
        return 0;
}

The code results in the following

compare held values
the vaule is not equal to zero 2
vaule for a, b and c are larger then 2

cprog Keyword 5

Variables (types, ranges, sizes)

Definition

A variable is a type of declaration and a place holder for a value. For example you declare a variable with the declarations section of your code. Another word for a variable is an object and refers to a location and name of a point in storage. The attributes of the variable is determined but its storage class and type. The value limits are held in limits.h There are four basic types of declared variables the int, char, float, and double types.

  1. The int type can hold a whole number up to 32 bits or one machine word.
  2. The char type typically has the size of one bit
  3. The float type or floating point can store one machine word as a real number
  4. the double type is like a float type but it allows you to store real numbers larger then float.

Variable floats are used when you set a vault to a floating amount that will be used and changed by the program. This example is a simple one, using the float within the main part of the program. Other times the float is used on a global level within the program.

Demonstration

The following is an example or int and char variables.

int main()
{
 
        int bowl = 324;
        char cup = 'a';
 
       printf("a char hold one char such as the letter %d\n", cup);
       printf("int can hold full value such as %d\n", bowl);
        return 0;
}

The code output is as follows

lab46:~/junk$ ./dem4.out
a char hold one char such as the letter 97
int can hold full value such as 324

The following is an example of a variable float

#include <stdio.h>
int main()
{
        float num = 9.87;
 
        printf("the number \"num\" is %.2f\n", num);
        return 0;
}

The output for the variable float example

lab46:~/src/cprog/project$ ./example9.out
the number "num" is 9.87

cprog Keyword 6

Scope (Block, Local, Global, File)

Definition

The scope within a program is the boundaries or references that assign and determine use of variables within it's borders. There are different levels of scope within the program that determine what level of declaration the code can be utilized at.

Block scope, a higher level of function scoping, gives variables the ability to be focused only on part of a function.

The term local refers to the declaration being available within the direct code, or within “{ }”.

The Global level sets the declaration above the codes local level and is used by all areas of the code. When you int a variable you typically declare it at the global level.

A file declaration is something that is used outside a block that can be used very much like the global level declaration.

Demonstration

This is an example that was given for char types.

#include <stdio.h> //FILE
#include <math.h>
 
int main() //GLOBAL 
{
    // LOCAL 
 
    unsigned long long int quantity = 0;
    unsigned char uc = 0;
    signed char sc = 0;
 
    printf("An unsigned char is %d bytes\n", sizeof(uc));
 
    printf("The range of an unsigned char is %hhu to %hhu\n", uc, (uc-1));
    quantity = (unsigned char)(uc-1) + 1;
 
    printf("An unsigned char can store %llu unique values\n\n", quantity);
 
    printf("A signed char is %d bytes\n", sizeof(sc));
    quantity = (unsigned long long int)pow(2, (sizeof(sc)*8));
 
    printf("The range of a signed char is %hhd to %hhd\n", (sc-(quantity/2)), (sc+(quantity/2)-1));
 
    printf("A signed char can store %llu unique values\n\n", quantity);
 
    return(0);
}
lab46:~/src/cprog/classproject$ ./var.out
An unsigned char is 1 bytes
The range of an unsigned char is 0 to 255
An unsigned char can store 256 unique values

A signed char is 1 bytes
The range of a signed char is -128 to 127
A signed char can store 256 unique values

cprog Keyword 7

Pointers (address of, assignment, dereferencing)

Definition

Pointers are values that are declared and referred to from within the program. In the following program I have used a simple int of two values. The values are then assigned a meaning and used within the program. The prinf function then calls on these pointers to output the assigned value.

Demonstration
#include<stdio.h>
int main()
{
        int x, y;
        x = 256;
        y = 23;
        {
        printf("%d \n", x);
        printf("%d \n", y);
        }
return(0);
}
lab46:~/src/cprog/classproject$ ./char.out
256
23

cprog Keyword 8

Type Casting

Definition

Type Casting is converting a variable of one type act like another type. For example making the int variable act like a char.

Demonstration
#include<stdio.h>
 
int main()
{
       int a=3,b=9;
        float c = 0, d = 0;
 
        c = b/a;
        printf("\n [%f] \n", c);
 
        d = (float)b/(float)a;
        printf("n\ [%f] \n", d);
return(0);
}
lab46:~/src/cprog/classproject$ ./typec.out
 [3.000000]
n [3.000000]

cprog Objective

cprog Objective

Right a script that will log and store all users on the server.

Definition

Logging users IP and account information

Method

Use nano and gcc to to compile the script

Measurement

The script successfully runs and appends to a file.

Analysis

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

  • How did you do? Not bad, i learned to use C to call out UNIX commands but it really is just as simpler to write the script on the command line. In this case this showed no real efficiency improvement.
  • Is there room for improvement? The arguments that are allowed are not talked about in the man pages
  • Could the measurement process be enhanced to be more effective? no
  • Do you think this enhancement would be efficient to employ? no
  • Could the course objective be altered to be more applicable? How would you alter it? use it to run a few more commands. For example doing some level of clean up or set up of a project file.

unix Keywords

  1. Local host(done)
  2. Remote host(done)
  3. Home directory(done)
  4. Current working directory(done)
  5. Types of files (regular, directory, special)(done)
  6. File manipulation(done)
  7. Text Processing(done)
  8. The VI editor(done)

unix Keyword 1

Local Host

Definition

The local Host is standard host name referring to the reserved domain or address. It typically speaks to the name of the computer or larger web of networked computers that the user is on. For example the IPv4 address on the net work, 127.0.0.0

Demonstration
lab46:~/src/cprog/classproject$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3e:5d:88:d8
          inet addr:10.80.2.38  Bcast:10.80.2.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe5d:88d8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:40022164 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46989201 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7764390567 (7.2 GiB)  TX bytes:24326549986 (22.6 GiB)
          Interrupt:18

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:341910 errors:0 dropped:0 overruns:0 frame:0
          TX packets:341910 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:44926915 (42.8 MiB)  TX bytes:44926915 (42.8 MiB)

unix Keyword 2

Remote Host

Definition

A remote host is another computer at another location. It is typically a server on a private or public internet location. There are many ways to access a remote host. One way i use at work is the Remote Desktop Connection (run⇒ mstsc). From here you just need your host address of the computer in the network… and a valid login. This allows me to access the three workstations in my area and monitor their behavior from one desk. Another method is to use a SSH (secure Shell), such as Putty.

Demonstration

having a keygen file generated for your ssh connection

lab46:~$ sshe-keygen -t dsa
-bash: sshe-keygen: command not found
lab46:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/skinney1/.ssh/id_dsa): 1
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Passphrases do not match.  Try again.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in 1.
Your public key has been saved in 1.pub.
The key fingerprint is:
b9:73:c8:83:18:c8:57:a7:52:2a:d3:33:02:64:5d:06 skinney1@lab46
The key's randomart image is:
+--[ DSA 1024]----+
| o.Eoo           |
|o  ..            |
|.     o .        |
| o o + o .       |
|  * O . S        |
|   = * o o       |
|    . . * .      |
|         +       |
|                 |
+-----------------+

unix Keyword 3

Home Directory

Definition

A home directory is a system of files that is set up on a host for multi-user operating. It allows users to have their own home… or book shelf for their work and files.

Demonstration

On the Lab46 home directory there are many files set up each with read a write permission given only to the owner.

lab46:/home$ ls
ab000126   bwilson3  ds003420    jburlin1  jwood36   mpaul6      sclayton
abranne1   cacquah   dschoeff    jc006215  jzimmer5  mpresto4    sedward9
abrunda1   cas21     dshadeck    jcardina  kamakazi  mshort3     sjankows
acanfie1   caustin8  dsherbur    jcavalu3  kbell1    mtaft4      sjelliso
acarpen5   ccaccia   dshreve     jcosgro4  kboe      mwagner3    skinney1
acrocker   ccarpe10  dstorm3     jdavis34  kc017344  mwarne11    smacombe
adexter    cchandan  dtalvi      jdawson2  kcard2    mwitter3    smalik2
adilaur1   ccranda2  dtaylo15    jdrew     kcaton    nandre      smatusic
aettenb3   cderick   dtennent    jeisele   kcook6    nbaird      smclaug3
afassett   cdewert   dtravis4    jellis15  kcornel6  nblancha    smd15
agardin4   cforman   dwalrat1    jferrito  kdenson   ngraham2    smilfor3
ahazen     cgoodwin  dwells6     jfrail    kgarrah1  nrounds     spetka
ajernig2   ckelce    dwrigh18    jfurter2  kgaylord  nsano       spline
ajoensen   ckuehner  eberdani    jh001093  kinney    nsr1        squires
akundlas   clawren2  efarley     jhall40   kkrauss1  nvergaso    squirrel
alius      cmace1    egarner     jhammo13  klynch3   nwebb       srk3

unix Keyword 4

Current Working Directory

Definition

The current working directory is the directory of the hierarchical file system. Within you current working directory process and programs that are run default to using that space. Much like doing work at your desk. Anything you do goes onto your current workspace, unless effort is done to move the work to another area.

Demonstration

pwd lists your current working directory

lab46:~$ pwd
/home/skinney1

ls list the contents of your current working directory

lab46:~$ ls
*      Maildir   badname  cutcprog  lastexamp       public_html  temp
1      WELCOME   bin      devel     output          shell        yb452.zip
1.pub  YB452     count    file      phenny          src
123    archives  count.c  junk      phenny.tar.bz2  src.bak
lab46:~$

unix Keyword 5

Types of files (regular, directory, special)

Definition

In a Windows the OS knows from the tag at the end of the file what its' type is. It also know what program is required to use that file. UNIX is like this in many ways however it allows a little more freedom with the regular file type. Some sources stat that UNIX does not really have a specific file type. You can make a file extension what ever you want. In some cases you have a special file type like with gcc. Where you need a .out name of the file to be run correctly. for example, If we named all text files as .txt, then we would would be our standard file type. There are special types of files when you look as special devices, like gcc. The directory files types are really just lists of what is in the file. Like a log of accessible content.

Demonstration

Ls showing the file types in my junk drawer

lab46:~/junk$ ls -l
total 96
-rw-r--r-- 1 skinney1 lab46   128 Mar 14 12:15 dem1.c
-rwxr-xr-x 1 skinney1 lab46  6570 Mar 14 12:15 dem1.out
-rw-r--r-- 1 skinney1 lab46   699 Mar 14 12:44 dem2.c
-rwxr-xr-x 1 skinney1 lab46  7092 Mar 14 12:44 dem2.out
-rw-r--r-- 1 skinney1 lab46   553 Mar 14 22:49 dem3.c
-rwxr-xr-x 1 skinney1 lab46  6964 Mar 14 23:29 dem3.out
-rw-r--r-- 1 skinney1 lab46   259 Mar 14 23:30 dem4.c
-rwxr-xr-x 1 skinney1 lab46  6666 Mar 14 23:30 dem4.out
-rw-r--r-- 1 skinney1 lab46 11221 Mar 14 12:49 distributed in the hope that it will be useful,
-rw-r--r-- 1 skinney1 lab46 11221 Mar 14 12:49 file is part of the GNU C Library.
-rw-r--r-- 1 skinney1 lab46 11221 Mar 14 12:49 free software
-rw-r--r-- 1 skinney1 lab46 11221 Mar 14 12:49 seLeneral Public License for more details.

unix Keyword 6

File manipulation

Definition

File manipulation in Unix is just like with any other OS, they just have a few extra buttons to try out. For example the “tac” command has the ability to print the file in the reverse order, not sure why anyone would want to but nice to have the option. Another example is the “rev” command. This command prints every character in reverse order. The last example is the paste command. This will paste the contents of files that you want to merge to the screen. These are just fun examples but there are many more.

  1. fileExists – whether a file exists
  2. isRegularFile – whether a file is a regular file
  3. isDirectory – whether a file is a directory
  4. fileTime – get or set file modified time
  5. copyFile, see copyFile(String,String)
  6. moveFile, see moveFile(String,String)
  7. removeFile – remove a file
  8. findFiles – find files recursively
  9. symlinkFile – make a symbolic link to a file
  10. linkFile, see linkFile(String,String) – make a new link to a file
  11. readlink – readlink fn
  12. mkdir
  13. makeDirectory, see makeDirectory(String) – make a directory
  14. copyDirectory, see copyDirectory(String,String)
  15. removeDirectory – remove a directory
  16. symlinkDirectory, see symlinkDirectory(String,String) – make symbolic links for all files in a directory tree
  17. readDirectory – read the contents of a directory
  18. realpath – convert a filename to one passing through no symbolic links
  19. temporaryFileName – make a temporary file name
Demonstration

Tac command example

 lab46:~/junk$ tac dem1.c
}
  return (0);
  }
  printf("%d\n", x + y);
  {

  int y = 12;
  int x = 24;
{
int main()

#include<math.h>
#include<stdio.h>
lab46:~/junk$

rev command example

lab46:~/junk$ rev dem1.c
>h.oidts<edulcni#
>h.htam<edulcni#

)(niam tni
 {
;42 = x tni
;21 = y tni

{
;)y + x ,"n\d%"(ftnirp
}
;)0( nruter
}
lab46:~/junk$

Paste command example

lab46:~/junk$ paste dem1.c dem3.c dem2.c
#include<stdio.h>       #include <stdio.h>      #include <stdio.h>
#include<math.h>        #include <math.h>       #include <math.h>

int main()      int main()      int main()
{       {       {
  int x = 24;
  int y = 12;           int a = 2;              int a = 2 == 2;
                int b = 3;              int b = 2 != 3;
  {             int c = 4;              int c = 4 < 5;
  printf("%d\n", x + y);                int d = 5;              int d = 4 > 9;
  }                     int e = 3 >= 3;
  return (0);   //comparision operators         int x = 11;
}               printf("compare held values\n");                int y = 33;
                if (a != 0)     //basic math statements
                  {            printf("basic math expressions\n");
                   printf("the vaule is not equal to zero %d\n", a );          printf("%d\n", x - y);
                  }            printf("%d\n", x + y);
                if ((b > c) || (a > d))        printf("%d\n", x * y);
                  {            printf("%d\n", y / x);
                  printf("b and a are less then d. the values are %d %d\n ", b,a);             printf("%d\n", (x*y)/2);
                  }            printf("%d\n", ((y-x)/20)*100);
                if ((a && b && c) < 2)
                  {
                 printf("vaule for a, b and c are larger then 2\n");    //compare represetned vaule
                  }                     printf("compare held values\n");
                return 0;               printf("%d\n", a);
        }               printf("%d\n", b);
                        printf("%d\n", c);
                        printf("%d\n", d);
                        printf("%d\n", e);
                        return 0;
                }

lab46:~/junk$

unix Keyword 7

Text Processing

Definition

UNIX is a very powerful word processing tool that's history is being used in universities and development. The utilities are really and endless list that can help with doing everything you might needed done. Within class we use many of the commands like, cat to quickly present the contents of a file. Grep is another good example. This command can search a target file for a pattern and present the information.

Demonstration

Cat command example

lab46:~/junk$ cat dem1.c
#include<stdio.h>
#include<math.h>

int main()
{
  int x = 24;
  int y = 12;

  {
  printf("%d\n", x + y);
  }
  return (0);
}
lab46:~/junk$

Grep command example searching for the word main in the file called dem1.c.

lab46:~/junk$ grep 'main' dem1.c
int main()

unix Keyword 8

The VI editor

Definition

VI is a screen based text editor that has many tools for programmers. The popularity of the program is as old as linux and is shipped standard on most distributions. VI is noted to taking some time to get accustomed to it's features and benefits. Most people coming from the Microsoft style of text editing find the key based commands difficult at first. The program was written to be independent of a mouse, something that was not around when it was first developed. Thus the program has two modes, the command and insertion mode.

Demonstration

Screen shot of the opening

~
~                              VIM - Vi IMproved
~
~                               version 7.2.445
~                           by Bram Moolenaar et al.
~           Modified by pkg-vim-maintainers@lists.alioth.debian.org
~                 Vim is open source and freely distributable
~
~                        Become a registered Vim user!
~                type  :help register<Enter>   for information
~
~                type  :q<Enter>               to exit
~                type  :help<Enter>  or  <F1>  for on-line help
~                type  :help version7<Enter>   for version info

Working with a program

lab46:~$ view
#include<stdio.h>
intmain()
{




printf("vi is cool");
return(0)
}
:q!

unix Objective

Unix Objective

vs.

Definition

Explore the benefits and experience the two main GUIs' that are available for the Linux Desktop.

Method

Research and report the differences and benefits of both Desktops.

Install and use both Gnome and KDE. perform the following, then rate on a scale from 1 to 10 and report on issues or seen benefits.

  1. Connect to the internet
  2. Make a DVD play
  3. Make an .avi file play
  4. Install a game
  5. Use it for a few days as your normal computer
Measurement

Research _

1) Gnome

History

The official name is the “GNOME Project”. It was started in 1997 by Miguel se lcaza and Federico Mena. GNOME was started because at that time KDE was the for runner; however, it ran on proprietary software for its Qt widget toolkit. In 2000 the GNOME Foundation was established to facilitate administration tasks, supporter development and other not directly technical aspects. The community of supporters is no small amount. They hold a large conference every year called the GNOME Users and Developers European Conference (GUADEC). The community is made up of many supporters large and small. Some of the large name supporters are IBM, Sun Microsystems and Hewlett-Packard.

What is GNOME

Gnome is a user environment that is available for most Linux distributions. One aspect that defines GNOME is the window manager Mutter, formally Metacity. The name Mutter is short for Metacity Clutter. What Mutter does give the user a non traditional experience. The normal GUI has a tool bar and the main Desktop is the area of business. Mutter is utilized within the what GNOME calls the Unity Desktop Environment. Now the Desktop is a clean slate and by calling up Mutter you have access to multiple work areas, programs and everything else that is on the traditional desktop.

Current release is 3.4.

Developments

The step into the Unity Desktop environment is a step towards the old Linux philosophy of many different areas that work well together. This has spread across tablets and phones. Unity is trying to position itself as a core environment for all platforms, must like Google has done with the Droid OS.

Distributions

Most if not all come packages with GNOME as Default or and option.

Opinion

While Unity is a step forward it leaves me feeling like i have lost control. Many people have written in complaints about the new Mutter world. I guess it just comes down to the way i like to use my desktop as a work surface. I was actually hoping that the future would bring the ability to customize each desktop more… not less. The new way that the desktops are called up actually makes them almost useless. They come when you call up the activities panel and are just a picture for the most part. Even calling a different program on each tend to merge the programs to the first desktop. Again, i want 4 virtual machines on a cube… that is the most impressive and use full desktop i have ever had. I feel like somewhere we took a wrong turn. There is nothing like the good old ctrl+alt arrow. Making you step away from the cube desktop (thanks compiz) and just watching your friends amazement as you shatter the Windows one desktop world.

GNOME Environment

2) KDE

History

KDE (K Desktop Environment) was started before GNOME in 1996 by Matthais Ettrich. The goal of KDE was to functional work the same and be a cross plateform desktop and applications,(FreeBSD, linux, windows, Solaris and Mac OSX). KDE has a large development base and many supporters.

What is KDE?

KDE has the look and feel of most GUIs out there for linux. It does work differently in some basic ways. However, it is easy to find how to navigate around differences. The look and feel comes from kwin being the main functional part of the Desktop. Giving you control over the environment.

Current release KDE 4.6

Developments

KDE had a major problem on their hands when they released KDE 4. The user interface was drastically changes, much like GNOME 3. The KDE community rose up and many changes happened.

Opinion

KDE 4.6 feels more like home then GNOME 3. You are able to use the desktops and customize them in many ways. However, you are still limited in these virtual workspaces as to what you can do. They are more of an idea of a virtual workspace but they are not workspaces. You cannot add icons to one without it being on them all etc. I have always wanted to have one for fun, one for college…etc. I had a hard time installing packets needs and found it confusing to navigate. Something the KDE founding mission has failed in as they want it to have an ease of use.

GUI Environment

Conclusion

Sources

Experience

GNOME

  1. Connect to the internet

10: Ease of use. Simple right click opened many connections that even windows does not find. Able to quickly add my key and it connects without a problem. Nivigates communication with my router much faster then I have experienced with Windows. I also have an issue where my Win Machine drops the routers information and the router has to be restarted so they can be friends again. A problem i did not see at all. Even when downloading Gbs over the net.

  1. Make a DVD and .avi play

7: I fully understand that proprietary driver packs are against the GUL and Opensource licenses. These used to be a beast to get and install but could done from the command line with sudo apt-get libdvdcss4 etc. All went well you were off an running but the learning curve took some time. The community documentation was dumbed down enough for anyone to use. In the new GNOME 3 world you still have the same issue; however, they have made it simple. When you try to play a file that requires prop drivers you get this nice little prompt. It asks you if you are sure you want to use prop drivers and away it goes. Installs after asking for your root pass life is off and running. Want to make it better? Ask me when i install it in the first place and install all of them. i like to know how to do something but after that.. i just want it done.

  1. Install a game

7: Well I cannot say much. They have added something very much like the google play market. Easy to install, nice icons… really trying to pit developers to better the choices. Pay for apps are starting to creep in. As for the quality of what is there… mostly the same boring junk. Free is nice, but i want to be able to play good stuff. Wine has made major improvements and this helps. So starcraft was installed and off i went.

  1. Use it for a few days as your normal computer

6: I have been a GNOME user for along time.. 5 years, maybe more. My flavor was Ubuntu, even have a sweater. I just cannot get Unity. I feel like i was taken from a college level and put in highschool again. I want more control over my linux GUI… that is why i love linux. The next area would be functionality. I do still have a win machine just because it is a windows world and Chrome is nice. I found Chrome for Gnome and was happy with that.

Total Score: 30

KDE

  1. Connect to the internet

9: Connected without any problems. Did not see as many local connections but mine is the only one that is important. Did have issues with reconnecting after going to sleep.

  1. Make a DVD and .avi play

4: I gave up. The repositories have to be added and then you can access the different drivers. There is not one clear repository that holds the drivers and not knowing that they have to be added send to in circles. The same prompt to install comes up when running the media however it just comes up with an unhelpful error code. After a few days of playing with this i installed another media player and found it worked fine. Totem is just different on KDE. I installed SUSI on another machine and was not able to get the driver pack working like i did on the first machine.

  1. Install a game

5: You have a list of names, nothing shinny and for KDE that is an issue. As they are on a mission to be sleek. They have a classic list of packets unlike the store approach of GNOME. So you have to know what you are after. WINE did not install with the ability to have starcraft run easily. That was a beast and when i did get it running.. games play was highly taxed.

  1. Use it for a few days as your normal computer

6: Without my movies or any real entertainment I was left to just searching the web. Found i did not have Chrome… Firefox is nice but has lost competitiveness with Chrome. I just did not have much to use it for. Total Score: 24

Analysis

I came in with KDE rating just 6 points lower then GNOME. KDE was such a heart break and held so many restrictions to fun that I just have to sadly turn to Unity. Thankfully you can add and use the traditional desktop still with GNOME 3. For this little adventure i learned a lot about the purpose and direction of the two main GUIs of the linux world.

Experiments

Experiment 1

Question

Is it possible to create a fully functional Linux system from a USB drive?

Resources

Hypothesis

I should be able to set up a full functional system off from a USB, restricted only by the size of the usbdrive. It will be able to record all changes, install needed packages and all for the full GUI experience.

Experiment

i have purchased or acquired the follow components for the experiment.

Lonovo X61 laptop, (7762-54U Intel Core2 Duo 1.6GHZ 1GB). - This is a depresied business laptop that seelf for 2k new - Total cost was less then ninety from ebay. Primarily because there is no OS, battery or hardrive. - This system will be a perfect platform for the linux system i plan to toy with 3 pendrives, 4gb, 8gb and 16 gb. - After researching different flavors of Linux and finding the amount of space each system will need the above drives are the perfect size. 3 ISO images - BackTrack 5 - Fedora - Arch Linux

Ubuntu was my first consideration being their large user base and documentation archives. However, i have run Ubuntu for about 5 years… time to step out of the box.

I will install each flavor using the wizard and live boot from the laptop

Data

- BackTrace 5

- Fedora

- Arch Linux

Analysis

Based on the data collected:

  • Was your hypothesis correct?

Yes the three usb drives boot nicley, save all changes and provide a complete user experience

 
* Was your hypothesis not applicable?
  it concluded with findings
* Is there more going on than you originally thought? (shortcomings in hypothesis)
  Wizard issues
  - The wizard had issues with the versions that i was trying to install. I had the Universal USB Installer ver 1.5.5.4
      The issue was resolved by upgrading to 1.8.8.4
  - The wizard likes to be smarter then is should be. If the .iso is not names exactly the same as the linux flavor drop down box the installer will       not find it. The Fedora install gave me some issues with this
* What shortcomings might there be in your experiment?
* The objective was to find out if a fully functional linux system could boot for a usb drive. This was nothing new and i found a lot of resources on the web showing how to. So the topic might not be deep enough. 
* What shortcomings might there be in your data?
 no data was collected

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 2

repair an old Dell with a fresh install of Ubuntu

Question

Can linux make a computer, that is currently able to run win xp, run faster and add life to an old machine.

Resources

Hypothesis

Can an old system run better with linux?

I believe that the system will run better then a store bought system with 3x the physical architecture.

Experiment

I will explore the current setup, document the system, save all files and clean out the cob-webs.

I will be installing the newest version of Ubuntu 11.10 for the i386. The OS is a large decrease in size. Going from 32GB used for XP down to the usb version, that is 700mb. The additional driver packs and toys will make the system 1.6GB total.

Data

System - Dell Dimension E310 - Pentium4 HT Prescott

single core with 90nm

- MBoard 0JC474, Southbridge 82801FB rev.4 - BIOS A03 2005 - Windows XP Media Center Edition Professional SP3 32 bit - Graphics card Intel 82915G/GV/910GL Express 128MB Drvier 6.14/.10.4410 - HD Seagate ST3160828AS SATA-II 156GB - RAM DDR2 512 XP -Start up time 2 minutes -Errors msmsgs.exe error. “the instructions at ”)x5ff3cbc2“ referenced memory at “0x0007710f”. The memory could not be read” Unexpected signal: stack overflow with ntdll.dll Java error mim.exe end program fault ccpcc.exe end program fault

-Performance

Physical memory 78% avg. Processer avg.

   on idle the CPU runs 0%... surprising... there is alot of junk on here that screams melware. I do not think i can trust the task manager. 
   Installed Speccy to check and everything is the same. My Duel core does not run as well. 
   Maxed with three browsers and a photo editor
   

Ubuntu 11.10 - Start up time was 40 seconds - HD was installed at the full 160GB on SCS13 sda ATA - Performance

 CPU avg is 12%
 Mem running at 41%

Analysis

Based on the data collected:

  • Was your hypothesis correct? The experience seems much fuller, from my opinion the system is much better.
  • Was your hypothesis not applicable? N/A
  • Is there more going on than you originally thought? nope
  • What shortcomings might there be in your experiment? My ability to actual measure core performance or other factors was very limited.
  • What shortcomings might there be in your data? The data is based mostly on users opinion.

Conclusions

Total install took 10 minutes. The installer was seamless and everything worked strait from the install. The system is setup for my son, he will be having lots of fun thanks to Ubuntu.

After thought: the performance was highly increased by Ubuntu; however Fedora made it fly.

Experiment 3

Rooting Android

Question

Is it worth all the hassle to root your android phone.

Resources

Hypothesis

After reviewing the walk through and many of the XDA developers forums the act of root is not an intense act. Thanks to the developers the process is turn key. Once rooted you have more functions that you can use to control many of the functions of your phone. You are able to limit feature that consume space and the CPU meter. Rooting the phone will improve the operation of the phone.

The only draw back is that gaining full power over your phone voids the warranty on the phone.

Experiment

I will be following the walk through given by the resources listed. 1)restore the phone to original factor install 2)install Odin 3)flash the ROM 4)reboot

Data

I had issues with the install and had to repeat the process. Once completed the phone ran much better. The boot up was completed in 1/3 of the time is typically takes and many of the advanced super user feature allow higher level of control.

Analysis

  • Was your hypothesis correct? Yes
  • Was your hypothesis not applicable? N/A
  • Is there more going on than you originally thought? The community that is working to allow rooting is busy. I did not know that it was such a big project
  • What shortcomings might there be in your experiment? The experiment is not really one that allows for measure outside of opinion.
  • What shortcomings might there be in your data? No data was needed

Conclusions

All phones should come with a root install for the owner. Would the consumer market allow limited access on their home computers in exchange for a service. I doubt it highy and wounder why we allow the legality of the warranty on the phones to stay valid. The process was easy and the return of the time invested was great.

Part 2

Entries

Entry 5: March 9, 2012

I just installed Fedora on a machine that i had worked on in the above experiment. Ubuntu was a large improvement over Win XP. It just still had some issues with speed and responsiveness. I notice many times it had a hard time keeping up with the visual aesthetics. It would also have to start and wait with many functions. I ran Fedora 16 live from a usb and I was very impressed. The machine ran smooth and without issues. I had used Kde in the past and found it to be a nicer GUI over the Gnome world. Performance was top notch until i started to test it against what i wanted it to do. I was used to the large developer base that comes from the Gnome world and I could tell right away that Fedora was missing a few bolts under the hood. The newest issue is with video. All of my video are ripped, stripped and converted to .avi files. Apparently one thing Fedora is not really happy with. I will be reviewing the repository and trying to make it work in an upcoming experiment.

Entry 6: March 16, 2012

Linux put the space shuttle in orbit. I was doing some looking around and it seems the NASA is sweet on linux. Discovery runs all lunix controls and most of what they are using is self written code. Nice to know that we do not have to restart the servers when we have an issue while they are in orbit. lol. The newest thing is that NASA is using a linux based vendor Wind River to support the development their New Millennium Program Space Technology 8 (ST8) Dependable Multiprocessor.

Entry 7: March 23, 2012

I did a search on admin commands that unix has to offer and came across the “w” command. This command allows you to see a list of users and there log history etc. This one is fun when you are looking for someone or just want to see when someone last came to visit.

Snippet form that help file

Different options that are given are 
        -f    file
              Tells last to use a specific file instead of /var/log/wtmp.
       -num   This is a count telling last how many lines to show.
       -n num The same.
       -t YYYYMMDDHHMMSS
              Display  the  state of logins as of the specified time.  This is
              useful, e.g., to determine easily who was logged in at a partic-
              ular  time  --  specify  that  time  with -t and look for "still
              logged in".
       -R     Suppresses the display of the hostname field.
       -a     Display the hostname in the last column. Useful  in  combination
              with the next flag.
       -d     For non-local logins, Linux stores not only the host name of the
              remote host but its IP number as well.  This  option  translates
              the IP number back into a hostname.
       -F     Print full login and logout times and dates.
       -i     This  option is like -d in that it displays the IP number of the
              remote host, but it displays the IP number  in  numbers-and-dots
              notation.
       -o     Read  an  old-type  wtmp  file  (written by linux-libc5 applica-
              tions).
       -w     Display full user and domain names in the output.
       -x     Display the system shutdown entries and run level changes.
lab46:~$ w
 12:59:04 up 72 days, 20:19, 12 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
mgough   pts/1    rrcs-69-193-122- 17Jan12  1:09m 10:18  10:18  irssi
wedge    pts/8    telstar.lair.lan 09:13    2:23m  0.14s  0.14s -bash
jjohns43 pts/24   cpe-74-65-82-173 23Jan12 28:25m 11:08  11:08  irssi
thakes3  pts/32   :pts/8:S.0       16Mar12  1:17   2:02   2:02  irssi
thakes3  pts/41   172.16.198.143:S 21Mar12 45:39m  0.28s  0.04s nano notes.txt
thakes3  pts/48   172.16.198.143:S 21Mar12  1:17   1.84s  1.83s screen -r 6463.
thakes3  pts/68   172.16.198.143:S Mon10   14.00s  0.32s  0.32s /bin/bash
skinney1 pts/74   65-124-85-125.di 10:26    0.00s  0.10s  0.01s w
thakes3  pts/70   172.16.198.143:S Sun13   46:01m  0.09s  0.09s /bin/bash
thakes3  pts/85   172.16.198.143:S Wed10    2days  0.14s  0.00s /bin/bash
nsano    pts/73   grrasp:S.0       17Feb12 39:34   5:55   5:55  irssi
jjohns43 pts/82   cpe-74-65-82-173 27Feb12 28:25m  5.79s  5.78s screen -r
lab46:~$ w last skinney1
 12:59:14 up 72 days, 20:19, 12 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
lab46:~$

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

cprog Keywords

  1. Selection Structures (if, case/switch) (done)
  2. Repetition/Iteration Structures (for, while, do while) (done)
  3. Arrays (standard notation, pointer arithmetic, single-dimensional, multi-dimensional) (done)
  4. File Access (Read, Write, Append) (done)
  5. Structures (Declaration, Accessing Elements, Pointers to) (done)
  6. typedef, enum, union (done)
  7. Functions, Parameters (Pass by: Value, Address, Reference), Return Types, Recursion, Command-line arguments (done)
  8. Compiler, Preprocessor, Flags, Assembler, Linker, Multi-file programs (how to structure, how to compile) (done)

cprog Keyword 9

Selection Structures (if, case/switch)

Definition

A selection structure allows the program to respond differently depending on users input. For example if the user is prompted a question responds “yes” a certain action is taken. On the other hand if the user responds “no” the program then goes to a part of the code the exit. A common way to set up the program to respond to input is to use the IF, or and switch statements.

Demonstration

The IF statement

int main()
{
        int num;
 
        printf("enter and number between -10 and 10: ");
        scanf("%d", &num);
 
        if (num > 0)
                printf("%d is a positive number\n", num);
 
        return (0);
}
lab46:~/src/cprog/classproject$ ./ex15.out
enter and number between -10 and 10: 10
10 is a positive number

The IF and Else statement

#include <stdio.h>

int main()
{
  int i = 6;

  if (i > 1)
    printf("We have\n");

  if (i > 10)
    printf("nice amount\n");
  else
    printf("not big enough\n");

  if (i == 5 )
  {
    printf("only got 5\n");
  }
  else if(i == 6 )
  {
    printf("just right\n");
  }
}
lab46:~/src/cprog/classproject$ ./ex17.out
We have
not big enough
just right

cprog Keyword 10

Repetition/Iteration Structures (for, while, do while)

Definition

The Repetition/Iteration Structures, also known as loops, allow the program to go through a self check to determine if it should continue the executing the program.

Demonstration
#include <stdio.h>
 
int main()
{
  int loopCount;
  printf("enter loop count: ");
  scanf("%d", &loopCount);
 
  while(loopCount > 0)
  {
    loopCount = loopCount -1;
     printf("only %d loops to go\n", loopCount);
  }
 
return (0);
}
 enter loop count: 12
only 11 loops to go
only 10 loops to go
only 9 loops to go
only 8 loops to go
only 7 loops to go
only 6 loops to go
only 5 loops to go
only 4 loops to go
only 3 loops to go
only 2 loops to go
only 1 loops to go
only 0 loops to go

cprog Keyword 11

Arrays (standard notation, pointer arithmetic, single-dimensional, multi-dimensional)

Definition

An Array is setting up place holders for values. A good way to see this is if you picture an excel spreadsheet. You have a column and a row. The Array sets the number of columns and the number of rows. This allocates memory blocks to be used by the program. When you add more rows you are adding dimensions to the array.

That standard notation for an array is;

int array[SIZE] = {Column pointer,… ,…, etc..};

Demonstration

Single dimensional array

#include <stdio.h>
#define SIZE 5
int main()
{
	int array[SIZE] = {4, 5, 6, 7, 8};	
	int i;
 
	for (i= 0; i < SIZE; i++)	
	{
		printf("%d\n", array[i]);
	}
return 0;		
}
lab46:~/src/cprog/classproject$ ./ex19.out
4
5
6
7
8

cprog Keyword 12

File Access (Read, Write, Append)

Definition

File access is when the program gets information from a file or produces an output to a file. This can be helpful in many ways. For example. With our encoding program we took input from a file converted it and then output the results to a file.

Commands used fgetc fprintf

Demonstration
int main()
{
        FILE *in;
        char *c, fname[] = "message.in";
        int i;
        int *input[255];
 
        printf("Do you want to encrypt the file: ");
        scanf("%d", input);
 
        if (*input == 'y' || *input == 'Y')
                {
                        c = fgetc(in);
                        while(c != EOF)
                        {
                        if((c >=65) && (c <= 'Z'))
                                c++;
                        else if((c >= 'a') && (c <= 'z'))
                                c++;
                        if((c == ('Z' + 1)) || (c == ('z' + 1)))
                                c = c - 26;
                        fprintf(stdout, "%c", c);
                        c = fgetc(in);
                        }
                }
                else if (*input == 'n' || *input == 'N')
                {
                        c = fgetc(in);
                        while(c != EOF)
            {
                        if((c >=65) && (c <= 'Z'))
                                c--;
                        else if((c >= 'a') && (c <= 'z'))
                                c--;
                        if((c == ('Z' + 1)) || (c == ('z' + 1)))
                                c = c - 26;
                        fprintf(stdout, "%c", c);
                        c = fgetc(in);
                        }
                }
                fclose(in);
                return (0);
}

cprog Keyword 13

Structures (Declaration, Accessing Elements, Pointers to)

Definition

Structures are a collection of variables. They are grouped together into a single thing and proved a way of keeping data and needed elements together.

Basic Syntax

Structure Declaration: struct struct-name{ type field-name; type field-name; … };

Demonstration
#include <stdio.h>
 
struct color 
 
	{
	  int id;
	  char *name;
	  float percentage;
	} 
 
	black, blue, red;
 
 
int main() 
{
  struct color st;
  black.id=1;
  blue.name = "fav";
  red.percentage = 90.5;
  printf(" Id is: %d \n", black.id);
  printf(" Name is: %s \n", blue.name);
  printf(" Percentage is: %f \n", red.percentage);
  return 0;
}
 lab46:~/src/cprog/classproject$ ./ex20.out
 Id is: 1
 Name is: fav
 Percentage is: 90.500000

cprog Keyword 14

typedef, enum, union

Definition

typedef or type define allows you to declare one type of integer as another type. When you declare this definition the name is has been “enum”.

Demonstration
For example of the enum

typedef enum x{1, 2}  Value;

int main()
{
   Value data = 20;
   if (data == BLACK)
   {
      //etc.
   }
}  

This example defines the integer aaa, bbb and ccc and sets them as arrays.

typedef int aaa, bbb, ccc;
typedef int aaa[15], bbb[9][6], ccc[2];

This example sets char to have a double place value. 

typedef int (*char)(double);

cprog Keyword 15

Functions

Definition

A function is a relation between inputs and outputs. It will return a value for use within the program. A function lists the statements that is executes.

For example the function

result = power(val, pow);

This calls the function powers and assigning the return value to variable results.

Syntax

return-type function-name ( argument)
{
    local-declarations
    statements
    return return-value;
}
Demonstration
void exchange(int a, int b)
{
    int temp;
 
    temp = a;
    a = b;
    b = temp;
    printf(" From function exchange: ");
    printf("a = %d, b = %d\n", a, b);
}

cprog Keyword 16

Compiler, Preprocessor, Flags, Assembler, Linker, Multi-file programs (how to structure, how to compile)

Definition

Compiler The compiler translate high-level languages programs into assembly language.

Assembler

The assembler converts assembly language into object files. These contain a combination of machine instructions. They also convert decimal numbers in to programmer binary.

Linker

The linker merges the object files and creates the executable file. It has basically three tasks; searched the program to find routines, determine memory locations and resolves reference among the files.

Loader

The loader is the part of the OS that takes the executable file and brings it out in the open and starts running it.

Demonstration
Source file => Assembler => Object File \
Source file => Assembler => Object File  ---> Linker ---> Executable File
Source file => Assembler => Object File /       |
                                              library

cprog Objective

cprog Objective

Break down and look at the source code for a game.

Definition

Find the source code for any game that is written in C. In my own words explain what the code does and how it performs the desired tasks.

Method

Completion comes from the written explanation.

Measurement

There are many sources for code out there. I found a code for a battleship program written by Michael Margues.

URL: http://www.cprogramming.com/cgi-bin/source/source.cgi?action=Category&CID=2

Analysis

The code is long enough to wrap around my house. So I will be taking some highlights and working through the general structure of the program.

(1) The code includes the conio.h file that is part of the DOS world. It allows the creation of text user interfaces. From this point it then declares three main voids. Mike takes and int's the lengths of the boats by allocating each part of the boat to declaration. He then uses chars to create and array that is used at the board. This serves as a very creative way to tie the required game play to the text output world.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

void checkShips();
void quitGame();
void targeting();

	int check[128];
	int target, hit = 0, i;
	int airpone, airptwo, airpthree, airpfour, airpfive;
	int destroypone, destroyptwo, destroypthree, destroypfour;
	int battlepone, battleptwo, battlepthree;
	int subpone, subptwo, subpthree;
	int patrolpone, patrolptwo;

	char rowone[50] = "11 12 13 14 15 16 17 18\n"; 
	char rowtwo[50] = "21 22 23 24 25 26 27 28\n";
	char rowthree[50] = "31 32 33 34 35 36 37 38\n";
	char rowfour[50] = "41 42 43 44 45 46 47 48\n";
	char rowfive[50] = "51 52 53 54 55 56 57 58\n";
	char rowsix[50] = "61 62 63 64 65 66 67 68\n";
	char rowseven[50] = "71 72 73 74 75 76 77 78\n";
	char roweight[50] = "81 82 83 84 85 86 87 88\n";
	char e;

	int airponetwo, airptwotwo, airpthreetwo, airpfourtwo, airpfivetwo;
	int destroyponetwo, destroyptwotwo, destroypthreetwo, destroypfourtwo;
	int battleponetwo, battleptwotwo, battlepthreetwo;
	int subponetwo, subptwotwo, subpthreetwo;
	int patrolponetwo, patrolptwotwo;

	char rowonetwo[50] = "11 12 13 14 15 16 17 18\n"; 
	char rowtwotwo[50] = "21 22 23 24 25 26 27 28\n";
	char rowthreetwo[50] = "31 32 33 34 35 36 37 38\n";
	char rowfourtwo[50] = "41 42 43 44 45 46 47 48\n";
	char rowfivetwo[50] = "51 52 53 54 55 56 57 58\n";
	char rowsixtwo[50] = "61 62 63 64 65 66 67 68\n";
	char rowseventwo[50] = "71 72 73 74 75 76 77 78\n";
	char roweighttwo[50] = "81 82 83 84 85 86 87 88\n";

(2)With everything set up for play he outputs the game board and begins getting the users input to establish the set up. This is setting data into each allocated spot on the board.

printf("Battle Ship\nBy Michael Marques\n");
	printf("These are the posible positions: \n");
	printf("11 ,12 ,13 ,14 ,15 ,16 ,17 ,18\n"); /* Displays posible ship positions */
	printf("21 ,22 ,23 ,24 ,25 ,26 ,27 ,28\n");
	printf("31 ,32 ,33 ,34 ,35 ,36 ,37 ,38\n");
	printf("41 ,42 ,43 ,44 ,45 ,46 ,47 ,48\n");
	printf("51 ,52 ,53 ,54 ,55 ,56 ,57 ,58\n");
	printf("61 ,62 ,63 ,64 ,65 ,66 ,67 ,68\n");
	printf("71 ,72 ,73 ,74 ,75 ,76 ,77 ,78\n");
	printf("81 ,82 ,83 ,84 ,85 ,86 ,87 ,88\n");

(3) The program prompts the user and allocates the selection as relevant to each ship. The program goes through this process with each piece of the game.

	printf("(3 spaces)Player 1 enter your Battle ship's poition: \n");
	printf("position1: ");     
	scanf("%d", &battlepone);
	printf("position2: ");
	scanf("%d", &battleptwo);
	printf("position3: ");
	scanf("%d", &battlepthree);

(4)

Ready to play! The user is then prompted for their input of where the enemy boats are. It runs through a long list of switch case statements for any of space that is hit.

	printf("Target: ");
	scanf("%d", &target);
	switch(target){
	case 11:
		switch(destroyponetwo) {
		case 11:
			printf("Hit!!!\n");
			hit = hit + 1;
			break;
		
			
		}
		switch(destroyptwotwo) {
		case 11:
			printf("Hit!!!\n");
			hit = hit + 1;
			break;

unix Keywords

  1. The UNIX Shell (done)
  2. Environment variable (done)
  3. $PATH (done)
  4. wildcards (done)
  5. tab completion (done)
  6. Job Control (done)
  7. The UNIX Programming Environment 9done)
  8. Compiler, Assembler, Linker, Loader (done)

unix Keyword 9

The UNIX Shell

Definition

The Unix Shell is basically a command line interpreter. This is also called a shell that gives the used and interface. The user is able to use the cell to run programs, tweak setting and many other uses. There are two main shells the Bourne shell and the C shell.

Demonstration

Example of a linux shell

unix Keyword 10

Environment variable

Definition

Environment variables are a set of named values that impact running programs and process. They set the stage for the operating environment. These variables are stored as temporary setting files. The stored values can be change but are typically established when the system starts. Tweaking these value give you control over things like your logname, mail server, pager or where your home file is.

Demonstration
lab46:~$ env EDITOR=nano
TERM=xterm
SHELL=/bin/bash
SSH_CLIENT=24.94.52.91 56204 22
SSH_TTY=/dev/pts/90
USER=skinney1
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd                                          =40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=0                                          1;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.                                          tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz                                          =01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.d                                          eb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;3                                          1:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=0                                          1;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.t                                          iff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;                                          35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4                                          v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:                                          *.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;                                          35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=                                          01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.                                          mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;3                                          6:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
MAIL=/home/skinney1/Maildir
PATH=/home/skinney1/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
LC_COLLATE=C
PWD=/home/skinney1
LANG=en_US
HISTCONTROL=ignoreboth
SHLVL=1
HOME=/home/skinney1
LOGNAME=skinney1
SSH_CONNECTION=24.94.52.91 56204 10.80.2.38 22
_=/usr/bin/env
EDITOR=nano

unix Keyword 11

$PATH

Definition

PATH is the environmental variable that is a list of files that my shell accesses, searches through, read/writes etc.

You are able to edit your path by using a PATH= command. This is highly recommended only at the administrator level. The example i found shows PATH=$PATH\:/dir/path ; export PATH

Demonstration
lab46:~$ $PATH
-bash: /home/skinney1/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games: No such file or directory
lab46:~$

unix Keyword 12

wildcards

Definition

A wildcard is basically a value that fills in as a include all value. The computer sees the wildcard as meaning it could be any value holding to what ever part is placed with it. For example a search for “*XYZ” will come back with all items that matches the XYZ at the end.

There are a few different types of wildacards; ? Matches any one character in a filename. * Matches any character or characters in a filename. [ ] Matches one of the characters included inside the [ ] symbols.

Demonstration

Example of a * wildcard search

 lab46:~/junk$ find de*
dem1.c
dem1.out
dem2.c
dem2.out
dem3.c
dem3.out
dem4.c
dem4.out

unix Keyword 13

Tab completion

Definition

Tab completion directs the shell to search the current directory and auto fill in the remainder of the name.

Demonstration

The example shows the contents of a file and the result of tab filling in the remainder of the content. The only trick with using tab completion is if there are multiple files that meet what you have entered then it will do nothing.

 lab46:~/src/cprog/classproject$ ls
6           char.out       encipherexample.c   hint1.out        script1.sh
7           cipher.txt     encipherexample1.c  message.in       script2.c
Suzy.c      color.sh       encipherexample2.c  ob1              test1.c
a.out       count.sh       encrpit.out         proj0.c          typec.c
age.sh      cprog2.c       enter.txt           project1.c       typec.out
backup.sh   date           excipherexample3.c  project1.c.save  typecast.c
bignum.c    encipher.c     exit.txt            rand.sh          typecast.out
bignum.out  encipher.out   func.c              range            var.c
bignum1.c   encipher1.c    hint1.c             range.c          var.out
char.c      encipher1.out  hint1.c.save        range.out
lab46:~/src/cprog/classproject$ ls cprog2.c

unix Keyword 14

Job Control

Definition

Job control is the ability to send running programs to the background within a shell. This can be beneficial when doing a large search quarry or when you need to do another element of a larger task. This is controlled by a list that the shell keeps that logs what is being done. This allows it to keep track of what processes are being run within the group. The

Demonstration
lab46:~$ top $

lab46:~$ % bg
top
top - 11:59:47 up 72 days, 19:20,  7 users,  load average: 0.00, 0.00, 0.00
Tasks: 329 total,   1 running, 328 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.2%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1568604k total,  1314012k used,   254592k free,   216856k buffers
Swap:   524280k total,    98664k used,   425616k free,   467392k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
17843 skinney1  38  18 11000 1432  932 R    1  0.1   0:00.08 top
    1 root      20   0  8356  700  592 S    0  0.0   0:50.92 init
    2 root      20   0     0    0    0 S    0  0.0   0:00.30 kthreadd
    3 root      RT   0     0    0    0 S    0  0.0   0:06.00 migration/0
    4 root      20   0     0    0    0 S    0  0.0   0:11.50 ksoftirqd/0
    5 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/0
    6 root      RT   0     0    0    0 S    0  0.0   0:05.07 migration/1
    7 root      20   0     0    0    0 S    0  0.0   0:04.58 ksoftirqd/1

unix Keyword 15

The UNIX Programming Environment

Definition
Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

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

unix Keyword 16

Compiler, Assembler, Linker, Loader

Definition

Compiler The compiler translate high-level languages programs into assembly language.

Assembler

The assembler converts assembly language into object files. These contain a combination of machine instructions. They also convert decimal numbers in to programmer binary.

Linker

The linker merges the object files and creates the executable file. It has basically three tasks; searched the program to find routines, determine memory locations and resolves reference among the files.

Loader

The loader is the part of the OS that takes the executable file and brings it out in the open and starts running it.

Demonstration
Source file => Assembler => Object File \
Source file => Assembler => Object File  ---> Linker ---> Executable File
Source file => Assembler => Object File /       |
                                              library

unix Objective

unix Objective

Connect to the lab46 server via my Droid phone.

Definition & Method

Explore the options available, install and connect.

Measurement

There are many apps and programs that allow you to connect to a server. ConnectBot, Better Terminal Emulator, Irssi ConnectBot and the list goes on. I am going to attempt the connection by using a method that stays as close to the command line as i can.

Analysis

The simplest way to connect was found with Irssi's droid app. The connection is simply added as name@lab46.corning-cc.edu:22 and off you go. The method i was after was using the typically built in Unix SSH program. This was not possible to achieve. Being Unix, on a rooted droid one should be able to download the SSH program and be off and running. I left it with what worked. Connecting with other methods seemed to be and annoying task.

Resource List

Experiments

Experiment 4

Question

Can I change the colors of different aspect of the shell from the command line?

Resources

Hypothesis

There are many times in a session that you are using a term for something and want it to stand out among your other sessions. What is the commands for changing its looks? My hypothesis is there has to be away to change these settings.

Experiment

I will be doing the needed research and documenting what i find.

Data

The main issue is that I am using a shh client. I cannot change those setting from with a host terminal as the look and feel of the ssh client is not controlled by the unix server. So error in logic when i started this little project. I did find some ways to control the output to the term by server and have listed them here.

First thing first, find you settings.

echo $PS1

You should have gotten something like

lab46:~$ echo $PS1
\h:\w\$

The logic is basically

  • \h = host name
  • \u = current username
  • \w = working directory

Changing you Bash Prompt color while using your log name. Simply change the '0;31m' to suit your needs.

export PS1="\e[0;31m[\u@\h \W]\$ \e[m "

This window will not allow me to show the color example that I have; however, here is some more color codes.

  • Black 30
  • Blue 34
  • Green 32
  • Cyan 36
  • Purple 35

Analysis

Based on the data collected:

  • Was your hypothesis correct? I was way off from the start.
  • Was your hypothesis not applicable? Correct, it was wrong.

Conclusions

Noted in research section

Experiment 5

Question

How does one hide themselves?

Resources

Hypothesis

The use of proxies allow a user to easily hide their IP/MAC from connections they make over the internet.

Experiment

not sure at this point….

Data

After reading and doing lots of research the folks at Anon/LOLSEC suggest the first step is your tractability to the physical machine. This is a little further then I want to slide into this subject. There are many ways to look at your own security. For one, paying cash for a machine and not leaving the ability to connect that machine's unique identifiers with your credit card number. From this point you take your new machine home and set up a triple virtual machine with each running a little IP and MAC change script that runs every hour. Never use this computer for anything normal… and never connect locally. The list of assignments goes on… but I am not interested in hacking the FBI. I will leave that to the script kiddies behind the masks and focus on just being hidden behind proxies.

Proxies

A proxy is like a man in the middle for the net. When you open a website your comp send your IP to the website. The site is then able to send the webpage to your comp. The proxy goes and gets that information and then sends in on to you. So the website never sees your IP but only that of the proxy. I have listed a few proxies in the research sections.

What is my IP

Windows “ipconfig”

C:\skinney>ipconfig

Windows IP Configuration

Ethernet adapter Wireless Network Connection:

        Media State . . . . . . . . . . . : Media disconnected

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . : work stuff
        IP Address. . . . . . . . . . . . : 00.00.000.00
        Subnet Mask . . . . . . . . . . . : 255.255.000.0
        Default Gateway . . . . . . . . . : 00.00.000.0

“*”nix typically you can just call “ifconfig” and get there.. but we needed to rock out “/sbin/ifconfig”

lab46:~$ ifconfig
-bash: ifconfig: command not found
lab46:~$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3e:5d:88:d8
          inet addr:12.82.2.32  Bcast:10.80.2.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe5d:88d8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:49729834 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58369549 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9291283443 (8.6 GiB)  TX bytes:30407298791 (28.3 GiB)
          Interrupt:18

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:384756 errors:0 dropped:0 overruns:0 frame:0
          TX packets:384756 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:51742675 (49.3 MiB)  TX bytes:51742675 (49.3 MiB)

Setting up the browser to use the proxy

Look in the internet options sections. There should be a “connections” section. Once you find this in your flavor of browsing. you need to initialize using proxies. At this point you will need the IP of the proxy you wish you use and the port of their server. Enter this information and you are off and running with a one proxy connect. Keep in mind… this is one layer. When it comes to being hidden you need many layers and there is no such thing as invisible.

Proxy Chaining

There is a simple method to chaining together many proxies in your browser. As noted earlier many layers is a good thing. What if you are using one proxy and lets say our court systems says… Proxy ABC i order you to give us a list of all IPs that wen through you to Mega Up Load. Guess you are in trouble… with the other millions of people. Now if you had a chain of proxies going… chances get slimmer that you will be in that list.

Here is an example of what we are trying to accomplish

[user]>>[proxy1]>>[proxy2]>>[proxy3]>>[website]

So to do this you are going to use a linker.. “-.-”

http://www.proxy.magusnet.com/-.-proxy2 etc/-.-proxy3 etc/-.-http://www.google.com

Analysis

Based on the data collected:

  • Was your hypothesis correct? It was correct, there are many ways to go about being hidden.
  • Is there more going on than you originally thought? There are many ways.. lol. The majority seem pretty strait forward.. and there are even pay for services that can do this service for you.
  • What shortcomings might there be in your experiment? Not data driven

Conclusions

You are only as safe as you want to pretend you are. There is always new ways around preconceived notions on security.

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 1, 2012

What action or concept of significance, as related to the course, did you experience on this date?

I was looking for “easter eggs” in unix. There are a lot of them in the old systems, but they seem to have been removed or just not on the lab46 term. I did find some fun ones

moo in apt-get

lab46:~$ apt-get moo
         (__)
         (oo)
   /------\/
  / |    ||
 *  /\---/\
    ~~   ~~
...."Have you mooed today?"...
lab46:~$

moo in aptitude

# aptitude moo
There are no Easter Eggs in this program.

# aptitude -v moo
There really are no Easter Eggs in this program.

# aptitude -v -v moo
Didn't I already tell you that there are no Easter Eggs in this program?

# aptitude -v -v -v moo
Stop it!

# aptitude -v -v -v -v moo
Okay, okay, if I give you an Easter Egg, will you go away?

# aptitude -v -v -v -v -v moo
All right, you win.

                               /----\
                       -------/      \
                      /               \
                     /                |
   -----------------/                  --------\
   ----------------------------------------------
# aptitude -v -v -v -v -v -v moo
What is it?  It's an elephant being eaten by a snake, of course.

last one

lab46:~$ ddate
Today is Boomtime, the 54th day of Discord in the YOLD 3178

Entry 10: April 7, 2012

I have a new phone… the droid razr… so nice.

Not being rooted makes me feel like a little kid who had his mommy put a lock on the frig.. I Must get access! I would do another experiment on this one but i already noted doing it on my samsung.

Entry 11: April 13, 2012

I am at work and I was talking with the resident IT personality. I was trying to glean the type of servers that we have and see if any are unix based. After finding out that he did not have any idea about the unix server that acts as a printer relay i was able to help him out. He needed to find the IP address and i was able to tell him what and how to do it.. nice

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.

cprog Keywords

  1. I/O Streams (cin, cout, cerr, stream operators) [C++]
  2. Namespaces [C++]
  3. Type Casting Operators, Const-Volatility Specifiers (const, volatile) [C++]
  4. Classes (Objects, Constructor, Destructor, Access Control, Public, Protected, Private, Friend, “this” pointer) [C++]
  5. Inheritance (single, multiple Inheritance), Polymorphism/Virtual Functions, Abstract Base Class [C++]
  6. Overloading (Functions, Operators) [C++]
  7. Exception Handing (throw, try, catch) [C++]
  8. Templates, STL (Standard Template Library) [C++]
cprog Keyword 17

I/O Streams (cin, cout, cerr, stream operators)

Definition

The concepts of I/O in C++ are streams, insertion, and extraction. The input stream is a source of input. It can be an object from which characters can be obtained (extracted). The output stream is an object to where output can be directed.

Demonstration

Here is and example

#include <iostream>
#include <fstream>
 
int main () 
{
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}
cprog Keyword 18

Namespaces [C++]

Definition

A namespace is a declaration of different areas of the code. It calls them by a name and is then called out from within the code within the cycle of workflow.

Demonstration

Here is an example of the arrangement that a namespace takes within the code.

#include <iostream>
using namespace std;
 
namespace first
{
  int var = 5;
}
 
namespace second
{
  double var = 3.1416;
}
 
int main () {
  cout << first::var << endl;
  cout << second::var << endl;
  return 0;
}
cprog Keyword 19

Classes

Definition

Classes are groups of data related to a single object type. They are really functions to access information, and the classes possess the ability to inherit from other classes.

Demonstration

Here is an example from wiki. This shows “class” being used to define the called variable “person”. Then person is further allocated to have two containers, a and b.

#include <iostream>
#include <string>
using namespace std;
 
class person
{
public:
  string name;
  int age;
};
 
int main()
{
  person a, b;
  a.name = "Calvin";
  b.name = "Hobbes";
  a.age = 30;
  b.age = 20;
  cout << a.name << ": " << a.age << endl;
  cout << b.name << ": " << b.age << endl;
  return 0;
}
cprog Keyword 20

Inheritance

Definition

Inheritance is a a structure of reusing existing classes that have already been declared without modifying them, thus producing hierarchical relationships between them.

Demonstration

In the following example the class “A” is called out as public making it inherit the past declaration.

#include <iostream>
using namespace std;
 
class A {
   int data;
public:
   void f(int arg) { data = arg; }
   int g() { return data; }
};
 
class B : public A { };
 
int main() {
   B obj;
   obj.f(20);
   cout << obj.g() << endl;
}
cprog Keyword 21

Overloading

Definition

Overloading allows functions to have the same name but to have different parameters. So operators can be extend to act as a class within the same code.

Demonstration

Here is an example from wiki. The “time” operators is declared at the code header and given meaning. It is then broken into minutes and seconds.

Time operator+(const Time& lhs, const Time& rhs) 
{
    Time temp = lhs;
    temp.seconds += rhs.seconds;
    if (temp.seconds >= 60) {
        temp.seconds -= 60;
        temp.minutes++;
    }
    temp.minutes += rhs.minutes;
    if (temp.minutes >= 60) {
        temp.minutes -= 60;
        temp.hours++;
    }
    temp.hours += rhs.hours;
    return temp;
}
cprog Keyword 22

Exception Handling

Definition

Exception Handling is the attempt to have foresight into problems that happen while the code is running. Planning ahead for the inability of the program to do what it is designed to do, like being unable to find the source file that is used to pull up a list of data. While righting you code it is a good idea to “throw and exception” and see how the code responds.

Demonstration

Here is an example where we are asking the user for two numbers… what if they add a letter?

	cout << "Please provide two numbers\n";
	cout << "First Number: ";
	cin >> a;
	cout << "Second Number: ";
	cin >> b;

Adding in an If statement when the input is used can handle this exception and have fun telling the user to go back to Kindergarten.

If (a='A')
   cout << "sorry bro...that is a letter.. and number is the ones you use when you count your pennys";
cprog Keyword 23

Templates, STL

Definition

STL is short for Standard Template Library. The templates are a standard list of classes and template code.

Demonstration

STL provides many different types of container types. One is called a vector. It is sets a block allocated for use and can grow as needed (something that would make bignum easier). Here is an example i found. You can see the used of the vector.h file and the allocating of it. “vector<int> v;”.

#include <string.h>
#include <algo.h>
#include <vector.h>
#include <stdlib.h>
#include <iostream.h>
 
main ()
{
  vector<int> v;  // create an empty vector of integers
  int input;
  while (cin >> input)    // while not end of file
    v.push_back (input);  // append to vector
 
  sort(v.begin(), v.end());
 
  int n = v.size();
  for (int i = 0; i < n; i++)
    cout << v[i] << "\n";
}

cprog Objective

cprog Objective

Use a C program to change the IP address of my computer.

Definition

While doing other objectives I came across the suggestion that you should change your IP at given increments to increases your privacy while surfing. The documentation i was reading had more to do with other “outlets” for creative computing; however my love of computers comes from finding the limits of what can or cannot be done.

Method

Explore the world for a walk-through or community documentation. Compile that information and implement.

Measurement

To change your ip the standard ifconfig way

# ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up
# ifconfig eth0

Here is the direct code from lainoox that works very nicely. I would suggest that a script on playing with ifconfig would just be simpler. This is one approach.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#include <errno.h>
#include <netinet/in.h>
#if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
#include <netpacket/packet.h>
#include <net/ethernet.h>
#else
#include <sys/types.h>
#include <netinet/if_ether.h>
#endif
 
int set_ip(char *iface_name, char *ip_addr)
{
	if(!iface_name)
		return -1;	
 
	int sockfd;
	struct ifreq ifr;
	struct sockaddr_in sin;
 
	sockfd = socket(AF_INET, SOCK_DGRAM, 0);
	if(sockfd == -1){
		fprintf(stderr, "Could not get socket.\n");
		return -1;
	}
 
	/* get interface name */
	strncpy(ifr.ifr_name, iface_name, IFNAMSIZ);
 
	/* Read interface flags */
	if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
		fprintf(stderr, "ifdown: shutdown ");
		perror(ifr.ifr_name);
		return -1;
	}
 
	/*
	* Expected in <net/if.h> according to
	* "UNIX Network Programming".
	*/
	#ifdef ifr_flags
	# define IRFFLAGS       ifr_flags
	#else   /* Present on kFreeBSD */
	# define IRFFLAGS       ifr_flagshigh
	#endif
 
	// If interface is down, bring it up
	if (ifr.IRFFLAGS | ~(IFF_UP)) {
		fprintf(stdout, "Device is currently down..setting up.-- %u\n",ifr.IRFFLAGS);
		ifr.IRFFLAGS |= IFF_UP;
		if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) {
			fprintf(stderr, "ifup: failed ");
			perror(ifr.ifr_name);
			return -1;
		}
	}
 
	sin.sin_family = AF_INET;
 
	// Convert IP from numbers and dots to binary notation
	inet_aton(ip_addr,&sin.sin_addr.s_addr);	
	memcpy(&ifr.ifr_addr, &sin, sizeof(struct sockaddr));	
 
	// Set interface address
	if (ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
		fprintf(stderr, "Cannot set IP address. ");
		perror(ifr.ifr_name);
		return -1;
	}	
	#undef IRFFLAGS		
 
	return 0;
}
 
void usage()
{
	const char *usage = {
		"./set_ip [interface] [ip address]\n"
	};
	fprintf(stderr,"%s",usage);
}
 
int main(int argc, char **argv)
{
	if(argc < 3){
		usage();
		return -1;
	}
 
	set_ip(argv[1],argv[2]);
 
	return 0;
}

Out put of the program

 ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:1b:21:0a:d2:cf  
          inet addr:192.168.5.12  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe0a:d2cf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2690 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14732 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:516826 (516.8 KB)  TX bytes:2242645 (2.2 MB)
 
$ sudo ./set_ip eth1 12.13.14.15
Device is currently down..setting up.-- 4163
$ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:1b:21:0a:d2:cf  
          inet addr:12.13.14.15  Bcast:12.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::21b:21ff:fe0a:d2cf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2690 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14742 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:516826 (516.8 KB)  TX bytes:2247309 (2.2 MB

Here is a shell script route

#!/bin/bash
SUBNET=192.168.135.
ETH=eth0

for i in {1..254}
do
  ip addr add ${SUBNET}${i}/24 dev ${ETH}

  # do whatever you want here

  ip addr del ${SUBNET}${i}/24 dev ${ETH}
done

Sources

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?

unix Keywords

  1. Source Code, Object Code, Binary Code, Library (done)
  2. Pattern Matching(done)
  3. Regular Expressions(done)
  4. Filtering(done)
  5. Shell Scripting(done)
  6. networking, UNIX Networking Tools(done)
  7. Security(done)
  8. X Window System(done)
unix Keyword 17

Source Code, Object Code, Binary Code, Library

Definition

The source code for a program is the raw, un-processed by the compiler, file. Written in a programming language and used to further develop the software. The object code is produced by the compiler. It is generally a sequence of instruction that is used within the running the code. The Binary code is the machine language that is the final output of the compiler. This is actually was produces the desired results by the source code. The Library is the standard set or characters used in the correct syntax to tell the compiler what is needed to do.

Demonstration

Source Code example

#include<stdio.h>

int main()
{
 printf("yo dude");

return(0);
}
unix Keyword 18

Pattern Matching

Definition

Pattern matching is using the syntax of search programs to find conditions that meet the requested quarry. The most commonly used program for searching is the grep command. Taken from the man pages, Grep is defines as, “Grep searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN”.

Demonstration

Syntax for grep

grep 'word' filename
grep 'string1 string2'  filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName

Example taken from another source

grep -v bash /etc/passwd | grep -v nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
news:x:9:13:news:/var/spool/news:
mailnull:x:47:47::/var/spool/mqueue:/dev/null
xfs:x:43:43:X Font Server:/etc/X11/fs:/bin/false
rpc:x:32:32:Portmapper RPC user:/:/bin/false
nscd:x:28:28:NSCD Daemon:/:/bin/false
named:x:25:25:Named:/var/named:/bin/false
squid:x:23:23::/var/spool/squid:/dev/null
ldap:x:55:55:LDAP User:/var/lib/ldap:/bin/false
apache:x:48:48:Apache:/var/www:/bin/false
unix Keyword 19

Regular Expressions

Definition

The term regular expressions is speaking about a set of characters that make up the words of patterns of a search. These are used when looking for specific strings of text that match the quarry. This is very much like the explained grep command earlier but focuses us into the actual, expression, wording used.

Demonstration

For example

grep -i man heroes.txt

We are searching for any string that meets the expression “man” in the text file “heroes.txt”. The output is the following.

Catwoman
Batman
Spider Man
Wonder Woman
Ant Man
Aquaman
Martian Manhunter
unix Keyword 20

Filtering

Definition

In Unix a filter is a way of using commands and pipes command that can manipulate the output of file. Two of the most powerful and popular Unix filters are the sed and awk commands.

Demonstration

The “sed” command allows us to look search a file and replace characters. For example in the following junk file. I have call cat to present the contents of the file. I then use a pipe to link in the sed command. Sed then looks as what is being outputted by cat and finds anything that is an “e” and replaces it with “E”.

$ cat junk.txt | sed -e "s/e/E/"
corE
worm sEed
jEwel
unix Keyword 21

Shell Scripting

Definition

Shell scripting is a way that you can automate routine tasks. It allows the user more flexibility and control over the operation of the system.

Demonstration

Following example from the SSH manual. You can see by this example, that the more complex shell scripts take on the look and feel of the C programming language. We have presented a list and are going to work through the list.

#!/bin/sh
fruitlist="Apple Pear Tomato Peach Grape"
for fruit in $fruitlist
do
   if [ "$fruit" = "Tomato" ] || [ "$fruit" = "Peach" ]
   then
      echo "I like ${fruit}es"
   else 
      echo "I like ${fruit}s"
   fi
done

Output of the script

I like Apples
I like Pears
I like Tomatoes 
I like Peachs
I like Grapes

Resource: https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/unixscripting/unixscripting.html

unix Keyword 22

networking, UNIX Networking Tools

Definition

I love networking.. and there are many flexible tools with unix. Networking is the communication between computers. It is bringing those computers together to share resources, make work groups or just set up a game of QuakeIII.

Some common commands

  • finding host/domain name and IP address - hostname
  • test network connection – ping
  • getting network configuration – ifconfig
  • Network connections, routing tables, interface statistics – netstat
  • query DNS lookup name – nslookup
  • communicate with other hostname – telnet
  • outing steps that packets take to get to network host – traceroute
  • view user information – finger
  • checking status of destination host - telnet
Demonstration

Examples from the lab46 side

ab46:~$ hostname
lab46
lab46:~$ ifconfig
-bash: ifconfig: command not found
lab46:~$ nslookup
-bash: nslookup: command not found
lab46:~$ telnet
telnet> lab46:~$
lab46:~$ finger
Login     Name              Tty      Idle  Login Time   Office     Office Phone
jdavis34  Joshua Davis      pts/22     1d  Mar  6 12:57 (cpe-67-252-69-1:S.0)
jdavis34  Joshua Davis      pts/88     5d  Mar 29 16:18 (cpe-67-252-69-1:S.3)
jjohns43  Jeffrey Johnson   pts/24    18d  Jan 23 12:18 (cpe-74-65-82-173:S.0)
jjohns43  Jeffrey Johnson   pts/82    18d  Feb 27 11:03 (cpe-74-65-82-173:S.0)
jpettie   Jacob Pettie      pts/5          Mar  8 18:05 (pool-96-247-148-158:S.0)
jpettie   Jacob Pettie      pts/31    46d  Mar  6 14:35 (pool-96-247-148-158:S.1)
jpettie   Jacob Pettie      pts/35     5d  Mar 20 14:43 (pool-96-247-148-158:S.8)
jpettie   Jacob Pettie      pts/44    38d  Mar  6 16:39 (pool-96-247-148-158:S.3)
jpettie   Jacob Pettie      pts/77    47d  Mar 13 11:22 (pool-96-247-148-158:S.4)
jpettie   Jacob Pettie      pts/75    56d  Mar  6 15:17 (pool-96-247-148-158:S.2)
jpettie   Jacob Pettie      pts/95   1:31  Mar  8 11:00 (pool-96-247-148-158:S.7)
jpettie   Jacob Pettie      pts/91    40d  Mar  8 10:58 (pool-96-247-148-158:S.5)
jpettie   Jacob Pettie      pts/92    40d  Mar  8 10:59 (pool-96-247-148-158:S.6)
mfaucet2  Mason Faucett     pts/65   1:06  Mar 22 13:17 (172:S.0)
skinney1  Shane Kinney      pts/55         May  1 11:54 (65-124-85-125.dia.static.qwest.net)
squirrel  Pressly Dowler    pts/8     12d  Apr 19 22:53 (softscope.lair.lan)
tgalpin2  Tyler Galpin      pts/12     11  Jan 30 21:25 (:pts/72:S.0)
tgalpin2  Tyler Galpin     *pts/72     11  May  2 11:06 (172.16.192.234)
thakes3   Thomas Hakes      pts/41     2d  Apr 27 22:48 (172.16.198.198:S.0)
thakes3   Thomas Hakes      pts/62      2  May  2 10:43 (172.16.198.198:S.2)
thakes3   Thomas Hakes      pts/68     17  May  2 10:44 (172.16.198.198:S.3)
thakes3   Thomas Hakes      pts/2       3  Apr 30 11:36 (172.16.198.198:S.1)
wedge     Matthew Haas     *pts/14      1  May  2 08:49 (telstar.lair.lan)
lab46:~$ finger wedge
Login: wedge                            Name: Matthew Haas
Directory: /home/wedge                  Shell: /bin/bash
On since Wed May  2 08:49 (EDT) on pts/14 from telstar.lair.lan
   1 minute 34 seconds idle
     (messages off)
Mail last read Wed May  2 09:49 2012 (EDT)
Plan:
----------------------------------------------------------------------------
 Lab46 System Administrator

FYI, that is a pointing finger.. not the one that goes up but strait out… lol

unix Keyword 23

Security

Definition

Security on a Unix system comes from a few areas of concentration. Using permissions for users and groups is one way to keep key areas of the system out of the reach of unwanted side effects. Another way is to use smart passwords. Insuring that passwords are change every 3 months, are unique and have both alpha and numeric elements. When it comes to a Unix server patching is the most frequently used method. Finding exploits and deploying methods to fix the seen threat. Other best practices are firewalls, iptables, white/black lists etc.

Demonstration

Use of the lsof commands that shows a list of open files and what or who opened them.

lab46:~$ lsof | less
COMMAND     PID       USER   FD      TYPE  DEVICE SIZE/OFF     NODE NAME
init          1       root  cwd   unknown                           /proc/1/cwd (readlink: Permission denied)
init          1       root  rtd   unknown                           /proc/1/root (readlink: Permission denied)
init          1       root  txt   unknown                           /proc/1/exe (readlink: Permission denied)
init          1       root NOFD                                     /proc/1/fd (opendir: Permission denied)
kthreadd      2       root  cwd   unknown                           /proc/2/cwd (readlink: Permission denied)
kthreadd      2       root  rtd   unknown                           /proc/2/root (readlink: Permission denied)
kthreadd      2       root  txt   unknown                           /proc/2/exe (readlink: Permission denied)
kthreadd      2       root NOFD                                     /proc/2/fd (opendir: Permission denied)
migration     3       root  cwd   unknown                           /proc/3/cwd (readlink: Permission denied)
migration     3       root  rtd   unknown                           /proc/3/root (readlink: Permission denied)
migration     3       root  txt   unknown                           /proc/3/exe (readlink: Permission denied)

Use of the netstat command showing current connected protocols and their state.

lab46:~$ netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 *:35801                 *:*                     LISTEN
tcp        0      0 *:nfs                   *:*                     LISTEN
tcp        0      0 *:3939                  *:*                     LISTEN
tcp        0      0 *:3333                  *:*                     LISTEN
tcp        0      0 lab46.offbyone.lan:5000 *:*                     LISTEN
tcp        0      0 lab46.offbyone.lan:5007 *:*                     LISTEN
tcp        0      0 *:59343                 *:*                     LISTEN
tcp        0      0 *:sunrpc                *:*                     LISTEN
tcp        0      0 *:csync2                *:*                     LISTEN
tcp        0      0 lab46.offbyone.lan:4242 *:*                     LISTEN
tcp        0      0 lab46.offbyone.la:60002 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:41572 auth1.offbyone.lan:ldap ESTABLISHED
tcp        0      0 lab46.offbyone.la:47089 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:47998 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:42140 auth1.offbyone.lan:ldap ESTABLISHED
unix Keyword 24

X Window System

Definition

The X Window System, X11, is the basic graphical user interface (GUI). X11 sits between the computer and the user acting like a translator. Taking the input from the user in the form of the mouse and keyboard and translating it to changes within the system.

Demonstration

Example of a GUI

unix Objective

unix Objective

Utilize the ntpq command

Definition

The ntpq command is a utility program that monitors the NTP deamon, ntpd. NTPQ stands for Network Time Protocol Query. It runs and interactive mode by using the command line and can write variables. “Ntpq uses NTP mode 6 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it”, Man pages.

Method

Research, discover and implement.

Measurement

The ntpq command give and output requesting arguments.

lab46:~$ ntpq
ntpq>

Check to make sure that the deamon is monitor is running. The following pgrep will feed back the process code ot ntpq.

lab46:~$ pgrep ntpd
961

The -p arguments shows the servers and their sink…

lab46:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*juicebox.lair.l 116.204.3.124    2 u  385 1024  377    0.742   -0.054   4.615
 caprisun.offbyo .STEP.          16 u    - 1024    0    0.000    0.000   0.000
Analysis

Well… nothing really amazing with ntpq. I did find out a fun new command so mission done.

Resource List

unix Retest

Retest 7

Perform the following steps:

State Experiment

I am going to reinact the double connection by thakes.

http://lab46.corning-cc.edu/opus/spring2012/thakes3/start#experiment_4

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • This experiment is not heavy in the research need. Knowledge of ssh is all that is needed.
  • Are there additional resources you've found that you can add to the resources list?
  • The man pages and wiki
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading
  • yes
  • If you find a deviation in opinion, state why you think this might exist.
  • none found
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?
  • yes it stated the needed direction and walked through the goal
  • What improvements could you make to their hypothesis, if any?
  • This was a simple state the desired outcome and shoot project. Nothing really to build on.
Experiment

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

  • Are the instructions correct in successfully achieving the results?
  • yes i was able to follow without any unknowns.
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • well… he could have given us his password… lol… no it was good.
  • screen shots are always nice and he presented that.
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?
  • nope
Data
Analysis

Answer the following:

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

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • That i have a double connection and could keep in going… maybe a single script used a lot could cause the server some issues… bad thought… nvm
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • yes
  • Does the original author appear to have gotten some value out of performing the experiment?
  • he had fun and so did I, so yes he learned how to use ssh and find another way to play with the server
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
  • I like it, good deal.
Retest 8

Perform the following steps:

State Experiment

I am going to do asowers xfc4 panel experiment.

http://lab46.corning-cc.edu/opus/spring2012/asowers/start#experiment_1

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • I was lost… there are terms that he knows that are not listed or given any explanation for.
  • 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?
  • for the user it met what he needed
  • If you find a deviation in opinion, state why you think this might exist.
  • I just need more to be able to implement and at this point do not know what it is.
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?
  • I understand what he is after and that he reached the goal.
  • What improvements could you make to their hypothesis, if any?
  • Explain more about what he is going to do and what tool he is going to use to do it with.
Experiment

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

  • Are the instructions correct in successfully achieving the results?
  • no, i am unable to complete the expirment
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Need more thought about tool needed and how it is to be done.
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?
  • His set up was fine
Data
Analysis

First I needed to attain my IP then I attempted to bring me up

lab46:~$ ssh -X skinney1@192.168.1.112
ssh: connect to host 192.168.1.112 port 22: Connection timed out

attempt to bring panel

lab46:~$ sudo xfce4-panel
[sudo] password for skinney1:
skinney1 is not in the sudoers file.  This incident will be reported.
  • Does the data seem in-line with the published data from the original author?
  • unable to complete
  • Can you explain any deviations?
  • I attempted by using my IPv4 Add and my Default gateway on port 22 with not use.
  • How about any sources of error?
  • just need more information
  • Is the stated hypothesis adequate?
  • yes
Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Maybe i need to be at the comp lab or a strait unix machine
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • For the author, yes.
  • Does the original author appear to have gotten some value out of performing the experiment?
  • yes
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
  • already noted
Retest 9

Perform the following steps:

State Experiment

I am going to retest Brain Robbins play on the break command.

http://lab46.corning-cc.edu/opus/spring2012/brobbin4/start#experiment_1

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Brain did a really good job explaining the concepts and walking the idea from conceptual to completion.
  • Are there additional resources you've found that you can add to the resources list?
  • Nope
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • Yes
  • If you find a deviation in opinion, state why you think this might exist.
  • None
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?
  • yes, nothing wrong with what is listed.
  • 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?
  • Yes, completed without issues
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • None
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?
  • none
Data

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

No additional research was needed.

Analysis

Answer the following:

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

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Using the break command does a better job then exit when you need a break command.
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • yes
  • Does the original author appear to have gotten some value out of performing the experiment?
  • yes
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
  • none, good job dude.

Experiments

Experiment 7

Question

What on earth is telnet for?

Resources

Hypothesis

Can telnet be used like ssh?

Experiment

“GIFY”, play and try.

Data

Telnet is is a network protocol much like ssh. TI is used to provide a connection between a user and server with TCP (Transmission Control Protocol). The basic syntax is telnet host.com. There are a list of arguments that can be used just like with any other utility.

telnet [-468ELadr] [-S tos] [-b address] [-e escapechar] [-l user] [-n tracefile] [host [port]]

Use telnet to connect to a server

telnet towel.blinkenlights.nl

Once connected starwar ascii plays



                                           /~\
                                          ( oo|    They've shut down
                                          _\=/_    the main reactor.
                          ___         #  /  _  \
                         / ()\        \\//|/.\|\\
                       _|_____|_       \/  \_/  ||
                      | | === | |         |\ /| ||
                      |_|  O  |_|         \_ _/   #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________

Analysis

Based on the data collected:

  • Was your hypothesis correct?
  • yes, same thing with not as much fun
  • Was your hypothesis not applicable?
  • yes
  • Is there more going on than you originally thought? (shortcomings in hypothesis)
  • no
  • What shortcomings might there be in your experiment?
  • it was a shoot and hit experiment
  • What shortcomings might there be in your data?

Conclusions

Telnet is just one more approach that has been taken to network computer together. It is used typically in a windows and unix server world.

Experiment 8

Implement TOR

Question

Can TOR be implemented on a droid unix machine.

Resources

Hypothesis

I am not the first, there must be away!?

Experiment

Success is gained from a working install of TOR on a droid unix machine.

Data

Thankfully, i found out after starting this project that Orbot worked on a nice app for TOR. TOR stands for The Onion Router and is designed to enable online anonymity. Much like a multilevel proxy. The project was started in 2002 by Roger Dingledine, nick Mathewson and Paul Syverson. In 2011 the project was awarded the Free Software Foundation's 2010 aware for projects of social benefit. Tor basically works to conceal the user from surveillance and traffic analysis. It encrypts and then randomly bounces the communications through a bunch of relays run by volunteers all over the place.

Install

Simple download the .apk file

https://play.google.com/store/apps/details?id=org.torproject.android&hl=en

Once installed you need to set up some fine points. TOR wants you to have root access to the device, but has a version for the unrooted. It will ask you simple questions about what you want to do with it, have everything use it etc.

I established everything and surprise… everything works fine.

Orbweb is also a nice install allow a full browsing experience that even tells you your fake IP, mine was 31.172.30.4.

Analysis

  • Was your hypothesis correct?
  • Yes
  • Was your hypothesis not applicable?
  • Yes
  • Is there more going on than you originally thought? (shortcomings in hypothesis)
  • NO
  • What shortcomings might there be in your experiment?
  • I cannot seem to find an experiment that is data driven
  • What shortcomings might there be in your data?

Conclusions

Thanks to projects and a supportive community of developers the general public has access to wonderful tools like TOR. The ease of install and of use made this project and easy score.

Retest 3

State Experiment

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • They worked for him, but I need more to go on.
  • Are there additional resources you've found that you can add to the resources list?
  • Yes, noted bellow.
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of concept?
  • yes
  • If you find a deviation in opinion, state why you think this might exist.
  • He seems to have issues with the code.. lets see if i get any further….

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?
  • Yes
  • What improvements could you make to their hypothesis, if any?
  • none

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

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • sure
  • Can you explain any deviations?
  • The mixing of a float and an int value results in two different types of holders.. then to do some math on it and ask for it to be normal just did not work for me.
#include <stdio.h>
#include <float.h>
 
 
int main()
{
 
        float x;
        int y;
        int done;
 
        printf("Listen... we only add two numbers so keep it simple\n");
        printf("input 1st num\n ");
        scanf("%f", &x);
        printf("input 2nd num\n ");
        scanf("%d", &y);
 
        done = x + y;
        printf("%f\n", done);
 
return 0;
}

Value is dumb

input 1st num
 2
input 2nd num
 2
0.000000
  • How about any sources of error?
  • I am not a pro… so i hate pointing at someone else's stuff knowing that i am also missing things.. but since you insist.
    • You can the project was started when we first began out C programming learning.
    • missing line breaks
    • cannot use one printf to get two vaules if not allocated to do so
    • did not declare the math header file
    • attempted a getchar… not sure why
    • The main focus was to see the int and float work together to do a simple math problem.
  • Is the stated hypothesis adequate?
  • yes

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • I need more work with C, but i had fun mixing it up.
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • yes
  • Does the original author appear to have gotten some value out of performing the experiment?
  • yes
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).