Table of Contents

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

I will be using a few different variants to test this hypotheses

https://help.ubuntu.com/community/Installation/FromUSBStick

The recommended platform set up wizard

http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/

Linux sources http://www.backtrack-linux.org/ http://www.fedoraproject.org/ http://www.archlinux.org/download/

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:

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

http://www.ubuntu.com/community

https://help.ubuntu.com/

http://askubuntu.com/

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:

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

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.